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 * @typedef {{ | 6 * @typedef {{ |
| 7 * 'title': string, | 7 * 'title': string, |
| 8 * 'tooltip': string, | 8 * 'tooltip': string, |
| 9 * 'url': string | 9 * 'url': string |
| 10 * }} | 10 * }} |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 | 31 |
| 32 properties: { | 32 properties: { |
| 33 /** | 33 /** |
| 34 * Preferences state. | 34 * Preferences state. |
| 35 */ | 35 */ |
| 36 prefs: { | 36 prefs: { |
| 37 type: Object, | 37 type: Object, |
| 38 notify: true, | 38 notify: true, |
| 39 }, | 39 }, |
| 40 | 40 |
| 41 newUrl: { | 41 /** @private {string} */ |
| 42 newUrl_: { | |
| 42 type: String, | 43 type: String, |
| 44 value: '', | |
| 43 }, | 45 }, |
| 44 | 46 |
| 45 /** | 47 /** |
| 46 * Pages to load upon browser startup. | 48 * Pages to load upon browser startup. |
| 47 * @private {!Array<!StartupPageInfo>} | 49 * @private {!Array<!StartupPageInfo>} |
| 48 */ | 50 */ |
| 49 startupPages_: Array, | 51 startupPages_: Array, |
| 50 }, | 52 }, |
| 51 | 53 |
| 52 attached: function() { | 54 attached: function() { |
| 53 var self = this; | 55 var self = this; |
| 54 cr.define('Settings', function() { | 56 cr.define('Settings', function() { |
| 55 return { | 57 return { |
| 56 updateStartupPages: function() { | 58 updateStartupPages: function() { |
| 57 return self.updateStartupPages_.apply(self, arguments); | 59 return self.updateStartupPages_.apply(self, arguments); |
| 58 }, | 60 }, |
| 59 }; | 61 }; |
| 60 }); | 62 }); |
| 61 chrome.send('onStartupPrefsPageLoad'); | 63 chrome.send('onStartupPrefsPageLoad'); |
| 62 }, | 64 }, |
| 63 | 65 |
| 64 /** @private */ | 66 /** @private */ |
| 65 updateStartupPages_: function(startupPages) { | 67 updateStartupPages_: function(startupPages) { |
| 66 this.startupPages_ = startupPages; | 68 this.startupPages_ = startupPages; |
| 67 }, | 69 }, |
| 68 | 70 |
| 69 /** @private */ | 71 /** @private */ |
| 70 onAddPageTap_: function() { | 72 onAddPageTap_: function() { |
| 73 this.newUrl_ = ''; | |
| 71 this.$.addUrlDialog.open(); | 74 this.$.addUrlDialog.open(); |
| 72 }, | 75 }, |
| 73 | 76 |
| 74 /** @private */ | 77 /** @private */ |
| 75 onUseCurrentPagesTap_: function() { | 78 onUseCurrentPagesTap_: function() { |
| 76 chrome.send('setStartupPagesToCurrentPages'); | 79 chrome.send('setStartupPagesToCurrentPages'); |
| 77 }, | 80 }, |
| 78 | 81 |
| 79 /** @private */ | 82 /** @private */ |
| 80 onCancelTap_: function() { | 83 onCancelTap_: function() { |
| 81 this.$.addUrlDialog.close(); | 84 this.$.addUrlDialog.close(); |
| 82 }, | 85 }, |
| 83 | 86 |
| 87 /** | |
| 88 * @return {boolean} Whether tapping the OK button should be allowed. | |
| 89 * @private | |
| 90 */ | |
| 91 isOkAllowed_: function() { | |
| 92 return this.newUrl_.length > 0; | |
|
dschuyler
2016/03/01 03:15:52
Can we re-add the trim() to avoid urls like ' ' an
Dan Beam
2016/03/02 19:56:42
Done.
| |
| 93 }, | |
| 94 | |
| 84 /** @private */ | 95 /** @private */ |
| 85 onOkTap_: function() { | 96 onOkTap_: function() { |
| 86 var value = this.newUrl && this.newUrl.trim(); | 97 assert(this.isOkAllowed_()); |
| 87 if (!value) | 98 chrome.send('addStartupPage', [this.newUrl_]); |
| 88 return; | |
| 89 chrome.send('addStartupPage', [value]); | |
| 90 this.newUrl = ''; | |
| 91 this.$.addUrlDialog.close(); | 99 this.$.addUrlDialog.close(); |
| 92 }, | 100 }, |
| 93 | 101 |
| 94 /** | 102 /** |
| 95 * @param {!{model: !{index: number}}} e | 103 * @param {!{model: !{index: number}}} e |
| 96 * @private | 104 * @private |
| 97 */ | 105 */ |
| 98 onRemoveUrlTap_: function(e) { | 106 onRemoveUrlTap_: function(e) { |
| 99 chrome.send('removeStartupPage', [e.model.index]); | 107 chrome.send('removeStartupPage', [e.model.index]); |
| 100 }, | 108 }, |
| 101 }); | 109 }); |
| OLD | NEW |