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

Unified 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: rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/cast/cast.html ('k') | chrome/browser/resources/cast/cast_favicon.ico » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e7bd2059148425d76e1d8f7b8b5ff0eef60e1020
--- /dev/null
+++ b/chrome/browser/resources/cast/cast.js
@@ -0,0 +1,40 @@
+// 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 extensionView = 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(extensionView.getAttribute('src'))[1];
+ var oldHash = window.location.hash.substr(1);
+ if (newHash !== oldHash) {
+ window.location.hash = newHash;
+ }
+ }).observe(extensionView, {
+ attributes: true
+ });
+
+ window.addEventListener('hashchange', function() {
+ var newHash = window.location.hash.substr(1);
+ var extensionViewSrcParts = splitUrlOnHash(
+ extensionView.getAttribute('src'));
+ if (newHash !== extensionViewSrcParts[1]) {
+ extensionView.load(extensionViewSrcParts[0] + '#' + newHash);
+ }
+ });
+
+ extensionView.load('chrome-extension://' +
+ loadTimeData.getString('extensionId') + '/cast_setup/devices.html');
+});
+
« no previous file with comments | « chrome/browser/resources/cast/cast.html ('k') | chrome/browser/resources/cast/cast_favicon.ico » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698