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

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

Issue 988783002: Add an initial implementation of the downloads MD settings page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a TODO. Created 5 years, 9 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 *
(...skipping 16 matching lines...) Expand all
27 */ 27 */
28 settings: null, 28 settings: null,
29 }, 29 },
30 30
31 /** @override */ 31 /** @override */
32 created: function() { 32 created: function() {
33 'use strict'; 33 'use strict';
34 34
35 this.settings = {}; 35 this.settings = {};
36 this.initializeA11y_(); 36 this.initializeA11y_();
37 this.initializeDownloads_();
37 var observer = new ObjectObserver(this.settings); 38 var observer = new ObjectObserver(this.settings);
38 observer.open(this.propertyChangeCallback_.bind(this, 'settings')); 39 observer.open(this.propertyChangeCallback_.bind(this, 'settings'));
39 40
40 // For all Object properties of settings, create an ObjectObserver. 41 // For all Object properties of settings, create an ObjectObserver.
41 for (let key in this.settings) { 42 for (let key in this.settings) {
42 if (typeof this.settings[key] == 'object') { 43 if (typeof this.settings[key] == 'object') {
43 let keyObserver = new ObjectObserver(this.settings[key]); 44 let keyObserver = new ObjectObserver(this.settings[key]);
44 keyObserver.open( 45 keyObserver.open(
45 this.propertyChangeCallback_.bind(this, 'settings.' + key)); 46 this.propertyChangeCallback_.bind(this, 'settings.' + key));
46 } 47 }
(...skipping 22 matching lines...) Expand all
69 }; 70 };
70 71
71 // ChromeVox is enbaled/disabled via the 'settings.accessibility' boolean 72 // ChromeVox is enbaled/disabled via the 'settings.accessibility' boolean
72 // pref. 73 // pref.
73 this.settings.accessibility = false; 74 this.settings.accessibility = false;
74 75
75 // TODO(jlklein): Actually pull the data out of prefs and initialize. 76 // TODO(jlklein): Actually pull the data out of prefs and initialize.
76 }, 77 },
77 78
78 /** 79 /**
80 * Initializes some defaults for the downloads settings.
81 * @private
82 */
83 initializeDownloads_: function() {
84 this.settings.downloads = {
85 downloadLocation: '',
86 promptForDownload: false,
87 };
88
89 // TODO(jlklein): Actually pull the data out of prefs and initialize.
Jeremy Klein 2015/03/06 19:40:14 nit: no need for the duplicate TODO.
Oren Blasberg 2015/03/06 19:53:16 Done.
90 },
91
92 /**
79 * @param {string} propertyPath The path before the property names. 93 * @param {string} propertyPath The path before the property names.
80 * @param {!Array<string>} added An array of keys which were added. 94 * @param {!Array<string>} added An array of keys which were added.
81 * @param {!Array<string>} removed An array of keys which were removed. 95 * @param {!Array<string>} removed An array of keys which were removed.
82 * @param {!Array<string>} changed An array of keys of properties whose 96 * @param {!Array<string>} changed An array of keys of properties whose
83 * values changed. 97 * values changed.
84 * @param {function(string) : *} getOldValueFn A function which takes a 98 * @param {function(string) : *} getOldValueFn A function which takes a
85 * property name and returns the old value for that property. 99 * property name and returns the old value for that property.
86 * @private 100 * @private
87 */ 101 */
88 propertyChangeCallback_: function( 102 propertyChangeCallback_: function(
89 propertyPath, added, removed, changed, getOldValueFn) { 103 propertyPath, added, removed, changed, getOldValueFn) {
90 Object.keys(changed).forEach(function(property) { 104 Object.keys(changed).forEach(function(property) {
91 console.log( 105 console.log(
92 `${propertyPath}.${property}`, 106 `${propertyPath}.${property}`,
93 `old : ${getOldValueFn(property)}`, 107 `old : ${getOldValueFn(property)}`,
94 `newValue : ${changed[property]}`); 108 `newValue : ${changed[property]}`);
95 109
96 // TODO(jlklein): Actually set the changed property back to prefs. 110 // TODO(jlklein): Actually set the changed property back to prefs.
97 }); 111 });
98 }, 112 },
99 }); 113 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698