Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Unified Diff: chrome/browser/resources/settings/settings_page/settings_page_visibility.js

Issue 1477773003: Use dom-if to hide settings pages and show explicitly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..b26b090d543e3d1c1b233a4a9f6ef652ef0b94d1
--- /dev/null
+++ b/chrome/browser/resources/settings/settings_page/settings_page_visibility.js
@@ -0,0 +1,59 @@
+// 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 common to all Settings pages
michaelpg 2015/12/02 19:22:52 nit: period. and more accurate comment
stevenjb 2015/12/02 21:57:10 Done.
+ *
+ * Example:
+ * behaviors: [SettingsPageVisibility],
+ *
+ * @group Chrome UI Behavior
michaelpg 2015/12/02 19:22:52 do we ever plan to use @group for anything?
stevenjb 2015/12/02 21:57:10 Dunno, but we have it everywhere.
+ */
+
+/**
+ * Set this to override page visibility, e.g. in tests.
+ * @type !Object|undefined
+ */
+var SettingPageDefaultVisibility;
+
+/** @polymerBehavior */
+var SettingsPageVisibility = {
+ properties: {
+ /** Dictionary of pages to hide. Includes 'basic' and 'advanced'. */
michaelpg 2015/12/02 19:22:52 Can you provide a more specific /** @type */? Isn
stevenjb 2015/12/02 21:57:10 Opps. It did originally but then I decided that wa
+ pageVisible: {
+ type: Object,
+ value: SettingPageDefaultVisibility,
+ notify: true,
+ },
+ },
+
+ /**
+ * Sets the visibility for each page in |pages| to true, causing it to load.
+ * @param {!Array<string>} pages
+ */
+ setVisiblePages: function(pages) {
+ var visible = this.pageVisible || {};
michaelpg 2015/12/02 19:22:52 since setVisiblePages([]) is a no-op (it doesn't h
stevenjb 2015/12/02 21:57:10 That kinda sorta almost makes sense to me :) Done.
+ for (var p of pages) {
+ visible[p] = true;
+ }
+ this.set('pageVisible', visible);
michaelpg 2015/12/02 19:22:52 this.pageVisible = visible
stevenjb 2015/12/02 21:57:10 Done.
+ },
+
+ /**
+ * Sets the visibility for all settings-section entries unless
+ * pageVisible has already been explicitly defined.
+ */
+ showDefaultSections: function() {
+ if (this.pageVisible != undefined)
+ return;
+ var pages = [];
+ var sections = this.shadowRoot.querySelectorAll('settings-section');
+ var len = sections.length;
+ for (var i = 0; i < len; ++i) {
+ pages.push(sections[i].section);
+ }
+ this.setVisiblePages(pages);
+ },
+};

Powered by Google App Engine
This is Rietveld 408576698