Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: chrome/browser/resources/md_history/history_toolbar.js

Issue 1643693003: MD History: Implement search functionality. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@patch_to_be_uploaded
Patch Set: Rebase and address reviewer comments. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 Polymer({ 5 Polymer({
6 is: 'history-toolbar', 6 is: 'history-toolbar',
7 properties: { 7 properties: {
8 // Number of history items currently selected. 8 // Number of history items currently selected.
9 count: { 9 count: {
10 type: Number, 10 type: Number,
11 value: 0, 11 value: 0,
12 observer: 'changeToolbarView_' 12 observer: 'changeToolbarView_'
13 }, 13 },
14
14 // True if 1 or more history items are selected. When this value changes 15 // True if 1 or more history items are selected. When this value changes
15 // the background colour changes. 16 // the background colour changes.
16 itemsSelected_: { 17 itemsSelected_: {
17 type: Boolean, 18 type: Boolean,
18 value: false, 19 value: false,
19 reflectToAttribute: true 20 reflectToAttribute: true
21 },
22
23 // The search term associated with the current results shown. Also used to
24 // determine whether results need to be refreshed (i.e. if it changes).
25 searchTerm: {
26 type: String,
27 value: ''
20 } 28 }
21 }, 29 },
22 30
23 /** 31 /**
24 * Changes the toolbar background color depending on whether any history items 32 * Changes the toolbar background color depending on whether any history items
25 * are currently selected. 33 * are currently selected.
26 * @private 34 * @private
27 */ 35 */
28 changeToolbarView_: function() { 36 changeToolbarView_: function() {
29 this.itemsSelected_ = this.count > 0; 37 this.itemsSelected_ = this.count > 0;
30 }, 38 },
31 39
40 /**
41 * If the search term has changed reload for the new search.
42 */
43 onSearchTermSearch: function(searchTerm) {
44 if (searchTerm != this.searchTerm)
45 this.fire('refresh-results', {search: searchTerm});
46 this.searchTerm = searchTerm;
47 },
48
49 attached: function() {
50 this.async(function() {
51 this.searchFieldDelegate_ = new ToolbarSearchFieldDelegate(this);
52 this.$['search-input'].setDelegate(this.searchFieldDelegate_);
53 });
54 },
55
32 onClearSelectionTap_: function() { 56 onClearSelectionTap_: function() {
33 this.fire('unselect-all'); 57 this.fire('unselect-all');
34 }, 58 },
35 59
36 /** 60 /**
37 * Relocates the user to the clear browsing data section of the settings page. 61 * Relocates the user to the clear browsing data section of the settings page.
38 * @private 62 * @private
39 */ 63 */
40 onClearBrowsingDataTap_: function() { 64 onClearBrowsingDataTap_: function() {
41 window.location.href = 'chrome://settings/clearBrowserData'; 65 window.location.href = 'chrome://settings/clearBrowserData';
42 }, 66 },
43 67
44 onDeleteTap_: function() { 68 onDeleteTap_: function() {
45 this.fire('delete-selected'); 69 this.fire('delete-selected');
46 }, 70 },
47 71
48 /** 72 /**
49 * If the user is a supervised user the delete button is not shown. 73 * If the user is a supervised user the delete button is not shown.
50 * @private 74 * @private
51 */ 75 */
52 deletingAllowed_: function() { 76 deletingAllowed_: function() {
53 return loadTimeData.getBoolean('allowDeletingHistory'); 77 return loadTimeData.getBoolean('allowDeletingHistory');
54 }, 78 },
55 79
56 numberOfItemsSelected_: function(count) { 80 numberOfItemsSelected_: function(count) {
57 return count > 0 ? loadTimeData.getStringF('itemsSelected', count) : ''; 81 return count > 0 ? loadTimeData.getStringF('itemsSelected', count) : '';
58 } 82 }
59 }); 83 });
84
85 /**
86 * @constructor
87 * @implements {SearchFieldDelegate}
88 * @param {!Object} toolbar This history-toolbar.
89 */
90 function ToolbarSearchFieldDelegate(toolbar) {
91 this.toolbar_ = toolbar;
92 }
93
94 ToolbarSearchFieldDelegate.prototype = {
95 /** @override */
96 onSearchTermSearch: function(searchTerm) {
97 this.toolbar_.onSearchTermSearch(searchTerm);
98 }
99 };
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_history/history_list.js ('k') | chrome/browser/ui/webui/md_history_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698