Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * 'settings-basic-page' is the settings page containing the basic settings. | 7 * 'settings-basic-page' is the settings page containing the actual settings. |
| 8 */ | 8 */ |
| 9 Polymer({ | 9 Polymer({ |
| 10 is: 'settings-basic-page', | 10 is: 'settings-basic-page', |
| 11 | 11 |
| 12 behaviors: [SettingsPageVisibility, MainPageBehavior], | 12 behaviors: [SettingsPageVisibility, MainPageBehavior], |
| 13 | 13 |
| 14 properties: { | 14 properties: { |
| 15 /** Preferences state. */ | 15 /** Preferences state. */ |
| 16 prefs: { | 16 prefs: { |
| 17 type: Object, | 17 type: Object, |
| 18 notify: true, | 18 notify: true, |
| 19 }, | 19 }, |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * Dictionary defining page visibility. | |
| 23 * @type {!GuestModePageVisibility} | |
| 24 */ | |
| 25 pageVisibility: Object, | |
| 26 | |
| 27 advancedToggleExpanded: { | |
| 28 type: Boolean, | |
| 29 notify: true, | |
| 30 }, | |
| 31 | |
| 32 /** | |
| 33 * Whether a search operation is in progress or previous search results are | |
| 34 * being displayed. | |
| 35 */ | |
| 36 inSearchMode: { | |
| 37 type: Boolean, | |
| 38 value: false, | |
| 39 }, | |
| 40 | |
| 41 /** | |
| 42 * True if a section is fully expanded to hide other sections beneath it. | |
| 43 * 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.
| |
| 44 * @private {boolean} | |
| 45 */ | |
| 46 hasExpandedSection_: { | |
| 47 type: Boolean, | |
| 48 value: false, | |
| 49 }, | |
| 50 | |
| 51 /** | |
| 22 * True if the basic page should currently display the reset profile banner. | 52 * True if the basic page should currently display the reset profile banner. |
| 23 * @private {boolean} | 53 * @private {boolean} |
| 24 */ | 54 */ |
| 25 showResetProfileBanner_: { | 55 showResetProfileBanner_: { |
| 26 type: Boolean, | 56 type: Boolean, |
| 27 value: function() { | 57 value: function() { |
| 28 return loadTimeData.getBoolean('showResetProfileBanner'); | 58 return loadTimeData.getBoolean('showResetProfileBanner'); |
| 29 }, | 59 }, |
| 30 }, | 60 }, |
| 61 | |
| 62 /** @private {!settings.Route|undefined} */ | |
| 63 currentRoute_: Object, | |
| 64 }, | |
| 65 | |
| 66 listeners: { | |
| 67 'subpage-expand': 'onSubpageExpanded_', | |
| 68 }, | |
| 69 | |
| 70 attached: function() { | |
|
dpapad
2016/12/02 19:45:54
Nit: @override
michaelpg
2016/12/08 03:31:59
Done.
| |
| 71 this.currentRoute_ = settings.getCurrentRoute(); | |
| 72 }, | |
| 73 | |
| 74 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
| |
| 75 this.currentRoute_ = newRoute; | |
| 76 | |
| 77 if (settings.Route.ADVANCED.contains(newRoute)) | |
| 78 this.advancedToggleExpanded = true; | |
| 79 | |
| 80 // When the route changes away from a sub-page, immediately update | |
| 81 // hasExpandedSection_ to unhide the other sections. | |
| 82 if (oldRoute && !(newRoute.isSubpage() && oldRoute.isSubpage() && | |
| 83 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
| |
| 84 this.hasExpandedSection_ = false; | |
| 85 } | |
| 86 | |
| 87 MainPageBehaviorImpl.currentRouteChanged.call(this, newRoute, oldRoute); | |
| 88 }, | |
| 89 | |
| 90 /** | |
| 91 * Queues a task to search the basic sections, then another for the advanced | |
| 92 * sections. | |
| 93 * @param {string} query The text to search for. | |
| 94 * @return {!Promise<!settings.SearchRequest>} A signal indicating that | |
| 95 * searching finished. | |
| 96 */ | |
| 97 searchContents: function(query) { | |
| 98 var whenSearchDone = settings.getSearchManager().search( | |
| 99 query, assert(this.$$('#basicPage'))); | |
| 100 | |
| 101 if (this.pageVisibility.advancedSettings !== false) { | |
| 102 assert(whenSearchDone === settings.getSearchManager().search( | |
| 103 query, assert(this.$$('#advancedPage')))); | |
| 104 } | |
| 105 | |
| 106 return whenSearchDone; | |
| 31 }, | 107 }, |
| 32 | 108 |
| 33 onResetDone_: function() { | 109 onResetDone_: function() { |
|
dpapad
2016/12/02 19:45:54
@private
michaelpg
2016/12/08 03:31:59
already done by something else i think?
| |
| 34 this.showResetProfileBanner_ = false; | 110 this.showResetProfileBanner_ = false; |
| 35 }, | 111 }, |
| 112 | |
| 113 /** | |
| 114 * Hides everything but the newly expanded subpage. | |
| 115 * @private | |
| 116 */ | |
| 117 onSubpageExpanded_: function() { | |
| 118 this.hasExpandedSection_ = true; | |
| 119 }, | |
| 120 | |
| 121 /** | |
| 122 * @param {boolean} inSearchMode | |
| 123 * @param {boolean} hasExpandedSection | |
| 124 * @return {boolean} | |
| 125 * @private | |
| 126 */ | |
| 127 showAdvancedToggle_: function(inSearchMode, hasExpandedSection) { | |
| 128 return !inSearchMode && !hasExpandedSection; | |
| 129 }, | |
| 130 | |
| 131 /** | |
| 132 * @param {!settings.Route} currentRoute | |
| 133 * @param {boolean} inSearchMode | |
| 134 * @param {boolean} hasExpandedSection | |
| 135 * @return {boolean} Whether to show the basic page, taking into account | |
| 136 * both routing and search state. | |
| 137 * @private | |
| 138 */ | |
| 139 showBasicPage_: function(currentRoute, inSearchMode, hasExpandedSection) { | |
| 140 return !hasExpandedSection || settings.Route.BASIC.contains(currentRoute); | |
| 141 }, | |
| 142 | |
| 143 /** | |
| 144 * @param {!settings.Route} currentRoute | |
| 145 * @param {boolean} inSearchMode | |
| 146 * @param {boolean} hasExpandedSection | |
| 147 * @param {boolean} advancedToggleExpanded | |
| 148 * @return {boolean} Whether to show the advanced page, taking into account | |
| 149 * both routing and search state. | |
| 150 * @private | |
| 151 */ | |
| 152 showAdvancedPage_: function(currentRoute, inSearchMode, hasExpandedSection, | |
| 153 advancedToggleExpanded) { | |
| 154 if (hasExpandedSection) | |
|
dpapad
2016/12/02 19:45:54
Nit:
return hasExpandedSection ?
settings.Rout
michaelpg
2016/12/08 03:31:58
Done.
| |
| 155 return settings.Route.ADVANCED.contains(currentRoute); | |
| 156 | |
| 157 return advancedToggleExpanded || inSearchMode; | |
| 158 }, | |
| 159 | |
| 160 /** | |
| 161 * @param {(boolean|undefined)} visibility | |
| 162 * @return {boolean} True unless visibility is false. | |
| 163 * @private | |
| 164 */ | |
| 165 showAdvancedSettings_: function(visibility) { | |
| 166 return visibility !== false; | |
| 167 }, | |
| 168 | |
| 169 /** | |
| 170 * @param {boolean} opened Whether the menu is expanded. | |
| 171 * @return {string} Which icon to use. | |
| 172 * @private | |
| 173 */ | |
| 174 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.
| |
| 175 return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down'; | |
| 176 }, | |
| 36 }); | 177 }); |
| OLD | NEW |