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 18 matching lines...) Expand all Loading... | |
29 notify: true, | 29 notify: true, |
30 }, | 30 }, |
31 | 31 |
32 newUrl: { | 32 newUrl: { |
33 type: String, | 33 type: String, |
34 }, | 34 }, |
35 | 35 |
36 /** @type {!Array<string>} */ | 36 /** @type {!Array<string>} */ |
37 savedUrlList: { | 37 savedUrlList: { |
38 type: Array, | 38 type: Array, |
39 value: function() { return []; } | |
40 }, | 39 }, |
41 }, | 40 }, |
42 | 41 |
42 observers: [ | |
43 'prefsChanged_(prefs.session.startup_urls.value.*)', | |
44 ], | |
45 | |
46 attached: function() { | |
47 var updateFunction = this.updateStartupPages_.bind(this); | |
48 cr.define('Settings', function() { | |
49 return { | |
50 updateStartupPages: function(data) { | |
michaelpg
2015/09/17 21:18:13
why not just:
updateStartupPages: updateFunction,
| |
51 updateFunction(data); | |
52 }, | |
53 }; | |
54 }); | |
55 }, | |
56 | |
57 /** @private */ | |
58 prefsChanged_: function(change) { | |
59 if (this.savedUrlList == undefined && | |
60 this.get('prefs.session.startup_urls')) { | |
61 this.savedUrlList = this.prefs.session.startup_urls.value.slice(); | |
62 } | |
63 }, | |
64 | |
65 /** @private */ | |
66 updateStartupPages_: function(data) { | |
67 var urlArray = data.map(function(datum) { return datum.url; }); | |
68 this.set('prefs.session.startup_urls.value', urlArray); | |
69 }, | |
70 | |
43 /** @private */ | 71 /** @private */ |
44 onUseCurrentPagesTap_: function() { | 72 onUseCurrentPagesTap_: function() { |
45 // TODO(dschuyler): I'll be making a chrome.send call here. | 73 chrome.send('setStartupPagesToCurrentPages'); |
46 }, | 74 }, |
47 | 75 |
48 /** @private */ | 76 /** @private */ |
49 onCancelTap_: function() { | 77 onCancelTap_: function() { |
50 this.set('prefs.session.startup_urls.value', this.savedUrlList.slice()); | 78 if (this.savedUrlList !== undefined) { |
79 this.set('prefs.session.startup_urls.value', this.savedUrlList.slice()); | |
80 } | |
51 }, | 81 }, |
52 | 82 |
53 /** @private */ | 83 /** @private */ |
54 onOkTap_: function() { | 84 onOkTap_: function() { |
55 var value = this.newUrl && this.newUrl.trim(); | 85 var value = this.newUrl && this.newUrl.trim(); |
56 if (!value) | 86 if (!value) |
57 return; | 87 return; |
58 this.push('prefs.session.startup_urls.value', value); | 88 this.push('prefs.session.startup_urls.value', value); |
59 this.newUrl = undefined; | 89 this.newUrl = undefined; |
60 }, | 90 }, |
61 | 91 |
62 /** @private */ | 92 /** @private */ |
63 onRemoveUrlTap_: function(e) { | 93 onRemoveUrlTap_: function(e) { |
64 this.splice('prefs.session.startup_urls.value', e.model.index, 1); | 94 this.splice('prefs.session.startup_urls.value', e.model.index, 1); |
65 }, | 95 }, |
66 }); | 96 }); |
OLD | NEW |