Friday, March 15, 2013

Just for fun - two Chrome packaged apps


This is just a teaser. I will share the apps once the bug # 197381 is fixed!

TODO
  • Figure out a way to send the correct User Agent headers so that websites will think that they are talking to real devices
  • Handler overflow and scrollbar (style). Exploring an interesting idea to fix this as follows:
  • Run Chrome with custom profile (using --user-data-dir)
  • Install the app in that instance of the Chrome
  • Run the app_host with the same custom profile
  • Create a shortcut for the app on the desktop
  • Edit the shortcut to point to the same profile (using --user-data-dir)
  • Edit the custom stylesheet at
.../Default/User StyleSheets/Custom.css
  • And add the following CSS 
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); 
    -webkit-border-radius: 10px;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    -webkit-border-radius: 10px;
    border-radius: 3px;
    background: rgba(128,128,128,1); 
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5); 
}

::-webkit-scrollbar-thumb:window-inactive {
background: rgba(192,192,192,0.4); 
}
  • And using the following command line option
--user-agent="Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3"
  • Voila...notice the thin scrollbars and mobile website for ios being displayed

  • You may have to use a batch (.bat) file to invoke the app like this
@echo off
cmd /c start C:\Users\name\AppData\Local\Google\Chrome\Application\app_host.exe --user-data-dir="c:\Users\name\.chriphone" --profile-directory=Default  --user-agent="Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3" --app-id=phfcjmgphpbpgofopejnibdpkcmmcfee

  • I get the following...gmail.com thinks it is talking to a real iPhone!

  • Similarly with the following user agent string:
--user-agent="Mozilla/5.0 (Linux; U; Android 4.0.4; en-gb; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"
  • I get the following...gmail.com thinks it is talking to a real Galaxy S3!

Also S4:



This basically solves (albeit in a hacky way) a question that was asked on

Chrome Apps Office Hours - the WebView Control

Enjoy!

No comments: