| 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 /** | |
| 14 * @type {string} | |
| 15 * @const | |
| 16 */ | |
| 17 var CAST_COMMAND_LINE_FLAG = 'enable-video-player-chromecast-support'; | |
| 18 | |
| 19 // THIS IS A TEST APP. | 13 // THIS IS A TEST APP. |
| 20 // TODO(yoshiki): Fix this before launch. | 14 // TODO(yoshiki): Fix this before launch. |
| 21 var APPLICATION_ID = '214CC863'; | 15 var APPLICATION_ID = '214CC863'; |
| 22 | 16 |
| 23 chrome.commandLinePrivate.hasSwitch(CAST_COMMAND_LINE_FLAG, function(result) { | 17 util.addPageLoadHandler(function() { |
| 24 if (!result) | |
| 25 return; | |
| 26 | |
| 27 // TODO(yoshiki): Check if the Google Cast extension is installed or not. | 18 // TODO(yoshiki): Check if the Google Cast extension is installed or not. |
| 28 // If not installed, we should skip all cast-related functionality. | 19 // If not installed, we should skip all cast-related functionality. |
| 29 | 20 |
| 30 loadCastAPI(initializeApi); | 21 loadCastAPI(initializeApi); |
| 31 }); | 22 }); |
| 32 | 23 |
| 33 /** | 24 /** |
| 34 * Executes the given callback after the cast extension is initialized. | 25 * Executes the given callback after the cast extension is initialized. |
| 35 * @param {function} callback Callback (executed asynchronously). | 26 * @param {function} callback Callback (executed asynchronously). |
| 36 * @param {boolean=} opt_secondTry Spericy try if it's second call after | 27 * @param {boolean=} opt_secondTry Spericy try if it's second call after |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 } | 121 } |
| 131 | 122 |
| 132 player.setCastList(receivers); | 123 player.setCastList(receivers); |
| 133 } else if (availability == chrome.cast.ReceiverAvailability.UNAVAILABLE) { | 124 } else if (availability == chrome.cast.ReceiverAvailability.UNAVAILABLE) { |
| 134 player.setCastList([]); | 125 player.setCastList([]); |
| 135 } else { | 126 } else { |
| 136 console.error('Unexpected response in onReceiver.', arguments); | 127 console.error('Unexpected response in onReceiver.', arguments); |
| 137 player.setCastList([]); | 128 player.setCastList([]); |
| 138 } | 129 } |
| 139 } | 130 } |
| OLD | NEW |