| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 type: String, | 53 type: String, |
| 54 value: 'startup-urls', | 54 value: 'startup-urls', |
| 55 readOnly: true | 55 readOnly: true |
| 56 }, | 56 }, |
| 57 | 57 |
| 58 /** | 58 /** |
| 59 * Title for the page header and navigation menu. | 59 * Title for the page header and navigation menu. |
| 60 */ | 60 */ |
| 61 pageTitle: { | 61 pageTitle: { |
| 62 type: String, | 62 type: String, |
| 63 value: loadTimeData.getString('onStartupSetPages'), | 63 value: function() { return loadTimeData.getString('onStartupSetPages'); }, |
| 64 readOnly: true | 64 readOnly: true |
| 65 }, | 65 }, |
| 66 | 66 |
| 67 /** | 67 /** |
| 68 * Name of the 'core-icon' to be shown in the settings-page-header. | 68 * Name of the 'core-icon' to be shown in the settings-page-header. |
| 69 */ | 69 */ |
| 70 icon: { | 70 icon: { |
| 71 type: String, | 71 type: String, |
| 72 value: 'image:brightness-1', | 72 value: 'image:brightness-1', |
| 73 readOnly: true | 73 readOnly: true |
| 74 }, | 74 }, |
| 75 | 75 |
| 76 newUrl: { | 76 newUrl: { |
| 77 type: String, | 77 type: String, |
| 78 }, | 78 }, |
| 79 | 79 |
| 80 /** @type {!Array<string>} */ | 80 /** @type {!Array<string>} */ |
| 81 savedUrlList: { | 81 savedUrlList: { |
| 82 type: Array, | 82 type: Array, |
| 83 value: function() { return []; } | 83 value: function() { return []; } |
| 84 }, | 84 }, |
| 85 }, | 85 }, |
| 86 | 86 |
| 87 attached: function() { | 87 attached: function() { |
| 88 this.savedUrlList = this.prefs.session.startup_urls.value.slice(); | 88 var startupUrls = this.get('session.startup_urls.value', this.prefs); |
| 89 if (startupUrls) |
| 90 this.savedUrlList = startupUrls.slice(); |
| 89 }, | 91 }, |
| 90 | 92 |
| 91 /** @private */ | 93 /** @private */ |
| 92 onUseCurrentPagesTap_: function() { | 94 onUseCurrentPagesTap_: function() { |
| 93 // TODO(dschuyler): I'll be making a chrome.send call here. | 95 // TODO(dschuyler): I'll be making a chrome.send call here. |
| 94 }, | 96 }, |
| 95 | 97 |
| 96 /** @private */ | 98 /** @private */ |
| 97 onCancelTap_: function() { | 99 onCancelTap_: function() { |
| 98 this.set('prefs.session.startup_urls.value', this.savedUrlList.slice()); | 100 this.set('prefs.session.startup_urls.value', this.savedUrlList.slice()); |
| 99 }, | 101 }, |
| 100 | 102 |
| 101 /** @private */ | 103 /** @private */ |
| 102 onOkTap_: function() { | 104 onOkTap_: function() { |
| 103 var value = this.newUrl && this.newUrl.trim(); | 105 var value = this.newUrl && this.newUrl.trim(); |
| 104 if (!value) | 106 if (!value) |
| 105 return; | 107 return; |
| 106 this.push('prefs.session.startup_urls.value', value); | 108 this.push('prefs.session.startup_urls.value', value); |
| 107 this.newUrl = undefined; | 109 this.newUrl = ''; |
| 108 }, | 110 }, |
| 109 | 111 |
| 110 /** @private */ | 112 /** |
| 113 * @param {!{model: !{index: number}}} e |
| 114 * @private |
| 115 */ |
| 111 onRemoveUrlTap_: function(e) { | 116 onRemoveUrlTap_: function(e) { |
| 112 this.splice('prefs.session.startup_urls.value', e.model.index, 1); | 117 this.splice('prefs.session.startup_urls.value', e.model.index, 1); |
| 113 }, | 118 }, |
| 114 }); | 119 }); |
| OLD | NEW |