Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / uber / uber_page_manager_observer.js
1 // Copyright 2014 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 cr.define('uber', function() {
6   var PageManager = cr.ui.pageManager.PageManager;
7
8   /**
9    * A PageManager observer that updates the uber page.
10    * @constructor
11    * @implements {PageManager.Observer}
12    */
13   function PageManagerObserver() {}
14
15   PageManagerObserver.prototype = {
16     __proto__: PageManager.Observer.prototype,
17
18     /**
19      * Informs the uber page when a top-level overlay is opened or closed.
20      * @param {Page} page The page that is being shown or was hidden.
21      * @override
22      */
23     onPageVisibilityChanged: function(page) {
24       if (PageManager.isTopLevelOverlay(page)) {
25         if (page.visible)
26           uber.invokeMethodOnParent('beginInterceptingEvents');
27         else
28           uber.invokeMethodOnParent('stopInterceptingEvents');
29       }
30     },
31
32     /**
33      * Uses uber to set the title.
34      * @param {string} title The title to set.
35      * @override
36      */
37     updateTitle: function(title) {
38       uber.setTitle(title);
39     },
40
41     /**
42      * Pushes the current page onto the history stack, replacing the current
43      * entry if appropriate.
44      * @param {string} path The path of the page to push onto the stack.
45      * @param {boolean} replace If true, allow no history events to be created.
46      * @override
47      */
48     updateHistory: function(path, replace) {
49       var historyFunction = replace ? uber.replaceState : uber.pushState;
50       historyFunction({}, path);
51     },
52   };
53
54   // Export
55   return {
56     PageManagerObserver: PageManagerObserver
57   };
58 });