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

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

Issue 2488113002: MD Settings: [further] robustify default zoom level handling (Closed)
Patch Set: . Created 4 years, 1 month 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
« no previous file with comments | « chrome/browser/resources/settings/appearance_page/appearance_page.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 *
11 * <iron-animated-pages> 11 * <iron-animated-pages>
12 * <settings-appearance-page prefs="{{prefs}}"> 12 * <settings-appearance-page prefs="{{prefs}}">
13 * </settings-appearance-page> 13 * </settings-appearance-page>
14 * ... other pages ... 14 * ... other pages ...
15 * </iron-animated-pages> 15 * </iron-animated-pages>
16 */ 16 */
17 Polymer({ 17 Polymer({
18 is: 'settings-appearance-page', 18 is: 'settings-appearance-page',
19 19
20 behaviors: [I18nBehavior], 20 behaviors: [I18nBehavior],
21 21
22 properties: { 22 properties: {
23 /** @private {!settings.AppearanceBrowserProxy} */ 23 /**
24 browserProxy_: Object, 24 * Dictionary defining page visibility.
25 * @type {!AppearancePageVisibility}
26 */
27 pageVisibility: Object,
25 28
26 prefs: { 29 prefs: {
27 type: Object, 30 type: Object,
28 notify: true, 31 notify: true,
29 }, 32 },
30 33
34 /** @private {!settings.AppearanceBrowserProxy} */
35 browserProxy_: Object,
dpapad 2016/11/10 02:20:49 Nit: I recall that we are OK not putting browserPr
Dan Beam 2016/11/10 02:25:29 done in next patch
36
31 /** @private */ 37 /** @private */
32 useSystemTheme_: { 38 defaultZoom_: Number,
33 type: Boolean,
34 value: false, // Can only be true on Linux, but value exists everywhere.
35 },
36 39
37 /** 40 /**
38 * List of options for the font size drop-down menu. 41 * List of options for the font size drop-down menu.
39 * @type {!DropdownMenuOptionList} 42 * @type {!DropdownMenuOptionList}
40 */ 43 */
41 fontSizeOptions_: { 44 fontSizeOptions_: {
42 readOnly: true, 45 readOnly: true,
43 type: Array, 46 type: Array,
44 value: function() { 47 value: function() {
45 return [ 48 return [
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 5 / 2, 80 5 / 2,
78 3, 81 3,
79 4, 82 4,
80 5, 83 5,
81 ], 84 ],
82 }, 85 },
83 86
84 /** @private */ 87 /** @private */
85 themeSublabel_: String, 88 themeSublabel_: String,
86 89
87 /** 90 /** @private */
88 * Dictionary defining page visibility. 91 useSystemTheme_: {
89 * @type {!AppearancePageVisibility} 92 type: Boolean,
90 */ 93 value: false, // Can only be true on Linux, but value exists everywhere.
91 pageVisibility: Object, 94 },
92 }, 95 },
93 96
94 /** @private {string} */ 97 /** @private {string} */
95 themeUrl_: '', 98 themeUrl_: '',
96 99
97 observers: [ 100 observers: [
98 'themeChanged_(prefs.extensions.theme.id.value, useSystemTheme_)', 101 'themeChanged_(prefs.extensions.theme.id.value, useSystemTheme_)',
99 102
100 <if expr="is_linux and not chromeos"> 103 <if expr="is_linux and not chromeos">
101 // NOTE: this pref only exists on Linux. 104 // NOTE: this pref only exists on Linux.
102 'useSystemThemePrefChanged_(prefs.extensions.theme.use_system.value)', 105 'useSystemThemePrefChanged_(prefs.extensions.theme.use_system.value)',
103 </if> 106 </if>
104 ], 107 ],
105 108
106 created: function() { 109 created: function() {
107 this.browserProxy_ = settings.AppearanceBrowserProxyImpl.getInstance(); 110 this.browserProxy_ = settings.AppearanceBrowserProxyImpl.getInstance();
108 }, 111 },
109 112
110 ready: function() { 113 ready: function() {
111 this.$.defaultFontSize.menuOptions = this.fontSizeOptions_; 114 this.$.defaultFontSize.menuOptions = this.fontSizeOptions_;
112 // TODO(dschuyler): Look into adding a listener for the 115 // TODO(dschuyler): Look into adding a listener for the
113 // default zoom percent. 116 // default zoom percent.
114 chrome.settingsPrivate.getDefaultZoom(function(zoom) { 117 chrome.settingsPrivate.getDefaultZoom(function(zoom) {
115 this.$.zoomLevel.value = zoom; 118 this.defaultZoom_ = zoom;
116 }.bind(this)); 119 }.bind(this));
117 }, 120 },
118 121
119 /** 122 /**
120 * @param {number} zoom 123 * @param {number} zoom
121 * @return {number} A zoom easier read by users. 124 * @return {number} A zoom easier read by users.
122 * @private 125 * @private
123 */ 126 */
124 formatZoom_: function(zoom) { 127 formatZoom_: function(zoom) {
125 return Math.round(zoom * 100); 128 return Math.round(zoom * 100);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 chrome.settingsPrivate.setDefaultZoom(parseFloat(this.$.zoomLevel.value)); 245 chrome.settingsPrivate.setDefaultZoom(parseFloat(this.$.zoomLevel.value));
243 }, 246 },
244 247
245 /** 248 /**
246 * @param {boolean} bookmarksBarVisible if bookmarks bar option is visible. 249 * @param {boolean} bookmarksBarVisible if bookmarks bar option is visible.
247 * @return {string} 'first' if the argument is false or empty otherwise. 250 * @return {string} 'first' if the argument is false or empty otherwise.
248 * @private 251 * @private
249 */ 252 */
250 getFirst_: function(bookmarksBarVisible) { 253 getFirst_: function(bookmarksBarVisible) {
251 return !bookmarksBarVisible ? 'first' : ''; 254 return !bookmarksBarVisible ? 'first' : '';
252 } 255 },
256
257 /**
258 * @see content::ZoomValuesEqual().
259 * @param {number} zoom1
260 * @param {number} zoom2
261 * @return {boolean}
262 * @private
263 */
264 zoomValuesEqual_: function(zoom1, zoom2) {
dpapad 2016/11/10 02:20:49 Nit (optional): I think only passing one param in
Dan Beam 2016/11/10 02:25:29 ehhhhhhhhhhhh, but then it's less like a straight-
265 return Math.abs(zoom1 - zoom2) <= 0.001;
266 },
253 }); 267 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/appearance_page/appearance_page.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698