• 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
5cr.define('options', function() {
6  /** @const */ var FocusOutlineManager = cr.ui.FocusOutlineManager;
7
8  var OptionsPage = {
9    /**
10     * This is the absolute difference maintained between standard and
11     * fixed-width font sizes. Refer http://crbug.com/91922.
12     * @const
13     */
14    SIZE_DIFFERENCE_FIXED_STANDARD: 3,
15
16    /**
17     * Initializes the complete options page. This will cause all C++ handlers
18     * to be invoked to do final setup.
19     */
20    initialize: function() {
21      chrome.send('coreOptionsInitialize');
22    },
23
24    /**
25     * Shows the tab contents for the given navigation tab.
26     * @param {Node} tab The tab that the user clicked.
27     */
28    showTab: function(tab) {
29      // Search parents until we find a tab, or the nav bar itself. This allows
30      // tabs to have child nodes, e.g. labels in separately-styled spans.
31      while (tab && tab.classList &&
32             !tab.classList.contains('subpages-nav-tabs') &&
33             !tab.classList.contains('tab')) {
34        tab = tab.parentNode;
35      }
36      if (!tab || !tab.classList || !tab.classList.contains('tab'))
37        return;
38
39      // Find tab bar of the tab.
40      var tabBar = tab;
41      while (tabBar && tabBar.classList &&
42             !tabBar.classList.contains('subpages-nav-tabs')) {
43        tabBar = tabBar.parentNode;
44      }
45      if (!tabBar || !tabBar.classList)
46        return;
47
48      if (tabBar.activeNavTab != null) {
49        tabBar.activeNavTab.classList.remove('active-tab');
50        $(tabBar.activeNavTab.getAttribute('tab-contents')).classList.
51            remove('active-tab-contents');
52      }
53
54      tab.classList.add('active-tab');
55      $(tab.getAttribute('tab-contents')).classList.add('active-tab-contents');
56      tabBar.activeNavTab = tab;
57    },
58
59    /**
60     * Shows or hides options for clearing Flash LSOs.
61     * @param {boolean} enabled Whether plugin data can be cleared.
62     */
63    setClearPluginLSODataEnabled: function(enabled) {
64      if (enabled) {
65        document.documentElement.setAttribute(
66            'flashPluginSupportsClearSiteData', '');
67      } else {
68        document.documentElement.removeAttribute(
69            'flashPluginSupportsClearSiteData');
70      }
71      if (navigator.plugins['Shockwave Flash'])
72        document.documentElement.setAttribute('hasFlashPlugin', '');
73    },
74
75    /**
76     * Shows or hides Pepper Flash settings.
77     * @param {boolean} enabled Whether Pepper Flash settings should be enabled.
78     */
79    setPepperFlashSettingsEnabled: function(enabled) {
80      if (enabled) {
81        document.documentElement.setAttribute(
82            'enablePepperFlashSettings', '');
83      } else {
84        document.documentElement.removeAttribute(
85            'enablePepperFlashSettings');
86      }
87    },
88
89    /**
90     * Sets whether Settings is shown as a standalone page in a window for the
91     * app launcher settings "app".
92     * @param {boolean} isSettingsApp Whether this page is shown standalone.
93     */
94    setIsSettingsApp: function(isSettingsApp) {
95      document.documentElement.classList.toggle('settings-app', isSettingsApp);
96    },
97
98    /**
99     * Returns true if Settings is shown as an "app" (in a window by itself)
100     * for the app launcher settings "app".
101     * @return {boolean} Whether this page is shown standalone.
102     */
103    isSettingsApp: function() {
104      return document.documentElement.classList.contains('settings-app');
105    },
106  };
107
108  // Export
109  return {
110    OptionsPage: OptionsPage
111  };
112});
113