Chromium Code Reviews| 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..3f5ffc4e1bc87e84ae14659c35c8347f28147e49 |
| --- /dev/null |
| +++ b/chrome/browser/resources/cast/cast.js |
| @@ -0,0 +1,39 @@ |
| +// 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() { |
| + 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://enhhojjnijigcajfphajepfemndkmdlo' + |
|
apacible
2016/05/16 19:04:07
If this fails to load, do we expect the default "P
apacible
2016/05/16 19:04:07
For different channels, the extension ID will be d
sheretov
2016/05/17 01:59:26
We expect to get the default behavior when extensi
sheretov
2016/05/17 01:59:26
Done, but I'm not sure if this is the right mechan
apacible
2016/05/18 17:30:42
mfoltz: thoughts?
apacible
2016/05/18 17:30:42
If the extensionview fails to load the URL, could
sheretov
2016/05/18 18:11:11
Sounds good. I'll put this in a subsequent CL.
|
| + '/cast_setup/devices.html'); |
| +}); |
| + |