Chromium Code Reviews| 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 {value: undefined}; | |
| 57 }, | |
| 58 }, | |
| 59 | |
| 60 /** | |
| 42 * List of options for the font size drop-down menu. | 61 * List of options for the font size drop-down menu. |
| 43 * The order of entries in this array matches the | 62 * @type {!DropdownMenuOptionList} |
| 44 * prefs.browser.clear_data.time_period.value enum. | |
| 45 * @private {!Array<!Array<{0: number, 1: string}>>} | |
| 46 */ | 63 */ |
| 47 fontSizeOptions_: { | 64 fontSizeOptions_: { |
| 48 readOnly: true, | 65 readOnly: true, |
| 49 type: Array, | 66 type: Array, |
| 50 value: function() { | 67 value: function() { |
| 51 return [ | 68 return [ |
| 52 [9, loadTimeData.getString('verySmall')], | 69 [9, loadTimeData.getString('verySmall')], |
| 53 [12, loadTimeData.getString('small')], | 70 [12, loadTimeData.getString('small')], |
| 54 [16, loadTimeData.getString('medium')], | 71 [16, loadTimeData.getString('medium')], |
| 55 [20, loadTimeData.getString('large')], | 72 [20, loadTimeData.getString('large')], |
| 56 [24, loadTimeData.getString('veryLarge')], | 73 [24, loadTimeData.getString('veryLarge')], |
| 57 ]; | 74 ]; |
| 58 }, | 75 }, |
| 59 }, | 76 }, |
| 77 | |
| 78 /** | |
| 79 * List of options for the page zoom drop-down menu. | |
| 80 * @type {!DropdownMenuOptionList} | |
| 81 */ | |
| 82 pageZoomOptions_: { | |
| 83 readOnly: true, | |
| 84 type: Array, | |
| 85 value: [ | |
| 86 [25, '25%'], | |
| 87 [33, '33%'], | |
| 88 [50, '50%'], | |
| 89 [67, '67%'], | |
| 90 [75, '75%'], | |
| 91 [90, '90%'], | |
| 92 [100, '100%'], | |
| 93 [110, '110%'], | |
| 94 [125, '125%'], | |
| 95 [150, '150%'], | |
| 96 [175, '175%'], | |
| 97 [200, '200%'], | |
| 98 [300, '300%'], | |
| 99 [400, '400%'], | |
| 100 [500, '500%'], | |
| 101 ], | |
| 102 }, | |
| 60 }, | 103 }, |
| 61 | 104 |
| 62 behaviors: [ | 105 behaviors: [ |
| 63 I18nBehavior, | 106 I18nBehavior, |
| 64 ], | 107 ], |
| 65 | 108 |
| 109 observers: [ | |
| 110 'zoomLevelChanged_(defaultZoomLevel_.value)', | |
| 111 ], | |
| 112 | |
| 66 ready: function() { | 113 ready: function() { |
| 67 this.$.defaultFontSize.menuOptions = this.fontSizeOptions_; | 114 this.$.defaultFontSize.menuOptions = this.fontSizeOptions_; |
| 115 this.$.pageZoom.menuOptions = this.pageZoomOptions_; | |
| 116 chrome.settingsPrivate.getDefaultZoomPercent( | |
| 117 this.zoomPrefChanged_.bind(this)); | |
| 68 }, | 118 }, |
| 69 | 119 |
| 70 /** @override */ | 120 /** @override */ |
| 71 attached: function() { | 121 attached: function() { |
| 72 // Query the initial state. | 122 // Query the initial state. |
| 73 cr.sendWithCallback('getResetThemeEnabled', undefined, | 123 cr.sendWithCallback('getResetThemeEnabled', undefined, |
| 74 this.setResetThemeEnabled.bind(this)); | 124 this.setResetThemeEnabled.bind(this)); |
| 75 | 125 |
| 76 // Set up the change event listener. | 126 // Set up the change event listener. |
| 77 cr.addWebUIListener('reset-theme-enabled-changed', | 127 cr.addWebUIListener('reset-theme-enabled-changed', |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 92 | 142 |
| 93 /** @private */ | 143 /** @private */ |
| 94 openThemesGallery_: function() { | 144 openThemesGallery_: function() { |
| 95 window.open(loadTimeData.getString('themesGalleryUrl')); | 145 window.open(loadTimeData.getString('themesGalleryUrl')); |
| 96 }, | 146 }, |
| 97 | 147 |
| 98 /** @private */ | 148 /** @private */ |
| 99 resetTheme_: function() { | 149 resetTheme_: function() { |
| 100 chrome.send('resetTheme'); | 150 chrome.send('resetTheme'); |
| 101 }, | 151 }, |
| 152 | |
| 153 /** | |
| 154 * @param {number} percent The integer percentage of the page zoom. | |
| 155 * @private | |
| 156 */ | |
| 157 zoomPrefChanged_: function(percent) { | |
| 158 this.set('defaultZoomLevel_.value', percent); | |
| 159 }, | |
| 160 | |
| 161 /** | |
| 162 * @param {number} percent The integer percentage of the page zoom. | |
| 163 * @private | |
| 164 */ | |
| 165 zoomLevelChanged_: function(percent) { | |
| 166 // The |percent| may be undefined on startup. | |
|
michaelpg
2015/11/11 02:09:41
This is dumb. FWIW, I consider this a Polymer bug.
| |
| 167 if (percent === undefined) | |
| 168 return; | |
| 169 chrome.settingsPrivate.setDefaultZoomPercent(percent); | |
| 170 }, | |
| 102 }); | 171 }); |
| OLD | NEW |