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

Side by Side Diff: chrome/browser/resources/cast/cast.js

Issue 1820023002: Implementation of chrome://cast page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a TODO(crbug.com/597778) comment. Created 4 years, 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 window.addEventListener('load', function init() {
6 chrome.send('requestExtensionId');
7 });
8
9 /** @param {string} extensionId */
10 window['setExtensionId'] = function(extensionId) {
11 var ev = document.querySelector('extensionview');
Bernhard Bauer 2016/05/19 14:34:07 Don't use abbreviations in variable names.
sheretov 2016/05/19 16:16:45 Done.
12
13 /**
14 * @param {string} str
15 * @return {!Array<string>}
16 */
17 var splitUrlOnHash = function(str) {
18 str = str || '';
19 var pos = str.indexOf('#');
20 return (pos !== -1) ? [str.substr(0, pos), str.substr(pos + 1)] : [str, ''];
21 };
22
23 new MutationObserver(function() {
24 var newHash = splitUrlOnHash(ev.getAttribute('src'))[1];
25 var oldHash = window.location.hash.substr(1);
26 if (newHash !== oldHash) {
27 window.location.hash = newHash;
28 }
29 }).observe(ev, {
30 attributes: true
31 });
32
33 window.addEventListener('hashchange', function() {
34 var newHash = window.location.hash.substr(1);
35 var evSrcParts = splitUrlOnHash(ev.getAttribute('src'));
36 if (newHash !== evSrcParts[1]) {
37 ev.load(evSrcParts[0] + '#' + newHash);
38 }
39 });
40
41 ev.load('chrome-extension://' + extensionId + '/cast_setup/devices.html');
42 };
43
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698