• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (c) 2012 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<include src="../uber/uber_page_manager_observer.js">
6<include src="../uber/uber_utils.js">
7
8(function() {
9  var HelpPage = help.HelpPage;
10  var PageManager = cr.ui.pageManager.PageManager;
11
12  /**
13   * DOMContentLoaded handler, sets up the page.
14   */
15  function load() {
16    PageManager.register(HelpPage.getInstance());
17
18    if (help.ChannelChangePage) {
19      PageManager.registerOverlay(help.ChannelChangePage.getInstance(),
20                                  HelpPage.getInstance());
21    }
22    cr.ui.FocusManager.disableMouseFocusOnButtons();
23    PageManager.addObserver(new uber.PageManagerObserver());
24    PageManager.initialize(HelpPage.getInstance());
25    uber.onContentFrameLoaded();
26
27    var pageName = PageManager.getPageNameFromPath();
28    // Still update history so that chrome://help/nonexistant redirects
29    // appropriately to chrome://help/. If the URL matches, updateHistory
30    // will avoid adding the extra state.
31    var updateHistory = true;
32    PageManager.showPageByName(pageName, updateHistory, {replaceState: true});
33  }
34
35  document.addEventListener('DOMContentLoaded', load);
36
37  /**
38   * Listener for the |beforeunload| event.
39   */
40  window.onbeforeunload = function() {
41    PageManager.willClose();
42  };
43
44  /**
45   * Listener for the |popstate| event.
46   * @param {Event} e The |popstate| event.
47   */
48  window.onpopstate = function(e) {
49    var pageName = PageManager.getPageNameFromPath();
50    PageManager.setState(pageName, location.hash, e.state);
51  };
52})();
53