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 'defaultFontSizeChanged_(prefs.webkit.webprefs.default_font_size.value)', |
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"> |
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 defaultFontSizeChanged_: function(value) { |
| 183 // This pref is handled separately in some extensions, but here it is tied |
| 184 // to default_font_size (to simplify the UI). |
| 185 this.set( |
| 186 'prefs.webkit.webprefs.default_fixed_font_size.value', |
| 187 value - SIZE_DIFFERENCE_FIXED_STANDARD_); |
| 188 }, |
| 189 |
168 /** @private */ | 190 /** @private */ |
169 onThemesTap_: function() { | 191 onThemesTap_: function() { |
170 window.open(this.themeUrl_ || loadTimeData.getString('themesGalleryUrl')); | 192 window.open(this.themeUrl_ || loadTimeData.getString('themesGalleryUrl')); |
171 }, | 193 }, |
172 | 194 |
173 // <if expr="chromeos"> | 195 // <if expr="chromeos"> |
174 /** | 196 /** |
175 * ChromeOS only. | 197 * ChromeOS only. |
176 * @private | 198 * @private |
177 */ | 199 */ |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 | 265 |
244 this.browserProxy_.getThemeInfo(themeId).then(function(info) { | 266 this.browserProxy_.getThemeInfo(themeId).then(function(info) { |
245 this.themeSublabel_ = info.name; | 267 this.themeSublabel_ = info.name; |
246 }.bind(this)); | 268 }.bind(this)); |
247 | 269 |
248 this.themeUrl_ = 'https://chrome.google.com/webstore/detail/' + themeId; | 270 this.themeUrl_ = 'https://chrome.google.com/webstore/detail/' + themeId; |
249 return; | 271 return; |
250 } | 272 } |
251 | 273 |
252 var i18nId; | 274 var i18nId; |
253 // <if expr="is_linux and not chromeos"> | 275 // <if expr="is_linux and not chromeos"> |
254 i18nId = useSystemTheme ? 'systemTheme' : 'classicTheme'; | 276 i18nId = useSystemTheme ? 'systemTheme' : 'classicTheme'; |
255 // </if> | 277 // </if> |
256 // <if expr="not is_linux or chromeos"> | 278 // <if expr="not is_linux or chromeos"> |
257 i18nId = 'chooseFromWebStore'; | 279 i18nId = 'chooseFromWebStore'; |
258 // </if> | 280 // </if> |
259 this.themeSublabel_ = this.i18n(i18nId); | 281 this.themeSublabel_ = this.i18n(i18nId); |
260 this.themeUrl_ = ''; | 282 this.themeUrl_ = ''; |
261 }, | 283 }, |
262 | 284 |
263 /** @private */ | 285 /** @private */ |
264 onZoomLevelChange_: function() { | 286 onZoomLevelChange_: function() { |
265 chrome.settingsPrivate.setDefaultZoom(parseFloat(this.$.zoomLevel.value)); | 287 chrome.settingsPrivate.setDefaultZoom(parseFloat(this.$.zoomLevel.value)); |
266 }, | 288 }, |
267 | 289 |
268 /** | 290 /** |
269 * @param {boolean} bookmarksBarVisible if bookmarks bar option is visible. | 291 * @param {boolean} bookmarksBarVisible if bookmarks bar option is visible. |
270 * @return {string} 'first' if the argument is false or empty otherwise. | 292 * @return {string} 'first' if the argument is false or empty otherwise. |
271 * @private | 293 * @private |
272 */ | 294 */ |
273 getFirst_: function(bookmarksBarVisible) { | 295 getFirst_: function(bookmarksBarVisible) { |
274 return !bookmarksBarVisible ? 'first' : ''; | 296 return !bookmarksBarVisible ? 'first' : ''; |
275 }, | 297 }, |
276 | 298 |
277 /** | 299 /** |
278 * @see content::ZoomValuesEqual(). | 300 * @see content::ZoomValuesEqual(). |
279 * @param {number} zoom1 | 301 * @param {number} zoom1 |
280 * @param {number} zoom2 | 302 * @param {number} zoom2 |
281 * @return {boolean} | 303 * @return {boolean} |
282 * @private | 304 * @private |
283 */ | 305 */ |
284 zoomValuesEqual_: function(zoom1, zoom2) { | 306 zoomValuesEqual_: function(zoom1, zoom2) { |
285 return Math.abs(zoom1 - zoom2) <= 0.001; | 307 return Math.abs(zoom1 - zoom2) <= 0.001; |
286 }, | 308 }, |
287 }); | 309 }); |
OLD | NEW |