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 873aa2d34f2746f21f9913593f549485d67acb05..dde5adea7361a21c243a54d1306bbd983aa71175 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', |
@@ -21,6 +21,27 @@ Polymer({ |
showAndroidApps: Boolean, |
/** |
+ * Dictionary defining page visibility. |
+ * @type {!GuestModePageVisibility} |
+ */ |
+ pageVisibility: Object, |
+ |
+ advancedToggleExpanded: { |
+ type: Boolean, |
+ notify: true, |
+ }, |
+ |
+ /** |
+ * True if a section is fully expanded to hide other sections beneath it. |
+ * False otherwise (even while animating a section open/closed). |
+ * @private {boolean} |
+ */ |
+ hasExpandedSection_: { |
+ type: Boolean, |
+ value: false, |
+ }, |
+ |
+ /** |
* True if the basic page should currently display the reset profile banner. |
* @private {boolean} |
*/ |
@@ -30,6 +51,60 @@ Polymer({ |
return loadTimeData.getBoolean('showResetProfileBanner'); |
}, |
}, |
+ |
+ /** @private {!settings.Route|undefined} */ |
+ currentRoute_: Object, |
+ }, |
+ |
+ listeners: { |
+ 'subpage-expand': 'onSubpageExpanded_', |
+ }, |
+ |
+ /** @override */ |
+ attached: function() { |
+ this.currentRoute_ = settings.getCurrentRoute(); |
+ }, |
+ |
+ /** |
+ * Overrides MainPageBehaviorImpl from MainPageBehavior. |
+ * @param {!settings.Route} newRoute |
+ * @param {settings.Route} oldRoute |
+ */ |
+ currentRouteChanged: function(newRoute, oldRoute) { |
+ this.currentRoute_ = newRoute; |
+ |
+ if (settings.Route.ADVANCED.contains(newRoute)) |
+ this.advancedToggleExpanded = true; |
+ |
+ if (oldRoute && oldRoute.isSubpage()) { |
+ // If the new route isn't the same expanded section, reset |
+ // hasExpandedSection_ for the next transition. |
+ if (!newRoute.isSubpage() || newRoute.section != oldRoute.section) |
+ this.hasExpandedSection_ = false; |
+ } else { |
+ assert(!this.hasExpandedSection_); |
+ } |
+ |
+ 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; |
}, |
/** @private */ |
@@ -46,4 +121,68 @@ Polymer({ |
this.get('pageVisibility.androidApps')); |
return this.showAndroidApps && this.showPage(visibility); |
}, |
+ |
+ /** |
+ * 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) { |
+ return hasExpandedSection ? |
+ settings.Route.ADVANCED.contains(currentRoute) : |
+ 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} Icon name. |
+ * @private |
+ */ |
+ getArrowIcon_: function(opened) { |
+ return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down'; |
+ }, |
}); |