OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 Polymer({ | 5 Polymer({ |
6 is: 'history-app', | 6 is: 'history-app', |
7 | 7 |
8 properties: { | 8 properties: { |
9 // The id of the currently selected page. | 9 // The id of the currently selected page. |
10 selectedPage_: {type: String, value: 'history', observer: 'unselectAll'}, | 10 selectedPage_: {type: String, value: 'history', observer: 'unselectAll'}, |
(...skipping 29 matching lines...) Expand all Loading... | |
40 'cr-menu-tap': 'onMenuTap_', | 40 'cr-menu-tap': 'onMenuTap_', |
41 'history-checkbox-select': 'checkboxSelected', | 41 'history-checkbox-select': 'checkboxSelected', |
42 'unselect-all': 'unselectAll', | 42 'unselect-all': 'unselectAll', |
43 'delete-selected': 'deleteSelected', | 43 'delete-selected': 'deleteSelected', |
44 'search-domain': 'searchDomain_', | 44 'search-domain': 'searchDomain_', |
45 }, | 45 }, |
46 | 46 |
47 /** @override */ | 47 /** @override */ |
48 ready: function() { | 48 ready: function() { |
49 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); | 49 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); |
50 | |
51 cr.ui.decorate('command', cr.ui.Command); | |
52 document.addEventListener('canExecute', this.onCanExecute_.bind(this)); | |
53 document.addEventListener('command', this.onCommand_.bind(this)); | |
50 }, | 54 }, |
51 | 55 |
52 /** @private */ | 56 /** @private */ |
53 onMenuTap_: function() { this.$['side-bar'].toggle(); }, | 57 onMenuTap_: function() { this.$['side-bar'].toggle(); }, |
54 | 58 |
55 /** | 59 /** |
56 * Listens for history-item being selected or deselected (through checkbox) | 60 * Listens for history-item being selected or deselected (through checkbox) |
57 * and changes the view of the top toolbar. | 61 * and changes the view of the top toolbar. |
58 * @param {{detail: {countAddition: number}}} e | 62 * @param {{detail: {countAddition: number}}} e |
59 */ | 63 */ |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 listContainer.historyResult(info, results); | 105 listContainer.historyResult(info, results); |
102 }, | 106 }, |
103 | 107 |
104 /** | 108 /** |
105 * Fired when the user presses 'More from this site'. | 109 * Fired when the user presses 'More from this site'. |
106 * @param {{detail: {domain: string}}} e | 110 * @param {{detail: {domain: string}}} e |
107 */ | 111 */ |
108 searchDomain_: function(e) { this.$.toolbar.setSearchTerm(e.detail.domain); }, | 112 searchDomain_: function(e) { this.$.toolbar.setSearchTerm(e.detail.domain); }, |
109 | 113 |
110 /** | 114 /** |
115 * @param {Event} e | |
tsergeant
2016/07/05 07:47:22
Does the closure compile work successfully if you
lshang
2016/07/06 05:03:08
Seems closure compiler can't recognize cr.ui.CanEx
| |
116 * @private | |
117 */ | |
118 onCanExecute_: function(e) { | |
119 e = /** @type {cr.ui.CanExecuteEvent} */(e); | |
120 switch (e.command.id) { | |
tsergeant
2016/07/05 07:47:22
I think there's no need to have the switch here, y
lshang
2016/07/06 05:03:08
Done.
| |
121 case 'find-command': | |
122 e.canExecute = true; | |
123 break; | |
124 } | |
125 }, | |
126 | |
127 /** | |
128 * @param {Event} e | |
129 * @private | |
130 */ | |
131 onCommand_: function(e) { | |
132 e = /** @type {cr.ui.CanExecuteEvent} */(e); | |
133 if (e.command.id == 'find-command') | |
134 this.$.toolbar.onFindCommand(); | |
135 }, | |
136 | |
137 /** | |
111 * @param {!Array<!ForeignSession>} sessionList Array of objects describing | 138 * @param {!Array<!ForeignSession>} sessionList Array of objects describing |
112 * the sessions from other devices. | 139 * the sessions from other devices. |
113 * @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile? | 140 * @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile? |
114 */ | 141 */ |
115 setForeignSessions: function(sessionList, isTabSyncEnabled) { | 142 setForeignSessions: function(sessionList, isTabSyncEnabled) { |
116 if (!isTabSyncEnabled) | 143 if (!isTabSyncEnabled) |
117 return; | 144 return; |
118 | 145 |
119 this.sessionList = sessionList; | 146 this.sessionList = sessionList; |
120 }, | 147 }, |
(...skipping 23 matching lines...) Expand all Loading... | |
144 * @param {boolean} incremental | 171 * @param {boolean} incremental |
145 * @param {string} searchTerm | 172 * @param {string} searchTerm |
146 * @return {boolean} Whether a loading spinner should be shown (implies the | 173 * @return {boolean} Whether a loading spinner should be shown (implies the |
147 * backend is querying a new search term). | 174 * backend is querying a new search term). |
148 * @private | 175 * @private |
149 */ | 176 */ |
150 shouldShowSpinner_: function(querying, incremental, searchTerm) { | 177 shouldShowSpinner_: function(querying, incremental, searchTerm) { |
151 return querying && !incremental && searchTerm != ''; | 178 return querying && !incremental && searchTerm != ''; |
152 }, | 179 }, |
153 }); | 180 }); |
OLD | NEW |