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

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: 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..1a55a14c18971aff10219cd89c9886e49923adf1 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,51 @@ 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';
script.addEventListener('error', onError);
- script.addEventListener('load', onLoad);
+ script.addEventListener('load', onLoadCastExtension.bind(null, callback));
+ document.body.appendChild(script);
+}
+
+/**
+ * Loads the mock cast extension.
+ * @param {function} callback Callback (executed asynchronously).
+ */
+function loadMockCastAPI(callback) {
hirono 2014/08/26 00:56:58 Is the function used?
yoshiki 2014/08/26 05:31:24 It was used. Removed.
+ var script = document.createElement('script');
+ script.src = window.mockCastExtensionLoaderForTest ;
+ script.addEventListener('error', function() {
+ chrome.test.failed('');
+ });
+ script.addEventListener('load', onLoadCastExtension.bind(null, callback));
document.body.appendChild(script);
}
/**
+ * Loads the cast sdk extension.
+ * @param {function} callback Callback (executed asynchronously).
+ */
+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