| 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-ui' implements the UI for the Settings page. | 7 * 'settings-ui' implements the UI for the Settings page. |
| 8 * | 8 * |
| 9 * Example: | 9 * Example: |
| 10 * | 10 * |
| 11 * <settings-ui prefs="{{prefs}}"></settings-ui> | 11 * <settings-ui prefs="{{prefs}}"></settings-ui> |
| 12 */ | 12 */ |
| 13 cr.exportPath('settings'); | 13 cr.exportPath('settings'); |
| 14 assert(!settings.defaultResourceLoaded, | 14 assert( |
| 15 'settings_ui.js run twice. You probably have an invalid import.'); | 15 !settings.defaultResourceLoaded, |
| 16 'settings_ui.js run twice. You probably have an invalid import.'); |
| 16 /** Global defined when the main Settings script runs. */ | 17 /** Global defined when the main Settings script runs. */ |
| 17 settings.defaultResourceLoaded = true; | 18 settings.defaultResourceLoaded = true; |
| 18 | 19 |
| 19 Polymer({ | 20 Polymer({ |
| 20 is: 'settings-ui', | 21 is: 'settings-ui', |
| 21 | 22 |
| 22 behaviors: [settings.RouteObserverBehavior], | 23 behaviors: [settings.RouteObserverBehavior], |
| 23 | 24 |
| 24 properties: { | 25 properties: { |
| 25 /** | 26 /** |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 86 |
| 86 window.addEventListener('popstate', function(e) { | 87 window.addEventListener('popstate', function(e) { |
| 87 this.$.drawer.closeDrawer(); | 88 this.$.drawer.closeDrawer(); |
| 88 }.bind(this)); | 89 }.bind(this)); |
| 89 | 90 |
| 90 if (loadTimeData.getBoolean('isGuest')) { | 91 if (loadTimeData.getBoolean('isGuest')) { |
| 91 this.pageVisibility_ = { | 92 this.pageVisibility_ = { |
| 92 people: false, | 93 people: false, |
| 93 onStartup: false, | 94 onStartup: false, |
| 94 reset: false, | 95 reset: false, |
| 95 <if expr="not chromeos"> | 96 /* <if expr="not chromeos"> */ |
| 96 appearance: false, | 97 appearance: false, |
| 97 defaultBrowser: false, | 98 defaultBrowser: false, |
| 98 advancedSettings: false, | 99 advancedSettings: false, |
| 99 </if> | 100 /* </if> */ |
| 100 <if expr="chromeos"> | 101 /* <if expr="chromeos"> */ |
| 101 appearance: { | 102 appearance: { |
| 102 setWallpaper: false, | 103 setWallpaper: false, |
| 103 setTheme: false, | 104 setTheme: false, |
| 104 homeButton: false, | 105 homeButton: false, |
| 105 bookmarksBar: false, | 106 bookmarksBar: false, |
| 106 pageZoom: false, | 107 pageZoom: false, |
| 107 }, | 108 }, |
| 108 advancedSettings: true, | 109 advancedSettings: true, |
| 109 privacy: { | 110 privacy: { |
| 110 searchPrediction: false, | 111 searchPrediction: false, |
| 111 networkPrediction: false, | 112 networkPrediction: false, |
| 112 }, | 113 }, |
| 113 passwordsAndForms: false, | 114 passwordsAndForms: false, |
| 114 downloads: { | 115 downloads: { |
| 115 googleDrive: false, | 116 googleDrive: false, |
| 116 }, | 117 }, |
| 117 </if> | 118 /* </if> */ |
| 118 }; | 119 }; |
| 119 } | 120 } |
| 120 | 121 |
| 121 this.showAndroidApps_ = loadTimeData.valueExists('androidAppsAllowed') && | 122 this.showAndroidApps_ = loadTimeData.valueExists('androidAppsAllowed') && |
| 122 loadTimeData.getBoolean('androidAppsAllowed'); | 123 loadTimeData.getBoolean('androidAppsAllowed'); |
| 123 }, | 124 }, |
| 124 | 125 |
| 125 /** @override */ | 126 /** @override */ |
| 126 attached: function() { | 127 attached: function() { |
| 127 // Preload bold Roboto so it doesn't load and flicker the first time used. | 128 // Preload bold Roboto so it doesn't load and flicker the first time used. |
| 128 document.fonts.load('bold 12px Roboto'); | 129 document.fonts.load('bold 12px Roboto'); |
| 129 settings.setGlobalScrollTarget(this.$.headerPanel.scroller); | 130 settings.setGlobalScrollTarget(this.$.headerPanel.scroller); |
| 130 }, | 131 }, |
| 131 | 132 |
| 132 /** @param {!settings.Route} route */ | 133 /** @param {!settings.Route} route */ |
| 133 currentRouteChanged: function(route) { | 134 currentRouteChanged: function(route) { |
| 134 var urlSearchQuery = settings.getQueryParameters().get('search') || ''; | 135 var urlSearchQuery = settings.getQueryParameters().get('search') || ''; |
| 135 if (urlSearchQuery == this.lastSearchQuery_) | 136 if (urlSearchQuery == this.lastSearchQuery_) |
| 136 return; | 137 return; |
| 137 | 138 |
| 138 this.lastSearchQuery_ = urlSearchQuery; | 139 this.lastSearchQuery_ = urlSearchQuery; |
| 139 | 140 |
| 140 var toolbar = /** @type {!CrToolbarElement} */ (this.$$('cr-toolbar')); | 141 var toolbar = /** @type {!CrToolbarElement} */ (this.$$('cr-toolbar')); |
| 141 var searchField = /** @type {CrToolbarSearchFieldElement} */ ( | 142 var searchField = |
| 142 toolbar.getSearchField()); | 143 /** @type {CrToolbarSearchFieldElement} */ (toolbar.getSearchField()); |
| 143 | 144 |
| 144 // If the search was initiated by directly entering a search URL, need to | 145 // If the search was initiated by directly entering a search URL, need to |
| 145 // sync the URL parameter to the textbox. | 146 // sync the URL parameter to the textbox. |
| 146 if (urlSearchQuery != searchField.getValue()) { | 147 if (urlSearchQuery != searchField.getValue()) { |
| 147 // Setting the search box value without triggering a 'search-changed' | 148 // Setting the search box value without triggering a 'search-changed' |
| 148 // event, to prevent an unnecessary duplicate entry in |window.history|. | 149 // event, to prevent an unnecessary duplicate entry in |window.history|. |
| 149 searchField.setValue(urlSearchQuery, true /* noEvent */); | 150 searchField.setValue(urlSearchQuery, true /* noEvent */); |
| 150 } | 151 } |
| 151 | 152 |
| 152 this.$.main.searchContents(urlSearchQuery); | 153 this.$.main.searchContents(urlSearchQuery); |
| 153 }, | 154 }, |
| 154 | 155 |
| 155 /** | 156 /** |
| 156 * @param {!CustomEvent} e | 157 * @param {!CustomEvent} e |
| 157 * @private | 158 * @private |
| 158 */ | 159 */ |
| 159 onRefreshPref_: function(e) { | 160 onRefreshPref_: function(e) { |
| 160 var prefName = /** @type {string} */(e.detail); | 161 var prefName = /** @type {string} */ (e.detail); |
| 161 return /** @type {SettingsPrefsElement} */(this.$.prefs).refresh(prefName); | 162 return /** @type {SettingsPrefsElement} */ (this.$.prefs).refresh(prefName); |
| 162 }, | 163 }, |
| 163 | 164 |
| 164 /** | 165 /** |
| 165 * Handles the 'search-changed' event fired from the toolbar. | 166 * Handles the 'search-changed' event fired from the toolbar. |
| 166 * @param {!Event} e | 167 * @param {!Event} e |
| 167 * @private | 168 * @private |
| 168 */ | 169 */ |
| 169 onSearchChanged_: function(e) { | 170 onSearchChanged_: function(e) { |
| 170 // Trim leading whitespace only, to prevent searching for empty string. This | 171 // Trim leading whitespace only, to prevent searching for empty string. This |
| 171 // still allows the user to search for 'foo bar', while taking a long pause | 172 // still allows the user to search for 'foo bar', while taking a long pause |
| (...skipping 18 matching lines...) Expand all Loading... |
| 190 this.$.drawer.closeDrawer(); | 191 this.$.drawer.closeDrawer(); |
| 191 }, | 192 }, |
| 192 | 193 |
| 193 /** @private */ | 194 /** @private */ |
| 194 onMenuButtonTap_: function() { | 195 onMenuButtonTap_: function() { |
| 195 this.$.drawer.toggle(); | 196 this.$.drawer.toggle(); |
| 196 }, | 197 }, |
| 197 | 198 |
| 198 /** @private */ | 199 /** @private */ |
| 199 directionDelegateChanged_: function() { | 200 directionDelegateChanged_: function() { |
| 200 this.$.drawer.align = this.directionDelegate.isRtl() ? | 201 this.$.drawer.align = this.directionDelegate.isRtl() ? 'right' : 'left'; |
| 201 'right' : 'left'; | |
| 202 }, | 202 }, |
| 203 }); | 203 }); |
| OLD | NEW |