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). |
+ * @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() { |
+ this.currentRoute_ = settings.getCurrentRoute(); |
+ }, |
+ |
+ currentRouteChanged: function(newRoute, oldRoute) { |
+ 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)) { |
+ 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() { |
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) |
+ 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) { |
+ return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down'; |
+ }, |
}); |