Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: chrome/browser/resources/settings/appearance_page/appearance_page.js

Issue 2766093002: MD Settings: validate home button url input (Closed)
Patch Set: fixes based on comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 * 'settings-appearance-page' is the settings page containing appearance 6 * 'settings-appearance-page' is the settings page containing appearance
7 * settings. 7 * settings.
8 * 8 *
9 * Example: 9 * Example:
10 * 10 *
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 return [ 45 return [
46 {value: 9, name: loadTimeData.getString('verySmall')}, 46 {value: 9, name: loadTimeData.getString('verySmall')},
47 {value: 12, name: loadTimeData.getString('small')}, 47 {value: 12, name: loadTimeData.getString('small')},
48 {value: 16, name: loadTimeData.getString('medium')}, 48 {value: 16, name: loadTimeData.getString('medium')},
49 {value: 20, name: loadTimeData.getString('large')}, 49 {value: 20, name: loadTimeData.getString('large')},
50 {value: 24, name: loadTimeData.getString('veryLarge')}, 50 {value: 24, name: loadTimeData.getString('veryLarge')},
51 ]; 51 ];
52 }, 52 },
53 }, 53 },
54 54
55 /** @private */
56 isHomeUrlInvalid_: Boolean,
57
55 /** 58 /**
56 * List of options for the page zoom drop-down menu. 59 * List of options for the page zoom drop-down menu.
57 * @type {!Array<number>} 60 * @type {!Array<number>}
58 */ 61 */
59 pageZoomLevels_: { 62 pageZoomLevels_: {
60 readOnly: true, 63 readOnly: true,
61 type: Array, 64 type: Array,
62 value: [ 65 value: [
63 // TODO(dbeam): get these dynamically from C++ instead. 66 // TODO(dbeam): get these dynamically from C++ instead.
64 1 / 4, 67 1 / 4,
(...skipping 28 matching lines...) Expand all
93 96
94 /** @private {?settings.AppearanceBrowserProxy} */ 97 /** @private {?settings.AppearanceBrowserProxy} */
95 browserProxy_: null, 98 browserProxy_: null,
96 99
97 /** @private {string} */ 100 /** @private {string} */
98 themeUrl_: '', 101 themeUrl_: '',
99 102
100 observers: [ 103 observers: [
101 'themeChanged_(prefs.extensions.theme.id.value, useSystemTheme_)', 104 'themeChanged_(prefs.extensions.theme.id.value, useSystemTheme_)',
102 105
103 // <if expr="is_linux and not chromeos"> 106 // <if expr="is_linux and not chromeos">
dpapad 2017/03/24 23:48:53 Let's undo those too (throughout this file).
scottchen 2017/03/24 23:54:04 Done.
104 // NOTE: this pref only exists on Linux. 107 // NOTE: this pref only exists on Linux.
105 'useSystemThemePrefChanged_(prefs.extensions.theme.use_system.value)', 108 'useSystemThemePrefChanged_(prefs.extensions.theme.use_system.value)',
106 // </if> 109 // </if>
107 ], 110 ],
108 111
109 created: function() { 112 created: function() {
110 this.browserProxy_ = settings.AppearanceBrowserProxyImpl.getInstance(); 113 this.browserProxy_ = settings.AppearanceBrowserProxyImpl.getInstance();
111 }, 114 },
112 115
113 ready: function() { 116 ready: function() {
114 this.$.defaultFontSize.menuOptions = this.fontSizeOptions_; 117 this.$.defaultFontSize.menuOptions = this.fontSizeOptions_;
115 // TODO(dschuyler): Look into adding a listener for the 118 // TODO(dschuyler): Look into adding a listener for the
116 // default zoom percent. 119 // default zoom percent.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 /** @private */ 154 /** @private */
152 onDisableExtension_: function() { 155 onDisableExtension_: function() {
153 this.fire('refresh-pref', 'homepage'); 156 this.fire('refresh-pref', 'homepage');
154 }, 157 },
155 158
156 /** @private */ 159 /** @private */
157 onThemesTap_: function() { 160 onThemesTap_: function() {
158 window.open(this.themeUrl_ || loadTimeData.getString('themesGalleryUrl')); 161 window.open(this.themeUrl_ || loadTimeData.getString('themesGalleryUrl'));
159 }, 162 },
160 163
161 // <if expr="chromeos"> 164 // <if expr="chromeos">
162 /** 165 /**
163 * ChromeOS only. 166 * ChromeOS only.
164 * @private 167 * @private
165 */ 168 */
166 openWallpaperManager_: function() { 169 openWallpaperManager_: function() {
167 this.browserProxy_.openWallpaperManager(); 170 this.browserProxy_.openWallpaperManager();
168 }, 171 },
169 // </if> 172 // </if>
170 173
171 /** @private */ 174 /** @private */
172 onUseDefaultTap_: function() { 175 onUseDefaultTap_: function() {
173 this.browserProxy_.useDefaultTheme(); 176 this.browserProxy_.useDefaultTheme();
174 }, 177 },
175 178
176 // <if expr="is_linux and not chromeos"> 179 // <if expr="is_linux and not chromeos">
177 /** 180 /**
178 * @param {boolean} useSystemTheme 181 * @param {boolean} useSystemTheme
179 * @private 182 * @private
180 */ 183 */
181 useSystemThemePrefChanged_: function(useSystemTheme) { 184 useSystemThemePrefChanged_: function(useSystemTheme) {
182 this.useSystemTheme_ = useSystemTheme; 185 this.useSystemTheme_ = useSystemTheme;
183 }, 186 },
184 187
185 /** 188 /**
186 * @param {string} themeId 189 * @param {string} themeId
(...skipping 24 matching lines...) Expand all
211 */ 214 */
212 showThemesSecondary_: function(themeId, useSystemTheme) { 215 showThemesSecondary_: function(themeId, useSystemTheme) {
213 return this.showUseClassic_(themeId, useSystemTheme) || 216 return this.showUseClassic_(themeId, useSystemTheme) ||
214 this.showUseSystem_(themeId, useSystemTheme); 217 this.showUseSystem_(themeId, useSystemTheme);
215 }, 218 },
216 219
217 /** @private */ 220 /** @private */
218 onUseSystemTap_: function() { 221 onUseSystemTap_: function() {
219 this.browserProxy_.useSystemTheme(); 222 this.browserProxy_.useSystemTheme();
220 }, 223 },
221 // </if> 224 // </if>
222 225
223 /** 226 /**
224 * @param {string} themeId 227 * @param {string} themeId
225 * @param {boolean} useSystemTheme 228 * @param {boolean} useSystemTheme
226 * @private 229 * @private
227 */ 230 */
228 themeChanged_: function(themeId, useSystemTheme) { 231 themeChanged_: function(themeId, useSystemTheme) {
229 if (themeId) { 232 if (themeId) {
230 assert(!useSystemTheme); 233 assert(!useSystemTheme);
231 234
232 this.browserProxy_.getThemeInfo(themeId).then(function(info) { 235 this.browserProxy_.getThemeInfo(themeId).then(function(info) {
233 this.themeSublabel_ = info.name; 236 this.themeSublabel_ = info.name;
234 }.bind(this)); 237 }.bind(this));
235 238
236 this.themeUrl_ = 'https://chrome.google.com/webstore/detail/' + themeId; 239 this.themeUrl_ = 'https://chrome.google.com/webstore/detail/' + themeId;
237 return; 240 return;
238 } 241 }
239 242
240 var i18nId; 243 var i18nId;
241 // <if expr="is_linux and not chromeos"> 244 // <if expr="is_linux and not chromeos">
242 i18nId = useSystemTheme ? 'systemTheme' : 'classicTheme'; 245 i18nId = useSystemTheme ? 'systemTheme' : 'classicTheme';
243 // </if> 246 // </if>
244 // <if expr="not is_linux or chromeos"> 247 // <if expr="not is_linux or chromeos">
245 i18nId = 'chooseFromWebStore'; 248 i18nId = 'chooseFromWebStore';
246 // </if> 249 // </if>
247 this.themeSublabel_ = this.i18n(i18nId); 250 this.themeSublabel_ = this.i18n(i18nId);
248 this.themeUrl_ = ''; 251 this.themeUrl_ = '';
249 }, 252 },
250 253
251 /** @private */ 254 /** @private */
252 onZoomLevelChange_: function() { 255 onZoomLevelChange_: function() {
253 chrome.settingsPrivate.setDefaultZoom(parseFloat(this.$.zoomLevel.value)); 256 chrome.settingsPrivate.setDefaultZoom(parseFloat(this.$.zoomLevel.value));
254 }, 257 },
255 258
256 /** 259 /**
257 * @param {boolean} bookmarksBarVisible if bookmarks bar option is visible. 260 * @param {boolean} bookmarksBarVisible if bookmarks bar option is visible.
258 * @return {string} 'first' if the argument is false or empty otherwise. 261 * @return {string} 'first' if the argument is false or empty otherwise.
259 * @private 262 * @private
260 */ 263 */
261 getFirst_: function(bookmarksBarVisible) { 264 getFirst_: function(bookmarksBarVisible) {
262 return !bookmarksBarVisible ? 'first' : ''; 265 return !bookmarksBarVisible ? 'first' : '';
263 }, 266 },
264 267
265 /** 268 /**
266 * @see content::ZoomValuesEqual(). 269 * @see content::ZoomValuesEqual().
267 * @param {number} zoom1 270 * @param {number} zoom1
268 * @param {number} zoom2 271 * @param {number} zoom2
269 * @return {boolean} 272 * @return {boolean}
270 * @private 273 * @private
271 */ 274 */
272 zoomValuesEqual_: function(zoom1, zoom2) { 275 zoomValuesEqual_: function(zoom1, zoom2) {
273 return Math.abs(zoom1 - zoom2) <= 0.001; 276 return Math.abs(zoom1 - zoom2) <= 0.001;
274 }, 277 },
278
279 /**
280 * @param {!Event} event
281 * @private
282 */
283 validate_: function(event) {
284 var inputElement = Polymer.dom(event).localTarget;
285
286 if (inputElement.value == '') {
287 this.isHomeUrlInvalid_ = false;
288 return;
289 }
290
291 this.browserProxy_.validateStartupPage(inputElement.value)
292 .then(function(isValid) {
293 this.isHomeUrlInvalid_ = !isValid;
294 }.bind(this));
295 },
275 }); 296 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698