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

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

Issue 1316003003: Add compiled_resources for settings/ and cr_elements/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@md_settings_compiled_resources_2
Patch Set: Add prefs/compiled_resources Created 5 years, 3 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
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 * @fileoverview 6 * @fileoverview
7 * 'cr-settings-prefs' is an element which serves as a model for 7 * 'cr-settings-prefs' is an element which serves as a model for
8 * interaction with settings which are stored in Chrome's 8 * interaction with settings which are stored in Chrome's
9 * Preferences. 9 * Preferences.
10 * 10 *
11 * Example: 11 * Example:
12 * 12 *
13 * <cr-settings-prefs id="prefs"></cr-settings-prefs> 13 * <cr-settings-prefs id="prefs"></cr-settings-prefs>
14 * <cr-settings-a11y-page prefs="{{this.$.prefs}}"></cr-settings-a11y-page> 14 * <cr-settings-a11y-page prefs="{{this.$.prefs}}"></cr-settings-a11y-page>
15 * 15 *
16 * @group Chrome Settings Elements 16 * @group Chrome Settings Elements
17 * @element cr-settings-a11y-page 17 * @element cr-settings-a11y-page
18 */ 18 */
19
20 /**
21 * TODO(stevenjb/michaelpg): Remove this once we stop using Object.observer.
Dan Beam 2015/08/28 20:32:26 observer -> observe
stevenjb 2015/08/28 20:57:16 Done.
22 * (that CL is in review, otherwise this doesn't really belong here).
23 * @param {!Object} object
24 * @param {!Function} callback
25 * @param {!Array<string>=} opt_acceptList
26 */
27 Object.observe = function(object, callback, opt_acceptList) {};
Dan Beam 2015/08/28 20:32:26 why can't we pull in es7_observe.js?
stevenjb 2015/08/28 20:57:16 Didn't seem worth any effort for something that's
stevenjb 2015/08/28 20:59:27 Also, I can wait for Michael's patch before landin
28
19 (function() { 29 (function() {
20 'use strict'; 30 'use strict';
21 31
22 Polymer({ 32 Polymer({
23 is: 'cr-settings-prefs', 33 is: 'cr-settings-prefs',
24 34
25 properties: { 35 properties: {
26 /** 36 /**
27 * Object containing all preferences. 37 * Object containing all preferences.
28 */ 38 */
29 prefStore: { 39 prefStore: {
30 type: Object, 40 type: Object,
31 value: function() { return {}; }, 41 value: function() { return {}; },
32 notify: true, 42 notify: true,
33 }, 43 },
34 }, 44 },
35 45
36 /** @override */ 46 /** @override */
37 created: function() { 47 created: function() {
38 CrSettingsPrefs.isInitialized = false; 48 CrSettingsPrefs.isInitialized = false;
39 49
40 chrome.settingsPrivate.onPrefsChanged.addListener( 50 chrome.settingsPrivate.onPrefsChanged.addListener(
41 this.onPrefsChanged_.bind(this)); 51 this.onPrefsChanged_.bind(this));
42 chrome.settingsPrivate.getAllPrefs(this.onPrefsFetched_.bind(this)); 52 chrome.settingsPrivate.getAllPrefs(this.onPrefsFetched_.bind(this));
43 }, 53 },
44 54
45 /** 55 /**
46 * Called when prefs in the underlying Chrome pref store are changed. 56 * Called when prefs in the underlying Chrome pref store are changed.
47 * @param {!Array<!PrefObject>} prefs The prefs that changed. 57 * @param {!Array<!chrome.settingsPrivate.PrefObject>} prefs The prefs that
58 * changed.
48 * @private 59 * @private
49 */ 60 */
50 onPrefsChanged_: function(prefs) { 61 onPrefsChanged_: function(prefs) {
51 this.updatePrefs_(prefs, false); 62 this.updatePrefs_(prefs, false);
52 }, 63 },
53 64
54 /** 65 /**
55 * Called when prefs are fetched from settingsPrivate. 66 * Called when prefs are fetched from settingsPrivate.
56 * @param {!Array<!PrefObject>} prefs 67 * @param {!Array<!chrome.settingsPrivate.PrefObject>} prefs
57 * @private 68 * @private
58 */ 69 */
59 onPrefsFetched_: function(prefs) { 70 onPrefsFetched_: function(prefs) {
60 this.updatePrefs_(prefs, true); 71 this.updatePrefs_(prefs, true);
61 72
62 CrSettingsPrefs.isInitialized = true; 73 CrSettingsPrefs.isInitialized = true;
63 document.dispatchEvent(new Event(CrSettingsPrefs.INITIALIZED)); 74 document.dispatchEvent(new Event(CrSettingsPrefs.INITIALIZED));
64 }, 75 },
65 76
66 77
67 /** 78 /**
68 * Updates the settings model with the given prefs. 79 * Updates the settings model with the given prefs.
69 * @param {!Array<!PrefObject>} prefs 80 * @param {!Array<!chrome.settingsPrivate.PrefObject>} prefs
70 * @param {boolean} shouldObserve Whether each of the prefs should be 81 * @param {boolean} shouldObserve Whether each of the prefs should be
71 * observed. 82 * observed.
72 * @private 83 * @private
73 */ 84 */
74 updatePrefs_: function(prefs, shouldObserve) { 85 updatePrefs_: function(prefs, shouldObserve) {
75 prefs.forEach(function(prefObj) { 86 prefs.forEach(function(prefObj) {
76 let root = this.prefStore; 87 let root = this.prefStore;
77 let tokens = prefObj.key.split('.'); 88 let tokens = prefObj.key.split('.');
78 89
79 assert(tokens.length > 0); 90 assert(tokens.length > 0);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 163
153 chrome.settingsPrivate.setPref( 164 chrome.settingsPrivate.setPref(
154 change.object['key'], 165 change.object['key'],
155 newValue, 166 newValue,
156 /* pageId */ '', 167 /* pageId */ '',
157 /* callback */ function() {}); 168 /* callback */ function() {});
158 }); 169 });
159 }, 170 },
160 }); 171 });
161 })(); 172 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698