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 * @fileoverview 'cr-settings-startup-urls-page' is the settings page | 6 * @fileoverview 'cr-settings-startup-urls-page' is the settings page |
| 7 * containing the urls that will be opened when chrome is started. | 7 * containing the urls that will be opened when chrome is started. |
| 8 * | 8 * |
| 9 * Example: | 9 * Example: |
| 10 * | 10 * |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 }, | 40 }, |
| 41 | 41 |
| 42 observers: [ | 42 observers: [ |
| 43 'prefsChanged_(prefs.session.startup_urls.value.*)', | 43 'prefsChanged_(prefs.session.startup_urls.value.*)', |
| 44 ], | 44 ], |
| 45 | 45 |
| 46 attached: function() { | 46 attached: function() { |
| 47 var updateFunction = this.updateStartupPages_.bind(this); | 47 var updateFunction = this.updateStartupPages_.bind(this); |
| 48 cr.define('Settings', function() { | 48 cr.define('Settings', function() { |
| 49 return { | 49 return { |
| 50 updateStartupPages: updateFunction, | 50 updateStartupPages: function(data) { |
| 51 updateFunction(data); | |
| 52 }, | |
|
Dan Beam
2015/09/18 01:42:05
you shouldn't need to make an extra scope just to
dschuyler
2015/09/18 02:36:29
I've moved the declaration to a var.
(I also found
| |
| 51 }; | 53 }; |
| 52 }); | 54 }); |
| 53 }, | 55 }, |
| 54 | 56 |
| 57 | |
| 55 /** @private */ | 58 /** @private */ |
| 56 prefsChanged_: function(change) { | 59 prefsChanged_: function(change) { |
| 57 if (this.savedUrlList == undefined && | 60 if (this.savedUrlList == undefined && |
| 58 this.get('prefs.session.startup_urls')) { | 61 this.get('prefs.session.startup_urls')) { |
| 59 this.savedUrlList = this.prefs.session.startup_urls.value.slice(); | 62 var pref = /** @type {chrome.settingsPrivate.PrefObject} */( |
| 63 this.get('prefs.session.startup_urls')); | |
|
Dan Beam
2015/09/18 01:42:05
why can't you re-use the .get() call above? e.g.
dschuyler
2015/09/18 02:36:29
Done.
| |
| 64 this.savedUrlList = pref.value.slice(); | |
| 60 } | 65 } |
| 61 }, | 66 }, |
| 62 | 67 |
| 63 /** @private */ | 68 /** @private */ |
| 64 updateStartupPages_: function(data) { | 69 updateStartupPages_: function(data) { |
| 65 var urlArray = []; | 70 var urlArray = []; |
| 66 for (var i = 0; i < data.length; ++i) | 71 for (var i = 0; i < data.length; ++i) |
| 67 urlArray.push(data[i].url); | 72 urlArray.push(data[i].url); |
| 68 this.set('prefs.session.startup_urls.value', urlArray); | 73 this.set('prefs.session.startup_urls.value', urlArray); |
| 69 }, | 74 }, |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 90 }, | 95 }, |
| 91 | 96 |
| 92 /** | 97 /** |
| 93 * @param {!{model: !{index: number}}} e | 98 * @param {!{model: !{index: number}}} e |
| 94 * @private | 99 * @private |
| 95 */ | 100 */ |
| 96 onRemoveUrlTap_: function(e) { | 101 onRemoveUrlTap_: function(e) { |
| 97 this.splice('prefs.session.startup_urls.value', e.model.index, 1); | 102 this.splice('prefs.session.startup_urls.value', e.model.index, 1); |
| 98 }, | 103 }, |
| 99 }); | 104 }); |
| OLD | NEW |