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 | |
6 /** | |
7 * This is the absolute difference maintained between standard and | |
8 * fixed-width font sizes. http://crbug.com/91922. | |
9 * @const @private {number} | |
10 */ | |
11 var SIZE_DIFFERENCE_FIXED_STANDARD_ = 3; | |
12 | |
13 | |
5 /** | 14 /** |
6 * 'settings-appearance-page' is the settings page containing appearance | 15 * 'settings-appearance-page' is the settings page containing appearance |
7 * settings. | 16 * settings. |
8 * | 17 * |
9 * Example: | 18 * Example: |
10 * | 19 * |
11 * <iron-animated-pages> | 20 * <iron-animated-pages> |
12 * <settings-appearance-page prefs="{{prefs}}"> | 21 * <settings-appearance-page prefs="{{prefs}}"> |
13 * </settings-appearance-page> | 22 * </settings-appearance-page> |
14 * ... other pages ... | 23 * ... other pages ... |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 }, | 112 }, |
104 }, | 113 }, |
105 | 114 |
106 /** @private {?settings.AppearanceBrowserProxy} */ | 115 /** @private {?settings.AppearanceBrowserProxy} */ |
107 browserProxy_: null, | 116 browserProxy_: null, |
108 | 117 |
109 /** @private {string} */ | 118 /** @private {string} */ |
110 themeUrl_: '', | 119 themeUrl_: '', |
111 | 120 |
112 observers: [ | 121 observers: [ |
122 'onDefaultFontSizeChanged_(prefs.webkit.webprefs.default_font_size.value)', | |
michaelpg
2017/04/17 20:06:28
nit: consistency w/ other observers: defaultFontSi
dschuyler
2017/04/17 21:26:11
Done.
| |
113 'themeChanged_(prefs.extensions.theme.id.value, useSystemTheme_)', | 123 'themeChanged_(prefs.extensions.theme.id.value, useSystemTheme_)', |
114 | 124 |
115 // <if expr="is_linux and not chromeos"> | 125 // <if expr="is_linux and not chromeos"> |
dschuyler
2017/04/15 01:27:57
This indention (here and below) is done by
git cl
| |
116 // NOTE: this pref only exists on Linux. | 126 // NOTE: this pref only exists on Linux. |
117 'useSystemThemePrefChanged_(prefs.extensions.theme.use_system.value)', | 127 'useSystemThemePrefChanged_(prefs.extensions.theme.use_system.value)', |
118 // </if> | 128 // </if> |
119 ], | 129 ], |
120 | 130 |
121 created: function() { | 131 created: function() { |
122 this.browserProxy_ = settings.AppearanceBrowserProxyImpl.getInstance(); | 132 this.browserProxy_ = settings.AppearanceBrowserProxyImpl.getInstance(); |
123 }, | 133 }, |
124 | 134 |
125 ready: function() { | 135 ready: function() { |
126 this.$.defaultFontSize.menuOptions = this.fontSizeOptions_; | 136 this.$.defaultFontSize.menuOptions = this.fontSizeOptions_; |
127 // TODO(dschuyler): Look into adding a listener for the | 137 // TODO(dschuyler): Look into adding a listener for the |
128 // default zoom percent. | 138 // default zoom percent. |
(...skipping 29 matching lines...) Expand all Loading... | |
158 /** @private */ | 168 /** @private */ |
159 onCustomizeFontsTap_: function() { | 169 onCustomizeFontsTap_: function() { |
160 settings.navigateTo(settings.Route.FONTS); | 170 settings.navigateTo(settings.Route.FONTS); |
161 }, | 171 }, |
162 | 172 |
163 /** @private */ | 173 /** @private */ |
164 onDisableExtension_: function() { | 174 onDisableExtension_: function() { |
165 this.fire('refresh-pref', 'homepage'); | 175 this.fire('refresh-pref', 'homepage'); |
166 }, | 176 }, |
167 | 177 |
178 /** | |
179 * @param {number} value The changed font size slider value. | |
180 * @private | |
181 */ | |
182 onDefaultFontSizeChanged_: function(value) { | |
183 // This is unusual but there is a pref that is dependent upon another. | |
michaelpg
2017/04/17 20:06:28
as a *minor* nit, could you try to condense this c
dschuyler
2017/04/17 21:26:11
Done.
| |
184 // Whenever the |default_font_size| is changed, this will update the | |
185 // |default_fixed_font_size| as well. They can (and are) handled separately | |
186 // in extensions. In the built-in settings (here), they are tied together to | |
187 // simplify the UI. | |
188 this.set( | |
189 'prefs.webkit.webprefs.default_fixed_font_size.value', | |
190 value - SIZE_DIFFERENCE_FIXED_STANDARD_); | |
191 }, | |
192 | |
168 /** @private */ | 193 /** @private */ |
169 onThemesTap_: function() { | 194 onThemesTap_: function() { |
170 window.open(this.themeUrl_ || loadTimeData.getString('themesGalleryUrl')); | 195 window.open(this.themeUrl_ || loadTimeData.getString('themesGalleryUrl')); |
171 }, | 196 }, |
172 | 197 |
173 // <if expr="chromeos"> | 198 // <if expr="chromeos"> |
174 /** | 199 /** |
175 * ChromeOS only. | 200 * ChromeOS only. |
176 * @private | 201 * @private |
177 */ | 202 */ |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 | 268 |
244 this.browserProxy_.getThemeInfo(themeId).then(function(info) { | 269 this.browserProxy_.getThemeInfo(themeId).then(function(info) { |
245 this.themeSublabel_ = info.name; | 270 this.themeSublabel_ = info.name; |
246 }.bind(this)); | 271 }.bind(this)); |
247 | 272 |
248 this.themeUrl_ = 'https://chrome.google.com/webstore/detail/' + themeId; | 273 this.themeUrl_ = 'https://chrome.google.com/webstore/detail/' + themeId; |
249 return; | 274 return; |
250 } | 275 } |
251 | 276 |
252 var i18nId; | 277 var i18nId; |
253 // <if expr="is_linux and not chromeos"> | 278 // <if expr="is_linux and not chromeos"> |
254 i18nId = useSystemTheme ? 'systemTheme' : 'classicTheme'; | 279 i18nId = useSystemTheme ? 'systemTheme' : 'classicTheme'; |
255 // </if> | 280 // </if> |
256 // <if expr="not is_linux or chromeos"> | 281 // <if expr="not is_linux or chromeos"> |
257 i18nId = 'chooseFromWebStore'; | 282 i18nId = 'chooseFromWebStore'; |
258 // </if> | 283 // </if> |
259 this.themeSublabel_ = this.i18n(i18nId); | 284 this.themeSublabel_ = this.i18n(i18nId); |
260 this.themeUrl_ = ''; | 285 this.themeUrl_ = ''; |
261 }, | 286 }, |
262 | 287 |
263 /** @private */ | 288 /** @private */ |
264 onZoomLevelChange_: function() { | 289 onZoomLevelChange_: function() { |
265 chrome.settingsPrivate.setDefaultZoom(parseFloat(this.$.zoomLevel.value)); | 290 chrome.settingsPrivate.setDefaultZoom(parseFloat(this.$.zoomLevel.value)); |
266 }, | 291 }, |
267 | 292 |
268 /** | 293 /** |
269 * @param {boolean} bookmarksBarVisible if bookmarks bar option is visible. | 294 * @param {boolean} bookmarksBarVisible if bookmarks bar option is visible. |
270 * @return {string} 'first' if the argument is false or empty otherwise. | 295 * @return {string} 'first' if the argument is false or empty otherwise. |
271 * @private | 296 * @private |
272 */ | 297 */ |
273 getFirst_: function(bookmarksBarVisible) { | 298 getFirst_: function(bookmarksBarVisible) { |
274 return !bookmarksBarVisible ? 'first' : ''; | 299 return !bookmarksBarVisible ? 'first' : ''; |
275 }, | 300 }, |
276 | 301 |
277 /** | 302 /** |
278 * @see content::ZoomValuesEqual(). | 303 * @see content::ZoomValuesEqual(). |
279 * @param {number} zoom1 | 304 * @param {number} zoom1 |
280 * @param {number} zoom2 | 305 * @param {number} zoom2 |
281 * @return {boolean} | 306 * @return {boolean} |
282 * @private | 307 * @private |
283 */ | 308 */ |
284 zoomValuesEqual_: function(zoom1, zoom2) { | 309 zoomValuesEqual_: function(zoom1, zoom2) { |
285 return Math.abs(zoom1 - zoom2) <= 0.001; | 310 return Math.abs(zoom1 - zoom2) <= 0.001; |
286 }, | 311 }, |
287 }); | 312 }); |
OLD | NEW |