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

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

Issue 2403353002: MD Settings: Stop calling chrome.settingsPrivate.setDefaultZoomLevel on startup. (Closed)
Patch Set: Address comment. Created 4 years, 2 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
« no previous file with comments | « no previous file | 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 *
(...skipping 13 matching lines...) Expand all
24 browserProxy_: Object, 24 browserProxy_: Object,
25 25
26 /** 26 /**
27 * Preferences state. 27 * Preferences state.
28 */ 28 */
29 prefs: { 29 prefs: {
30 type: Object, 30 type: Object,
31 notify: true, 31 notify: true,
32 }, 32 },
33 33
34 /** 34 /** @private */
35 * @private
36 */
37 allowResetTheme_: { 35 allowResetTheme_: {
38 notify: true, 36 notify: true,
39 type: Boolean, 37 type: Boolean,
40 value: false, 38 value: false,
41 }, 39 },
42 40
43 /** 41 /** @private */
44 * @private
45 */
46 defaultZoomLevel_: { 42 defaultZoomLevel_: {
47 notify: true, 43 notify: true,
48 type: Object, 44 type: Object,
49 value: function() { 45 value: {type: chrome.settingsPrivate.PrefType.NUMBER},
Dan Beam 2016/10/11 19:03:23 can we just omit the default value and use: defau
dpapad 2016/10/11 19:33:06 Unfortunately that only works when you are setting
Dan Beam 2016/10/11 19:34:48 and the problem with that is what?
Dan Beam 2016/10/11 19:35:50 i.e. why not just change this code:
dpapad 2016/10/11 19:43:24 The problem is that settings-dropdown-menu does no
Dan Beam 2016/10/12 23:56:20 does this work? this.defaultZoomLevel_ = {...}; t
50 return {
51 type: chrome.settingsPrivate.PrefType.NUMBER,
52 };
53 },
54 }, 46 },
55 47
56 /** 48 /**
49 * Needed such that the |defaultZoomLevel_| pref can be initialized
50 * without unnecessarily invoking
51 * chrome.settingsPrivate.setDefaultZoomPercent().
52 * @private
53 */
54 defaultZoomLevelInitialized_: {
Dan Beam 2016/10/11 19:03:23 fyi, some polymer peeps asked me to use vanilla pr
dpapad 2016/10/11 19:33:06 Done. I was thinking about this myself.
55 type: Boolean,
56 value: false,
57 },
58
59 /**
57 * List of options for the font size drop-down menu. 60 * List of options for the font size drop-down menu.
58 * @type {!DropdownMenuOptionList} 61 * @type {!DropdownMenuOptionList}
59 */ 62 */
60 fontSizeOptions_: { 63 fontSizeOptions_: {
61 readOnly: true, 64 readOnly: true,
62 type: Array, 65 type: Array,
63 value: function() { 66 value: function() {
64 return [ 67 return [
65 {value: 9, name: loadTimeData.getString('verySmall')}, 68 {value: 9, name: loadTimeData.getString('verySmall')},
66 {value: 12, name: loadTimeData.getString('small')}, 69 {value: 12, name: loadTimeData.getString('small')},
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 ], 118 ],
116 119
117 created: function() { 120 created: function() {
118 this.browserProxy_ = settings.AppearanceBrowserProxyImpl.getInstance(); 121 this.browserProxy_ = settings.AppearanceBrowserProxyImpl.getInstance();
119 }, 122 },
120 123
121 ready: function() { 124 ready: function() {
122 this.$.defaultFontSize.menuOptions = this.fontSizeOptions_; 125 this.$.defaultFontSize.menuOptions = this.fontSizeOptions_;
123 this.$.pageZoom.menuOptions = this.pageZoomOptions_; 126 this.$.pageZoom.menuOptions = this.pageZoomOptions_;
124 // TODO(dschuyler): Look into adding a listener for the 127 // TODO(dschuyler): Look into adding a listener for the
125 // default zoom percent. 128 // default zoom percent.
Dan Beam 2016/10/11 19:03:23 i suppose this is more work than we want to do rig
dpapad 2016/10/11 19:33:06 Definitely not in this CL, but I think we should a
126 chrome.settingsPrivate.getDefaultZoomPercent( 129 chrome.settingsPrivate.getDefaultZoomPercent(
127 this.zoomPrefChanged_.bind(this)); 130 this.zoomPrefChanged_.bind(this));
128 }, 131 },
129 132
130 /** @override */ 133 /** @override */
131 attached: function() { 134 attached: function() {
132 // Query the initial state. 135 // Query the initial state.
133 this.browserProxy_.getResetThemeEnabled().then( 136 this.browserProxy_.getResetThemeEnabled().then(
134 this.setResetThemeEnabled.bind(this)); 137 this.setResetThemeEnabled.bind(this));
135 138
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } else { 198 } else {
196 this.themeSublabel_ = this.i18n('chooseFromWebStore'); 199 this.themeSublabel_ = this.i18n('chooseFromWebStore');
197 } 200 }
198 }, 201 },
199 202
200 /** 203 /**
201 * @param {number} percent The integer percentage of the page zoom. 204 * @param {number} percent The integer percentage of the page zoom.
202 * @private 205 * @private
203 */ 206 */
204 zoomPrefChanged_: function(percent) { 207 zoomPrefChanged_: function(percent) {
205 this.set('defaultZoomLevel_.value', percent); 208 this.set('defaultZoomLevel_.value', percent);
Dan Beam 2016/10/11 19:35:50 this.defaultZoomLevel_ = { type: chrome.settings
michaelpg 2016/10/11 22:01:10 but then you're relying on a mildly obscure fact a
Dan Beam 2016/10/12 23:17:43 I think this is defined and intentional, not mildl
206 }, 209 },
207 210
208 /** 211 /**
209 * @param {number} percent The integer percentage of the page zoom. 212 * @param {number} percent The integer percentage of the page zoom.
210 * @private 213 * @private
211 */ 214 */
212 zoomLevelChanged_: function(percent) { 215 zoomLevelChanged_: function(percent) {
213 // The |percent| may be undefined on startup. 216 // The |percent| may be undefined on startup.
214 if (percent === undefined) 217 if (percent === undefined)
215 return; 218 return;
219
220 if (!this.defaultZoomLevelInitialized_) {
221 // Simply mark this pref as initialized, no actual change was requested by
222 // the user.
223 this.defaultZoomLevelInitialized_ = true;
224 return;
225 }
226
216 chrome.settingsPrivate.setDefaultZoomPercent(percent); 227 chrome.settingsPrivate.setDefaultZoomPercent(percent);
217 }, 228 },
218 229
219 /** 230 /**
220 * @param {boolean} bookmarksBarVisible if bookmarks bar option is visible. 231 * @param {boolean} bookmarksBarVisible if bookmarks bar option is visible.
221 * @return {string} 'first' if the argument is false or empty otherwise. 232 * @return {string} 'first' if the argument is false or empty otherwise.
222 * @private 233 * @private
223 */ 234 */
224 getFirst_: function(bookmarksBarVisible) { 235 getFirst_: function(bookmarksBarVisible) {
225 return !bookmarksBarVisible ? 'first' : ''; 236 return !bookmarksBarVisible ? 'first' : '';
226 } 237 }
227 }); 238 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698