Commit fa6a64ed authored by jlklein's avatar jlklein Committed by Commit bot

Fix the pref binding by binding to the object rather than the element

BUG=485381

Review URL: https://codereview.chromium.org/1132223005

Cr-Commit-Position: refs/heads/master@{#329789}
parent 81440521
...@@ -15,42 +15,43 @@ ...@@ -15,42 +15,43 @@
<if expr="chromeos"> <if expr="chromeos">
<cr-settings-checkbox <cr-settings-checkbox
pref="{{prefs.settings.settings.a11y.enable_menu}}" pref="{{prefs.settings.a11y.enable_menu}}"
i18n-values="label:accessibilityOptionsInMenuLabel"> i18n-values="label:accessibilityOptionsInMenuLabel">
</cr-settings-checkbox> </cr-settings-checkbox>
<cr-settings-checkbox <cr-settings-checkbox
pref="{{prefs.settings.settings.a11y.large_cursor_enabled}}" pref="{{prefs.settings.a11y.large_cursor_enabled}}"
i18n-values="label:accessibilityLargeMouseCursorLabel"> i18n-values="label:accessibilityLargeMouseCursorLabel">
</cr-settings-checkbox> </cr-settings-checkbox>
<cr-settings-checkbox <cr-settings-checkbox
pref="{{prefs.settings.settings.a11y.high_contrast_enabled}}" pref="{{prefs.settings.a11y.high_contrast_enabled}}"
i18n-values="label:accessibilityHighContrastLabel"> i18n-values="label:accessibilityHighContrastLabel">
</cr-settings-checkbox> </cr-settings-checkbox>
<cr-settings-checkbox <cr-settings-checkbox
pref="{{prefs.settings.settings.a11y.sticky_keys_enabled}}" pref="{{prefs.settings.a11y.sticky_keys_enabled}}"
i18n-values="label:accessibilityStickyKeysLabel; i18n-values="label:accessibilityStickyKeysLabel;
subLabel:accessibilityStickyKeysSublabel"> subLabel:accessibilityStickyKeysSublabel">
</cr-settings-checkbox> </cr-settings-checkbox>
<cr-settings-checkbox pref="{{prefs.settings.settings.accessibility}}" <cr-settings-checkbox pref="{{prefs.settings.accessibility}}"
i18n-values="label:accessibilityChromeVoxLabel; i18n-values="label:accessibilityChromeVoxLabel;
subLabel:accessibilityChromeVoxSublabel"> subLabel:accessibilityChromeVoxSublabel">
</cr-settings-checkbox> </cr-settings-checkbox>
<cr-settings-checkbox <cr-settings-checkbox
pref="{{prefs.settings.settings.a11y.screen_magnifier}}" pref="{{prefs.settings.a11y.screen_magnifier}}"
i18n-values="label:accessibilityScreenMagnifierLabel"> i18n-values="label:accessibilityScreenMagnifierLabel">
</cr-settings-checkbox> </cr-settings-checkbox>
<cr-settings-checkbox <cr-settings-checkbox
pref="{{prefs.settings.settings.touchpad.enable_tap_dragging}}" pref="{{prefs.settings.touchpad.enable_tap_dragging}}"
i18n-values="label:accessibilityTapDraggingLabel"> i18n-values="label:accessibilityTapDraggingLabel">
</cr-settings-checkbox> </cr-settings-checkbox>
<cr-settings-checkbox pref="{{prefs.settings.settings.a11y.autoclick}}" <cr-settings-checkbox pref="{{prefs.settings.a11y.autoclick}}"
i18n-values="label:accessibilityClickOnStopLabel"> i18n-values="label:accessibilityClickOnStopLabel">
</cr-settings-checkbox> </cr-settings-checkbox>
<div class="autoclick-delay-label" <div class="autoclick-delay-label"
hidden$="{{!prefs.settings.settings.a11y.autoclick}}"> hidden$="{{!prefs.settings.a11y.autoclick}}">
<span i18n-content="accessibilityDelayBeforeClickLabel"></span> <span i18n-content="accessibilityDelayBeforeClickLabel"></span>
<select id="autoclickDropdown" on-change="autoclickSelectChanged_"> <select id="autoclickDropdown"
value="{{prefs.settings.a11y.autoclick_delay_ms::change}}">
<option value="200" <option value="200"
i18n-content="accessibilityDelayBeforeClickExtremelyShort"> i18n-content="accessibilityDelayBeforeClickExtremelyShort">
</option> </option>
...@@ -70,7 +71,7 @@ ...@@ -70,7 +71,7 @@
</div> </div>
<cr-settings-checkbox <cr-settings-checkbox
pref="{{prefs.settings.settings.a11y.virtual_keyboard}}" pref="{{prefs.settings.a11y.virtual_keyboard}}"
i18n-values="label:accessibilityOnScreenKeyboardLabel"> i18n-values="label:accessibilityOnScreenKeyboardLabel">
</cr-settings-checkbox> </cr-settings-checkbox>
</if> </if>
......
...@@ -23,9 +23,6 @@ Polymer({ ...@@ -23,9 +23,6 @@ Polymer({
properties: { properties: {
/** /**
* Preferences state. * Preferences state.
*
* @type {?CrSettingsPrefsElement}
* @default null
*/ */
prefs: { prefs: {
type: Object, type: Object,
...@@ -72,14 +69,4 @@ Polymer({ ...@@ -72,14 +69,4 @@ Polymer({
readOnly: true, readOnly: true,
}, },
}, },
/**
* Called when the selected value of the autoclick dropdown changes.
* TODO(jlklein): Replace with binding when paper-dropdown lands.
* @private
*/
autoclickSelectChanged_: function() {
this.prefs.settings.settings.a11y.autoclick_delay_ms =
this.$.autoclickDropdown.value;
},
}); });
...@@ -21,7 +21,10 @@ Polymer({ ...@@ -21,7 +21,10 @@ Polymer({
* The boolean preference object to control. * The boolean preference object to control.
* @type {?chrome.settingsPrivate.PrefObject} * @type {?chrome.settingsPrivate.PrefObject}
*/ */
pref: Object, pref: {
type: Object,
notify: true,
},
label: { label: {
type: String, type: String,
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<span class="time-zone-label" i18n-content="dateTimeTimeZoneLabel"></span> <span class="time-zone-label" i18n-content="dateTimeTimeZoneLabel"></span>
</div> </div>
<cr-settings-checkbox <cr-settings-checkbox
pref="{{prefs.settings.settings.clock.use_24hour_clock}}" pref="{{prefs.settings.clock.use_24hour_clock}}"
i18n-values="label:dateTime24HourClockLabel"> i18n-values="label:dateTime24HourClockLabel">
</cr-settings-checkbox> </cr-settings-checkbox>
<span id="setAutomatically" i18n-content="dateTimeAutomaticallySet"></span> <span id="setAutomatically" i18n-content="dateTimeAutomaticallySet"></span>
......
...@@ -24,7 +24,6 @@ Polymer({ ...@@ -24,7 +24,6 @@ Polymer({
properties: { properties: {
/** /**
* Preferences state. * Preferences state.
* @type {?CrSettingsPrefsElement}
*/ */
prefs: { prefs: {
type: Object, type: Object,
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<div class="layout horizontal center"> <div class="layout horizontal center">
<div id="locationLabel" i18n-content="downloadsLocationLabel"></div> <div id="locationLabel" i18n-content="downloadsLocationLabel"></div>
<cr-input id="downloadsPath" floating-label="false" <cr-input id="downloadsPath" floating-label="false"
value="{{prefs.settings.download.default_directory.value}}" value="{{prefs.download.default_directory.value}}"
readonly aria-labelledby="locationLabel"> readonly aria-labelledby="locationLabel">
</cr-input> </cr-input>
</div> </div>
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
</cr-button> </cr-button>
</div> </div>
<cr-settings-checkbox <cr-settings-checkbox
pref="{{prefs.settings.download.prompt_for_download}}" pref="{{prefs.download.prompt_for_download}}"
i18n-values="label:downloadsPromptForDownloadLabel"> i18n-values="label:downloadsPromptForDownloadLabel">
</cr-settings-checkbox> </cr-settings-checkbox>
</paper-material> </paper-material>
......
...@@ -24,7 +24,6 @@ Polymer({ ...@@ -24,7 +24,6 @@ Polymer({
properties: { properties: {
/** /**
* Preferences state. * Preferences state.
* @type {?CrSettingsPrefsElement}
*/ */
prefs: { prefs: {
type: Object, type: Object,
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
/** /**
* Object containing all preferences. * Object containing all preferences.
*/ */
settings: { prefStore: {
type: Object, type: Object,
value: function() { return {}; }, value: function() { return {}; },
notify: true, notify: true,
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
*/ */
updatePrefs_: function(prefs, shouldObserve) { updatePrefs_: function(prefs, shouldObserve) {
prefs.forEach(function(prefObj) { prefs.forEach(function(prefObj) {
let root = this.settings; let root = this.prefStore;
let tokens = prefObj.key.split('.'); let tokens = prefObj.key.split('.');
assert(tokens.length > 0); assert(tokens.length > 0);
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
let token = tokens[i]; let token = tokens[i];
if (!root.hasOwnProperty(token)) { if (!root.hasOwnProperty(token)) {
let path = 'settings.' + tokens.slice(0, i + 1).join('.'); let path = 'prefStore.' + tokens.slice(0, i + 1).join('.');
this.setPathValue(path, {}); this.setPathValue(path, {});
} }
root = root[token]; root = root[token];
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
// NOTE: Do this copy rather than just a re-assignment, so that the // NOTE: Do this copy rather than just a re-assignment, so that the
// ObjectObserver fires. // ObjectObserver fires.
for (let objKey in prefObj) { for (let objKey in prefObj) {
let path = 'settings.' + prefObj.key + '.' + objKey; let path = 'prefStore.' + prefObj.key + '.' + objKey;
this.setPathValue(path, prefObj[objKey]); this.setPathValue(path, prefObj[objKey]);
} }
......
...@@ -21,15 +21,6 @@ Polymer({ ...@@ -21,15 +21,6 @@ Polymer({
is: 'cr-settings-search-engines-page', is: 'cr-settings-search-engines-page',
properties: { properties: {
/**
* Preferences state.
* @type {?CrSettingsPrefsElement}
*/
prefs: {
type: Object,
notify: true
},
/** /**
* Route for the page. * Route for the page.
*/ */
......
...@@ -20,15 +20,6 @@ Polymer({ ...@@ -20,15 +20,6 @@ Polymer({
is: 'cr-settings-search-page', is: 'cr-settings-search-page',
properties: { properties: {
/**
* Preferences state.
* @type {?CrSettingsPrefsElement}
*/
prefs: {
type: Object,
notify: true,
},
/** /**
* Route for the page. * Route for the page.
*/ */
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<dom-module id="cr-settings"> <dom-module id="cr-settings">
<template> <template>
<cr-settings-prefs id="prefs"></cr-settings-prefs> <cr-settings-prefs id="prefs" pref-store="{{prefs_}}"></cr-settings-prefs>
<cr-settings-ui prefs="{{prefs_}}"></cr-settings-ui> <cr-settings-ui prefs="{{prefs_}}"></cr-settings-ui>
</template> </template>
<script src="settings.js"></script> <script src="settings.js"></script>
......
...@@ -13,18 +13,4 @@ ...@@ -13,18 +13,4 @@
* @group Chrome Settings Elements * @group Chrome Settings Elements
* @element cr-settings * @element cr-settings
*/ */
Polymer({ Polymer({is: 'cr-settings'});
is: 'cr-settings',
properties: {
/**
* The CrSettingsPrefsElement used throughout the app.
* @private {!CrSettingsPrefsElement}
*/
prefs_: {
type: Object,
value: function() { return this.$.prefs; },
notify: true,
}
},
});
...@@ -43,10 +43,8 @@ ...@@ -43,10 +43,8 @@
</if> </if>
<cr-settings-downloads-page prefs="{{prefs}}" route="downloads"> <cr-settings-downloads-page prefs="{{prefs}}" route="downloads">
</cr-settings-downloads-page> </cr-settings-downloads-page>
<cr-settings-search-page prefs="{{prefs}}" route="search"> <cr-settings-search-page route="search"></cr-settings-search-page>
</cr-settings-search-page> <cr-settings-search-engines-page route="search-engines">
<cr-settings-search-engines-page prefs="{{prefs}}"
route="search-engines">
</cr-settings-search-engines-page> </cr-settings-search-engines-page>
</iron-pages> </iron-pages>
</more-route-selector> </more-route-selector>
......
...@@ -22,23 +22,16 @@ Polymer({ ...@@ -22,23 +22,16 @@ Polymer({
properties: { properties: {
/** /**
* Gets or sets the state. `true` is checked and `false` is unchecked. * Gets or sets the state. `true` is checked and `false` is unchecked.
*
* @attribute checked
* @type {boolean}
* @default false
*/ */
checked: { checked: {
type: Boolean, type: Boolean,
value: false, value: false,
notify: true,
reflectToAttribute: true reflectToAttribute: true
}, },
/** /**
* If true, the user cannot interact with this element. * If true, the user cannot interact with this element.
*
* @attribute disabled
* @type {boolean}
* @default false
*/ */
disabled: { disabled: {
type: Boolean, type: Boolean,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment