iTunes web site and Google Chrome on Microsoft Windows

Here’s proof that Apple’s iTunes web site doesn’t natively recognize Google Chrome for automatically launching the iTunes application from the iTunes web site. Below is a screen capture of the source code used by the iTunes web site to detect the presence of the iTunes software on the PC accessing the iTunes web site. The JavaScript function used to detect iTunes is called “iTunesDetected” and will only return TRUE if any of the following are true:

  • the browser’s user agent string contains the word “Macintosh”
  • the browser is Internet Explorer and the iTunes ActiveX component installed
  • the browser is Firefox and the iTunes Mozilla plugin is installed
  • an iTunes cookie named “iTunesPresent” set to true in the domain of the Apple web site visiting or in “.apple.com”

iTunes web site JavaScript that excludes Google Chrome

The $64 question now is what’s the best way to get the “iTunesPresent” cookie set in domain “.apple.com”.

My first thought was to configure Chrome to use a user agent string containing “Macintosh” and then launch iTunes from the iTunes web site once thereby setting the cookie.

Chrome using Macintosh/Safari User Agent String

I was perplexed when this didn’t work. Using the built-in debugger in Chrome I proceeded to set a break point in the iTunesDetected function and then single stepped through the function to see what was happening. Even thought I had set my user agent string to “Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_3; en-us) AppleWebKit/525.19 (KHTML, like Gecko) Version/3.2.1 Safari/525.19” using the Chrome command line switch “–user-agent=” debugging showed me that “navigator.agentString” was still set to the default Chrome UAS.

navigator.userAgent

At this point I decided to take the sledgehammer approach. I navigated Chrome to the following url: http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewTop?id=25204&popId=30 and after receiving the error that iTunes wasn’t installed I set a break-point in the JavaScript that tested whether iTunes was “installed”.

itmsCheck.js

I then reloaded the page and after the breakpoint triggered, I changed “iTunesDetected()” to “true” and began to single step through the code. Once I entered function “its.cookies.setUnescaped” I proceeded to change “if (domain)” to “if (true)” and hard-coded the setting of domainString to ” domain=.apple” (see lines 216 and 217 below).

How to force creation of iTunesPresent cookie in .apple.com domain

I then let the script continue by pressing the run pause-run buttonbutton.

My PC now contains the iTunesPresent cookie in the “.apple.com” domain which now allows me to automatically launch iTunes from web pages on the iTunes web site using Google Chrome.

iTunesPresent cookie

Why Apple doesn’t directly support Google Chrome remains a mystery to me. I understand that Google Chrome is a competing product to Apple’s Safari browser, however, I am confident that Apple will make far more revenue from the iTunes store by making the user experience of iTunes best-in-class using any platform or browser.

Leave a Reply