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-main' displays the selected settings page. | 7 * 'settings-main' displays the selected settings page. |
8 */ | 8 */ |
9 Polymer({ | 9 Polymer({ |
10 is: 'settings-main', | 10 is: 'settings-main', |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 value: function() { | 47 value: function() { |
48 return {about: false, basic: false, advanced: false}; | 48 return {about: false, basic: false, advanced: false}; |
49 }, | 49 }, |
50 }, | 50 }, |
51 | 51 |
52 toolbarSpinnerActive: { | 52 toolbarSpinnerActive: { |
53 type: Boolean, | 53 type: Boolean, |
54 value: false, | 54 value: false, |
55 notify: true, | 55 notify: true, |
56 }, | 56 }, |
| 57 |
| 58 /** |
| 59 * Dictionary defining page visibility. |
| 60 * @type {!GuestModePageVisibility} |
| 61 */ |
| 62 pageVisibility: { |
| 63 type: Object, |
| 64 value: function() { return {}; }, |
| 65 }, |
57 }, | 66 }, |
58 | 67 |
59 /** @override */ | 68 /** @override */ |
60 created: function() { | 69 created: function() { |
61 /** @private {!PromiseResolver} */ | 70 /** @private {!PromiseResolver} */ |
62 this.resolver_ = new PromiseResolver; | 71 this.resolver_ = new PromiseResolver; |
63 settings.main.rendered = this.resolver_.promise; | 72 settings.main.rendered = this.resolver_.promise; |
64 }, | 73 }, |
65 | 74 |
66 /** @override */ | 75 /** @override */ |
(...skipping 30 matching lines...) Expand all Loading... |
97 * @private | 106 * @private |
98 */ | 107 */ |
99 arrowState_: function(opened) { | 108 arrowState_: function(opened) { |
100 return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down'; | 109 return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down'; |
101 }, | 110 }, |
102 | 111 |
103 /** | 112 /** |
104 * @param {boolean} showBasicPage | 113 * @param {boolean} showBasicPage |
105 * @param {boolean} inSubpage | 114 * @param {boolean} inSubpage |
106 * @return {boolean} | 115 * @return {boolean} |
| 116 * @private |
107 */ | 117 */ |
108 showAdvancedToggle_: function(showBasicPage, inSubpage) { | 118 showAdvancedToggle_: function(showBasicPage, inSubpage) { |
109 return showBasicPage && !inSubpage; | 119 return showBasicPage && !inSubpage; |
110 }, | 120 }, |
111 | 121 |
112 /** | 122 /** |
113 * @param {!SettingsRoute} newRoute | 123 * @param {!SettingsRoute} newRoute |
114 * @private | 124 * @private |
115 */ | 125 */ |
116 currentRouteChanged_: function(newRoute) { | 126 currentRouteChanged_: function(newRoute) { |
117 this.inSubpage_ = newRoute.subpage.length > 0; | 127 this.inSubpage_ = newRoute.subpage.length > 0; |
118 this.style.height = this.inSubpage_ ? '100%' : ''; | 128 this.style.height = this.inSubpage_ ? '100%' : ''; |
119 | 129 |
120 if (newRoute.page == 'about') { | 130 if (newRoute.page == 'about') { |
121 this.showPages_ = {about: true, basic: false, advanced: false}; | 131 this.showPages_ = {about: true, basic: false, advanced: false}; |
122 } else { | 132 } else { |
| 133 |
| 134 if (newRoute.page == 'advanced') { |
| 135 assert(!this.pageVisibility || |
| 136 this.pageVisibility.advancedSettings !== false); |
| 137 } |
| 138 |
123 this.showPages_ = { | 139 this.showPages_ = { |
124 about: false, | 140 about: false, |
125 basic: newRoute.page == 'basic' || !this.inSubpage_, | 141 basic: newRoute.page == 'basic' || !this.inSubpage_, |
126 advanced: newRoute.page == 'advanced' || | 142 advanced: newRoute.page == 'advanced' || |
127 (!this.inSubpage_ && this.advancedToggleExpanded_), | 143 (!this.inSubpage_ && this.advancedToggleExpanded_), |
128 }; | 144 }; |
129 | 145 |
130 if (this.showPages_.advanced) | 146 if (this.showPages_.advanced) |
131 this.advancedToggleExpanded_ = true; | 147 this.advancedToggleExpanded_ = true; |
132 } | 148 } |
(...skipping 28 matching lines...) Expand all Loading... |
161 this.showPages_ = {about: false, basic: true, advanced: true}; | 177 this.showPages_ = {about: false, basic: true, advanced: true}; |
162 setTimeout(function() { | 178 setTimeout(function() { |
163 settings.getSearchManager().search( | 179 settings.getSearchManager().search( |
164 query, assert(this.$$('settings-basic-page'))); | 180 query, assert(this.$$('settings-basic-page'))); |
165 }.bind(this), 0); | 181 }.bind(this), 0); |
166 setTimeout(function() { | 182 setTimeout(function() { |
167 settings.getSearchManager().search( | 183 settings.getSearchManager().search( |
168 query, assert(this.$$('settings-advanced-page'))); | 184 query, assert(this.$$('settings-advanced-page'))); |
169 }.bind(this), 0); | 185 }.bind(this), 0); |
170 }, | 186 }, |
| 187 |
| 188 /** |
| 189 * @param {(boolean|undefined)} visibility |
| 190 * @return {boolean} True unless visibility is false. |
| 191 * @private |
| 192 */ |
| 193 showAdvancedSettings_: function(visibility) { |
| 194 return visibility !== false; |
| 195 }, |
171 }); | 196 }); |
OLD | NEW |