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

Unified Diff: chrome/browser/resources/settings/basic_page/basic_page.js

Issue 2518233004: MD Settings: Move settings-advanced-page into settings-basic-page (Closed)
Patch Set: rebase/fix line lengths Created 4 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/basic_page/basic_page.js
diff --git a/chrome/browser/resources/settings/basic_page/basic_page.js b/chrome/browser/resources/settings/basic_page/basic_page.js
index 7facd9f8179c0bdc2b8bf05ebfbc7087b71c5889..66e2674385f874c2ccb06028b8831636a1238d1c 100644
--- a/chrome/browser/resources/settings/basic_page/basic_page.js
+++ b/chrome/browser/resources/settings/basic_page/basic_page.js
@@ -4,7 +4,7 @@
/**
* @fileoverview
- * 'settings-basic-page' is the settings page containing the basic settings.
+ * 'settings-basic-page' is the settings page containing the actual settings.
*/
Polymer({
is: 'settings-basic-page',
@@ -19,6 +19,36 @@ Polymer({
},
/**
+ * Dictionary defining page visibility.
+ * @type {!GuestModePageVisibility}
+ */
+ pageVisibility: Object,
+
+ advancedToggleExpanded: {
+ type: Boolean,
+ notify: true,
+ },
+
+ /**
+ * Whether a search operation is in progress or previous search results are
+ * being displayed.
+ */
+ inSearchMode: {
+ type: Boolean,
+ value: false,
+ },
+
+ /**
+ * True if a section is fully expanded to hide other sections beneath it.
+ * Not true otherwise (even while animating a section open/closed).
dpapad 2016/12/02 19:45:53 Nit: s/Not true/False
michaelpg 2016/12/08 03:31:59 Done.
+ * @private {boolean}
+ */
+ hasExpandedSection_: {
+ type: Boolean,
+ value: false,
+ },
+
+ /**
* True if the basic page should currently display the reset profile banner.
* @private {boolean}
*/
@@ -28,9 +58,120 @@ Polymer({
return loadTimeData.getBoolean('showResetProfileBanner');
},
},
+
+ /** @private {!settings.Route|undefined} */
+ currentRoute_: Object,
+ },
+
+ listeners: {
+ 'subpage-expand': 'onSubpageExpanded_',
+ },
+
+ attached: function() {
dpapad 2016/12/02 19:45:54 Nit: @override
michaelpg 2016/12/08 03:31:59 Done.
+ this.currentRoute_ = settings.getCurrentRoute();
+ },
+
+ currentRouteChanged: function(newRoute, oldRoute) {
dpapad 2016/12/02 19:45:53 @param annotations missing. Also, can you mention
michaelpg 2016/12/08 03:31:59 Done. (Can't use @override because it's overriding
+ this.currentRoute_ = newRoute;
+
+ if (settings.Route.ADVANCED.contains(newRoute))
+ this.advancedToggleExpanded = true;
+
+ // When the route changes away from a sub-page, immediately update
+ // hasExpandedSection_ to unhide the other sections.
+ if (oldRoute && !(newRoute.isSubpage() && oldRoute.isSubpage() &&
+ newRoute.section == oldRoute.section)) {
dpapad 2016/12/02 19:45:53 Indentation is 6 from previous line. Shouldn't it
michaelpg 2016/12/08 03:31:59 6 is a mistake. 8 might be better because it's an
+ this.hasExpandedSection_ = false;
+ }
+
+ MainPageBehaviorImpl.currentRouteChanged.call(this, newRoute, oldRoute);
+ },
+
+ /**
+ * Queues a task to search the basic sections, then another for the advanced
+ * sections.
+ * @param {string} query The text to search for.
+ * @return {!Promise<!settings.SearchRequest>} A signal indicating that
+ * searching finished.
+ */
+ searchContents: function(query) {
+ var whenSearchDone = settings.getSearchManager().search(
+ query, assert(this.$$('#basicPage')));
+
+ if (this.pageVisibility.advancedSettings !== false) {
+ assert(whenSearchDone === settings.getSearchManager().search(
+ query, assert(this.$$('#advancedPage'))));
+ }
+
+ return whenSearchDone;
},
onResetDone_: function() {
dpapad 2016/12/02 19:45:54 @private
michaelpg 2016/12/08 03:31:59 already done by something else i think?
this.showResetProfileBanner_ = false;
},
+
+ /**
+ * Hides everything but the newly expanded subpage.
+ * @private
+ */
+ onSubpageExpanded_: function() {
+ this.hasExpandedSection_ = true;
+ },
+
+ /**
+ * @param {boolean} inSearchMode
+ * @param {boolean} hasExpandedSection
+ * @return {boolean}
+ * @private
+ */
+ showAdvancedToggle_: function(inSearchMode, hasExpandedSection) {
+ return !inSearchMode && !hasExpandedSection;
+ },
+
+ /**
+ * @param {!settings.Route} currentRoute
+ * @param {boolean} inSearchMode
+ * @param {boolean} hasExpandedSection
+ * @return {boolean} Whether to show the basic page, taking into account
+ * both routing and search state.
+ * @private
+ */
+ showBasicPage_: function(currentRoute, inSearchMode, hasExpandedSection) {
+ return !hasExpandedSection || settings.Route.BASIC.contains(currentRoute);
+ },
+
+ /**
+ * @param {!settings.Route} currentRoute
+ * @param {boolean} inSearchMode
+ * @param {boolean} hasExpandedSection
+ * @param {boolean} advancedToggleExpanded
+ * @return {boolean} Whether to show the advanced page, taking into account
+ * both routing and search state.
+ * @private
+ */
+ showAdvancedPage_: function(currentRoute, inSearchMode, hasExpandedSection,
+ advancedToggleExpanded) {
+ if (hasExpandedSection)
dpapad 2016/12/02 19:45:54 Nit: return hasExpandedSection ? settings.Rout
michaelpg 2016/12/08 03:31:58 Done.
+ return settings.Route.ADVANCED.contains(currentRoute);
+
+ return advancedToggleExpanded || inSearchMode;
+ },
+
+ /**
+ * @param {(boolean|undefined)} visibility
+ * @return {boolean} True unless visibility is false.
+ * @private
+ */
+ showAdvancedSettings_: function(visibility) {
+ return visibility !== false;
+ },
+
+ /**
+ * @param {boolean} opened Whether the menu is expanded.
+ * @return {string} Which icon to use.
+ * @private
+ */
+ arrowState_: function(opened) {
dpapad 2016/12/02 19:45:53 Nit: How about renaming to|getIcon_|? Seems more e
michaelpg 2016/12/08 03:31:59 Done.
+ return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down';
+ },
});

Powered by Google App Engine
This is Rietveld 408576698