Chromium Code Reviews| Index: chrome/browser/resources/settings/settings_page/settings_page_visibility.js |
| diff --git a/chrome/browser/resources/settings/settings_page/settings_page_visibility.js b/chrome/browser/resources/settings/settings_page/settings_page_visibility.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..961a5f222f472865b6c9c0723661fb81ef5915ed |
| --- /dev/null |
| +++ b/chrome/browser/resources/settings/settings_page/settings_page_visibility.js |
| @@ -0,0 +1,47 @@ |
| +// 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 SettingsHideAllPagesForTest; |
|
Dan Beam
2015/12/08 02:55:27
nit: settingsHideAllPagesForTest
stevenjb
2015/12/08 20:07:37
Done.
|
| + |
| +/** @polymerBehavior */ |
| +var SettingsPageVisibility = { |
| + properties: { |
| + /** |
| + * Dictionary defining page visibility. If not set for a page, visibility |
| + * will default to true (unless SettingsHideAllPagesForTest is set). |
| + * @type {Object<string, boolean>} |
|
michaelpg
2015/12/08 00:45:58
nit: just Object<boolean>, keys are always strings
Dan Beam
2015/12/08 02:55:27
+1 (I thought we had a presubmit about this?)
stevenjb
2015/12/08 20:07:37
Done. (And apparently not, we have 128 instances o
|
| + */ |
| + pageVisibility: { |
| + type: Object, |
| + value: function() { return {}; }, |
| + notify: true, |
|
michaelpg
2015/12/08 00:45:58
notify: true is unnecessary -- no one is two-way b
stevenjb
2015/12/08 20:07:37
Not currently... and probably not ever. Done.
|
| + }, |
| + }, |
| + |
| + /** |
| + * @param {boolean} visibility |
| + * @return {boolean} |
| + */ |
| + showPage: function(visibility) { |
| + return !SettingsHideAllPagesForTest && visibility !== false; |
| + }, |
| +}; |