Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 // This hack prevents a bug on the cast extension. | 7 // This hack prevents a bug on the cast extension. |
| 8 // TODO(yoshiki): Remove this once the cast extension supports Chrome apps. | 8 // TODO(yoshiki): Remove this once the cast extension supports Chrome apps. |
| 9 // Although localStorage in Chrome app is not supported, but it's used in the | 9 // Although localStorage in Chrome app is not supported, but it's used in the |
| 10 // cast extension. This line prevents an exception on using localStorage. | 10 // cast extension. This line prevents an exception on using localStorage. |
| 11 window.__defineGetter__('localStorage', function() { return {}; }); | 11 window.__defineGetter__('localStorage', function() { return {}; }); |
| 12 | 12 |
| 13 // THIS IS A TEST APP. | 13 // THIS IS A TEST APP. |
| 14 // TODO(yoshiki): Fix this before launch. | 14 // TODO(yoshiki): Fix this before launch. |
| 15 var APPLICATION_ID = '214CC863'; | 15 var APPLICATION_ID = '214CC863'; |
| 16 | 16 |
| 17 util.addPageLoadHandler(function() { | 17 util.addPageLoadHandler(function() { |
| 18 // TODO(yoshiki): Check if the Google Cast extension is installed or not. | 18 CastExtensionDiscoverer.findInstalledExtension(function(foundId) { |
| 19 // If not installed, we should skip all cast-related functionality. | 19 console.log(foundId); |
|
fukino
2014/08/07 00:35:04
nit: Remaining debug print? If not, more readable
yoshiki
2014/08/07 06:33:46
It should be removed.
| |
| 20 | 20 if (foundId) |
| 21 loadCastAPI(initializeApi); | 21 loadCastAPI(initializeApi); |
| 22 else | |
| 23 console.info('No Google Cast extension is installed.'); | |
| 24 }); | |
| 22 }); | 25 }); |
| 23 | 26 |
| 24 /** | 27 /** |
| 25 * Executes the given callback after the cast extension is initialized. | 28 * Executes the given callback after the cast extension is initialized. |
| 26 * @param {function} callback Callback (executed asynchronously). | 29 * @param {function} callback Callback (executed asynchronously). |
| 27 * @param {boolean=} opt_secondTry Spericy try if it's second call after | 30 * @param {boolean=} opt_secondTry Spericy try if it's second call after |
| 28 * installation of Cast API extension. | 31 * installation of Cast API extension. |
| 29 */ | 32 */ |
| 30 function loadCastAPI(callback, opt_secondTry) { | 33 function loadCastAPI(callback, opt_secondTry) { |
| 31 var script = document.createElement('script'); | 34 var script = document.createElement('script'); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 } | 124 } |
| 122 | 125 |
| 123 player.setCastList(receivers); | 126 player.setCastList(receivers); |
| 124 } else if (availability == chrome.cast.ReceiverAvailability.UNAVAILABLE) { | 127 } else if (availability == chrome.cast.ReceiverAvailability.UNAVAILABLE) { |
| 125 player.setCastList([]); | 128 player.setCastList([]); |
| 126 } else { | 129 } else { |
| 127 console.error('Unexpected response in onReceiver.', arguments); | 130 console.error('Unexpected response in onReceiver.', arguments); |
| 128 player.setCastList([]); | 131 player.setCastList([]); |
| 129 } | 132 } |
| 130 } | 133 } |
| OLD | NEW |