summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/resources/settings/settings_page/settings_page_visibility.js
blob: 660d8e17d8b72c1c25d80a0759df9aed6dbae285 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright 2015 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.

/**
 * @fileoverview
 * Behavior controlling the visibility of Settings pages.
 *
 * Example:
 *   behaviors: [SettingsPageVisibility],
 *
 * @group Chrome UI Behavior
 */

/**
 * Set this to true in tests before loading the page (e.g. in preLoad()) so that
 * pages do not initially get created. Set this to false BEFORE modifying
 * pageVisibility. NOTE: Changing this value after the DOM is loaded will not
 * trigger a visibility change, pageVisibility must be modified to trigger data
 * binding events.
 * @type {boolean}
 */
var settingsHidePagesByDefaultForTest;

/** @polymerBehavior */
var SettingsPageVisibility = {
  properties: {
    /**
     * Dictionary defining page visibility. If not set for a page, visibility
     * will default to true, unless settingsHidePagesByDefaultForTest is set
     * in which case visibility defaults to false.
     * @type {Object<boolean>}
     */
    pageVisibility: {
      type: Object,
      value: function() { return {}; },
    },
  },

  /**
   * @param {boolean} visibility
   * @return {boolean}
   */
  showPage: function(visibility) {
    if (settingsHidePagesByDefaultForTest)
      return visibility === true;
    return visibility !== false;
  },
};