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 /** | 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 12 matching lines...) Expand all Loading... |
23 properties: { | 23 properties: { |
24 /** | 24 /** |
25 * The current active route. | 25 * The current active route. |
26 */ | 26 */ |
27 currentRoute: { | 27 currentRoute: { |
28 notify: true, | 28 notify: true, |
29 type: Object, | 29 type: Object, |
30 }, | 30 }, |
31 | 31 |
32 /** | 32 /** |
| 33 * Preferences state. |
| 34 */ |
| 35 prefs: { |
| 36 type: Object, |
| 37 notify: true, |
| 38 }, |
| 39 |
| 40 /** |
33 * @private | 41 * @private |
34 */ | 42 */ |
35 allowResetTheme_: { | 43 allowResetTheme_: { |
36 notify: true, | 44 notify: true, |
37 type: Boolean, | 45 type: Boolean, |
38 value: false, | 46 value: false, |
39 }, | 47 }, |
40 | 48 |
41 /** | 49 /** |
| 50 * @private |
| 51 */ |
| 52 defaultZoomLevel_: { |
| 53 notify: true, |
| 54 type: Object, |
| 55 value: function() { |
| 56 return { |
| 57 type: chrome.settingsPrivate.PrefType.NUMBER, |
| 58 }; |
| 59 }, |
| 60 }, |
| 61 |
| 62 /** |
42 * List of options for the font size drop-down menu. | 63 * List of options for the font size drop-down menu. |
43 * The order of entries in this array matches the | 64 * @type {!DropdownMenuOptionList} |
44 * prefs.browser.clear_data.time_period.value enum. | |
45 * @private {!Array<!Array<{0: number, 1: string}>>} | |
46 */ | 65 */ |
47 fontSizeOptions_: { | 66 fontSizeOptions_: { |
48 readOnly: true, | 67 readOnly: true, |
49 type: Array, | 68 type: Array, |
50 value: function() { | 69 value: function() { |
51 return [ | 70 return [ |
52 [9, loadTimeData.getString('verySmall')], | 71 {value: 9, name: loadTimeData.getString('verySmall')}, |
53 [12, loadTimeData.getString('small')], | 72 {value: 12, name: loadTimeData.getString('small')}, |
54 [16, loadTimeData.getString('medium')], | 73 {value: 16, name: loadTimeData.getString('medium')}, |
55 [20, loadTimeData.getString('large')], | 74 {value: 20, name: loadTimeData.getString('large')}, |
56 [24, loadTimeData.getString('veryLarge')], | 75 {value: 24, name: loadTimeData.getString('veryLarge')}, |
57 ]; | 76 ]; |
58 }, | 77 }, |
59 }, | 78 }, |
| 79 |
| 80 /** |
| 81 * List of options for the page zoom drop-down menu. |
| 82 * @type {!DropdownMenuOptionList} |
| 83 */ |
| 84 pageZoomOptions_: { |
| 85 readOnly: true, |
| 86 type: Array, |
| 87 value: [ |
| 88 {value: 25, name: '25%'}, |
| 89 {value: 33, name: '33%'}, |
| 90 {value: 50, name: '50%'}, |
| 91 {value: 67, name: '67%'}, |
| 92 {value: 75, name: '75%'}, |
| 93 {value: 90, name: '90%'}, |
| 94 {value: 100, name: '100%'}, |
| 95 {value: 110, name: '110%'}, |
| 96 {value: 125, name: '125%'}, |
| 97 {value: 150, name: '150%'}, |
| 98 {value: 175, name: '175%'}, |
| 99 {value: 200, name: '200%'}, |
| 100 {value: 300, name: '300%'}, |
| 101 {value: 400, name: '400%'}, |
| 102 {value: 500, name: '500%'}, |
| 103 ], |
| 104 }, |
60 }, | 105 }, |
61 | 106 |
62 behaviors: [ | 107 behaviors: [ |
63 I18nBehavior, | 108 I18nBehavior, |
64 ], | 109 ], |
65 | 110 |
| 111 observers: [ |
| 112 'zoomLevelChanged_(defaultZoomLevel_.value)', |
| 113 ], |
| 114 |
66 ready: function() { | 115 ready: function() { |
67 this.$.defaultFontSize.menuOptions = this.fontSizeOptions_; | 116 this.$.defaultFontSize.menuOptions = this.fontSizeOptions_; |
| 117 this.$.pageZoom.menuOptions = this.pageZoomOptions_; |
| 118 // TODO(dschuyler): Look into adding a listener for the |
| 119 // default zoom percent. |
| 120 chrome.settingsPrivate.getDefaultZoomPercent( |
| 121 this.zoomPrefChanged_.bind(this)); |
68 }, | 122 }, |
69 | 123 |
70 /** @override */ | 124 /** @override */ |
71 attached: function() { | 125 attached: function() { |
72 // Query the initial state. | 126 // Query the initial state. |
73 cr.sendWithCallback('getResetThemeEnabled', undefined, | 127 cr.sendWithCallback('getResetThemeEnabled', undefined, |
74 this.setResetThemeEnabled.bind(this)); | 128 this.setResetThemeEnabled.bind(this)); |
75 | 129 |
76 // Set up the change event listener. | 130 // Set up the change event listener. |
77 cr.addWebUIListener('reset-theme-enabled-changed', | 131 cr.addWebUIListener('reset-theme-enabled-changed', |
(...skipping 19 matching lines...) Expand all Loading... |
97 | 151 |
98 /** @private */ | 152 /** @private */ |
99 resetTheme_: function() { | 153 resetTheme_: function() { |
100 chrome.send('resetTheme'); | 154 chrome.send('resetTheme'); |
101 }, | 155 }, |
102 | 156 |
103 /** @private */ | 157 /** @private */ |
104 showFontsPage_: function() { | 158 showFontsPage_: function() { |
105 return this.currentRoute.subpage[0] == 'appearance-fonts'; | 159 return this.currentRoute.subpage[0] == 'appearance-fonts'; |
106 }, | 160 }, |
| 161 |
| 162 /** |
| 163 * @param {number} percent The integer percentage of the page zoom. |
| 164 * @private |
| 165 */ |
| 166 zoomPrefChanged_: function(percent) { |
| 167 this.set('defaultZoomLevel_.value', percent); |
| 168 }, |
| 169 |
| 170 /** |
| 171 * @param {number} percent The integer percentage of the page zoom. |
| 172 * @private |
| 173 */ |
| 174 zoomLevelChanged_: function(percent) { |
| 175 // The |percent| may be undefined on startup. |
| 176 if (percent === undefined) |
| 177 return; |
| 178 chrome.settingsPrivate.setDefaultZoomPercent(percent); |
| 179 }, |
107 }); | 180 }); |
OLD | NEW |