Index: chrome/browser/resources/uber/uber_page_manager_observer.js |
diff --git a/chrome/browser/resources/uber/uber_page_manager_observer.js b/chrome/browser/resources/uber/uber_page_manager_observer.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..330fabb30a94303f0706111cca25915c0a57026a |
--- /dev/null |
+++ b/chrome/browser/resources/uber/uber_page_manager_observer.js |
@@ -0,0 +1,58 @@ |
+// Copyright 2014 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. |
+ |
+cr.define('uber', function() { |
+ var PageManager = cr.ui.pageManager.PageManager; |
+ |
+ /** |
+ * A PageManager observer that updates the uber page. |
+ * @constructor |
+ * @implements {PageManager.Observer} |
+ */ |
+ function PageManagerObserver() {} |
+ |
+ PageManagerObserver.prototype = { |
+ __proto__: PageManager.Observer.prototype, |
+ |
+ /** |
+ * Informs the uber page when a top-level overlay is opened or closed. |
+ * @param {Page} page The page that is being shown or was hidden. |
+ * @override |
+ */ |
+ onPageVisibilityChanged: function(page) { |
+ if (PageManager.isTopLevelOverlay(page)) { |
+ if (page.visible) |
+ uber.invokeMethodOnParent('beginInterceptingEvents'); |
+ else |
+ uber.invokeMethodOnParent('stopInterceptingEvents'); |
+ } |
+ }, |
+ |
+ /** |
+ * Uses uber to set the title. |
+ * @param {string} title The title to set. |
+ * @override |
+ */ |
+ updateTitle: function(title) { |
+ uber.setTitle(title); |
+ }, |
+ |
+ /** |
+ * Pushes the current page onto the history stack, replacing the current |
+ * entry if appropriate. |
+ * @param {string} path The path of the page to push onto the stack. |
+ * @param {boolean} replace If true, allow no history events to be created. |
+ * @override |
+ */ |
+ updateHistory: function(path, replace) { |
+ var historyFunction = replace ? uber.replaceState : uber.pushState; |
+ historyFunction({}, path); |
+ }, |
+ }; |
+ |
+ // Export |
+ return { |
+ PageManagerObserver: PageManagerObserver |
+ }; |
+}); |