Chromium Code Reviews| 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..3cc61317c07f65b257c1dc8816dbe437f7a638aa |
| --- /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.pageDiv.hidden) |
|
Dan Beam
2014/08/06 18:30:54
can't you ask if page.visible?
michaelpg
2014/08/06 21:58:18
Done.
|
| + uber.invokeMethodOnParent('stopInterceptingEvents'); |
| + else |
| + uber.invokeMethodOnParent('beginInterceptingEvents'); |
| + } |
| + }, |
| + |
| + /** |
| + * 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.call(uber, {}, path); |
|
Dan Beam
2014/08/06 18:30:54
why are you using |uber| as the thisArg?
michaelpg
2014/08/06 21:58:18
just copypasta. can just be historyFunction({}, pa
|
| + }, |
| + }; |
| + |
| + // Export |
| + return { |
| + PageManagerObserver: PageManagerObserver |
| + }; |
| +}); |