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 'settings-startup-urls-page' is the settings page | 6 * @fileoverview '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 | 9 |
10 /** | |
11 * @typedef {{ | |
12 * title: string, | |
13 * tooltip: string, | |
14 * url: string | |
15 * }} | |
16 */ | |
17 var StartupPageInfo; | |
18 | |
19 Polymer({ | 10 Polymer({ |
20 is: 'settings-startup-urls-page', | 11 is: 'settings-startup-urls-page', |
21 | 12 |
22 behaviors: [WebUIListenerBehavior], | 13 behaviors: [WebUIListenerBehavior], |
23 | 14 |
24 properties: { | 15 properties: { |
25 /** @type {settings.StartupUrlsPageBrowserProxy} */ | 16 /** @type {settings.StartupUrlsPageBrowserProxy} */ |
26 browserProxy_: Object, | 17 browserProxy_: Object, |
27 | 18 |
28 /** | 19 /** |
29 * Pages to load upon browser startup. | 20 * Pages to load upon browser startup. |
30 * @private {!Array<!StartupPageInfo>} | 21 * @private {!Array<!StartupPageInfo>} |
31 */ | 22 */ |
32 startupPages_: Array, | 23 startupPages_: Array, |
33 | 24 |
34 showStartupUrlDialog_: Boolean, | 25 showStartupUrlDialog_: Boolean, |
35 }, | 26 }, |
36 | 27 |
37 /** @override */ | 28 /** @override */ |
38 attached: function() { | 29 attached: function() { |
39 this.browserProxy_ = settings.StartupUrlsPageBrowserProxyImpl.getInstance(); | 30 this.browserProxy_ = settings.StartupUrlsPageBrowserProxyImpl.getInstance(); |
40 this.addWebUIListener('update-startup-pages', function(startupPages) { | 31 this.addWebUIListener('update-startup-pages', function(startupPages) { |
41 this.startupPages_ = startupPages; | 32 this.startupPages_ = startupPages; |
42 }.bind(this)); | 33 }.bind(this)); |
43 this.browserProxy_.loadStartupPages(); | 34 this.browserProxy_.loadStartupPages(); |
44 }, | 35 }, |
45 | 36 |
46 /** | 37 /** |
47 * @param {string} url Location of an image to get a set of icons fors. | |
48 * @return {string} A set of icon URLs. | |
49 * @private | |
50 */ | |
51 getIconSet_: function(url) { | |
52 return getFaviconImageSet(url); | |
53 }, | |
54 | |
55 /** | |
56 * Opens the dialog and registers a listener for removing the dialog from the | 38 * Opens the dialog and registers a listener for removing the dialog from the |
57 * DOM once is closed. The listener is destroyed when the dialog is removed | 39 * DOM once is closed. The listener is destroyed when the dialog is removed |
58 * (because of 'restamp'). | 40 * (because of 'restamp'). |
59 * @private | 41 * @private |
60 */ | 42 */ |
61 onAddPageTap_: function() { | 43 onAddPageTap_: function() { |
62 this.showStartupUrlDialog_ = true; | 44 this.showStartupUrlDialog_ = true; |
63 this.async(function() { | 45 this.async(function() { |
64 var dialog = this.$$('settings-startup-url-dialog'); | 46 var dialog = this.$$('settings-startup-url-dialog'); |
65 dialog.addEventListener('iron-overlay-closed', function() { | 47 dialog.addEventListener('iron-overlay-closed', function() { |
66 this.showStartupUrlDialog_ = false; | 48 this.showStartupUrlDialog_ = false; |
67 }.bind(this)); | 49 }.bind(this)); |
68 }.bind(this)); | 50 }.bind(this)); |
69 }, | 51 }, |
70 | 52 |
71 /** @private */ | 53 /** @private */ |
72 onUseCurrentPagesTap_: function() { | 54 onUseCurrentPagesTap_: function() { |
73 this.browserProxy_.useCurrentPages(); | 55 this.browserProxy_.useCurrentPages(); |
74 }, | 56 }, |
75 | |
76 /** | |
77 * @param {!{model: !{index: number}}} e | |
78 * @private | |
79 */ | |
80 onRemoveUrlTap_: function(e) { | |
81 this.browserProxy_.removeStartupPage(e.model.index); | |
82 }, | |
83 }); | 57 }); |
OLD | NEW |