| Index: chrome/browser/resources/cast/cast.js
|
| diff --git a/chrome/browser/resources/cast/cast.js b/chrome/browser/resources/cast/cast.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..33e3bdadba427f516f3d61906794725051d44538
|
| --- /dev/null
|
| +++ b/chrome/browser/resources/cast/cast.js
|
| @@ -0,0 +1,43 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +window.addEventListener('load', function init() {
|
| + chrome.send('requestExtensionId');
|
| +});
|
| +
|
| +/** @param {string} extensionId */
|
| +window['setExtensionId'] = function(extensionId) {
|
| + var ev = document.querySelector('extensionview');
|
| +
|
| + /**
|
| + * @param {string} str
|
| + * @return {!Array<string>}
|
| + */
|
| + var splitUrlOnHash = function(str) {
|
| + str = str || '';
|
| + var pos = str.indexOf('#');
|
| + return (pos !== -1) ? [str.substr(0, pos), str.substr(pos + 1)] : [str, ''];
|
| + };
|
| +
|
| + new MutationObserver(function() {
|
| + var newHash = splitUrlOnHash(ev.getAttribute('src'))[1];
|
| + var oldHash = window.location.hash.substr(1);
|
| + if (newHash !== oldHash) {
|
| + window.location.hash = newHash;
|
| + }
|
| + }).observe(ev, {
|
| + attributes: true
|
| + });
|
| +
|
| + window.addEventListener('hashchange', function() {
|
| + var newHash = window.location.hash.substr(1);
|
| + var evSrcParts = splitUrlOnHash(ev.getAttribute('src'));
|
| + if (newHash !== evSrcParts[1]) {
|
| + ev.load(evSrcParts[0] + '#' + newHash);
|
| + }
|
| + });
|
| +
|
| + ev.load('chrome-extension://' + extensionId + '/cast_setup/devices.html');
|
| +};
|
| +
|
|
|