Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(849)

Unified Diff: ui/file_manager/video_player/js/cast/caster.js

Issue 505043002: Files.app Test: check the cast icon in drive volume (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Define apiConfig property. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/file_manager/video_player/js/cast/caster.js
diff --git a/ui/file_manager/video_player/js/cast/caster.js b/ui/file_manager/video_player/js/cast/caster.js
index e349f03bf7965db772d6d9868fcf140490d917d0..e81ab6618c1513a4a680a4d235d476a65000bc68 100644
--- a/ui/file_manager/video_player/js/cast/caster.js
+++ b/ui/file_manager/video_player/js/cast/caster.js
@@ -22,6 +22,11 @@ util.addPageLoadHandler(function() {
* Starts initialization of cast-related feature.
*/
function initialize() {
+ if (window.loadMockCastExtensionForTest) {
+ onLoadCastExtension(initializeApi);
+ return;
+ }
+
CastExtensionDiscoverer.findInstalledExtension(function(foundId) {
if (foundId)
loadCastAPI(initializeApi);
@@ -66,33 +71,37 @@ function loadCastAPI(callback, opt_secondTry) {
}.wrap());
}.wrap();
- var onLoad = function() {
- if(!chrome.cast || !chrome.cast.isAvailable) {
- var checkTimer = setTimeout(function() {
- console.error('Either "Google Cast API" or "Google Cast" extension ' +
- 'seems not to be installed?');
- }.wrap(), 5000);
-
- window['__onGCastApiAvailable'] = function(loaded, errorInfo) {
- clearTimeout(checkTimer);
-
- if (loaded)
- callback();
- else
- console.error('Google Cast extension load failed.', errorInfo);
- }.wrap();
- } else {
- setTimeout(callback); // Runs asynchronously.
- }
- }.wrap();
-
script.src = '_modules/mafeflapfdfljijmlienjedomfjfmhpd/cast_sender.js';
hirono 2014/08/26 05:59:01 How about overriding the path of chrome cat API fo
yoshiki 2014/08/26 06:11:02 That's not good because here this doesn't the load
hirono 2014/08/26 06:33:24 Cannot we load the mock API instead of the SDK loa
script.addEventListener('error', onError);
- script.addEventListener('load', onLoad);
+ script.addEventListener('load', onLoadCastExtension.bind(null, callback));
document.body.appendChild(script);
}
/**
+ * Loads the cast sdk extension.
+ * @param {function} callback Callback (executed asynchronously).
hirono 2014/08/26 05:59:01 nit: Please add type annotation to the function.
yoshiki 2014/08/26 06:11:02 Done.
+ */
+function onLoadCastExtension(callback) {
+ if(!chrome.cast || !chrome.cast.isAvailable) {
+ var checkTimer = setTimeout(function() {
+ console.error('Either "Google Cast API" or "Google Cast" extension ' +
+ 'seems not to be installed?');
+ }.wrap(), 5000);
+
+ window['__onGCastApiAvailable'] = function(loaded, errorInfo) {
+ clearTimeout(checkTimer);
+
+ if (loaded)
+ callback();
+ else
+ console.error('Google Cast extension load failed.', errorInfo);
+ }.wrap();
+ } else {
+ setTimeout(callback); // Runs asynchronously.
+ }
+};
+
+/**
* Initialize Cast API.
*/
function initializeApi() {

Powered by Google App Engine
This is Rietveld 408576698