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

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

Issue 2068613002: [MD History] Add URL parameter for search. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@routing
Patch Set: Created 4 years, 6 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 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 /** 5 /**
6 * @typedef {{device: string, 6 * @typedef {{device: string,
7 * lastUpdateTime: string, 7 * lastUpdateTime: string,
8 * separatorIndexes: !Array<number>, 8 * separatorIndexes: !Array<number>,
9 * timestamp: number, 9 * timestamp: number,
10 * tabs: !Array<!ForeignSessionTab>, 10 * tabs: !Array<!ForeignSessionTab>,
11 * tag: string}} 11 * tag: string}}
12 */ 12 */
13 var ForeignDeviceInternal; 13 var ForeignDeviceInternal;
14 14
15 Polymer({ 15 Polymer({
16 is: 'history-synced-device-manager', 16 is: 'history-synced-device-manager',
17 17
18 properties: { 18 properties: {
19 /** 19 /**
20 * @type {?Array<!ForeignSession>} 20 * @type {?Array<!ForeignSession>}
21 */ 21 */
22 sessionList: { 22 sessionList: {
23 type: Array, 23 type: Array,
24 observer: 'updateSyncedDevices' 24 observer: 'updateSyncedDevices'
25 }, 25 },
26 26
27 searchedTerm: { 27 searchTerm: {
28 type: String, 28 type: String,
29 observer: 'searchTermChanged' 29 observer: 'searchTermChanged'
30 }, 30 },
31 31
32 /** 32 /**
33 * An array of synced devices with synced tab data. 33 * An array of synced devices with synced tab data.
34 * @type {!Array<!ForeignDeviceInternal>} 34 * @type {!Array<!ForeignDeviceInternal>}
35 */ 35 */
36 syncedDevices_: { 36 syncedDevices_: {
37 type: Array, 37 type: Array,
38 value: function() { return []; } 38 value: function() { return []; }
39 } 39 }
40 }, 40 },
41 41
42 /** 42 /**
43 * @param {!ForeignSession} session 43 * @param {!ForeignSession} session
44 * @return {!ForeignDeviceInternal} 44 * @return {!ForeignDeviceInternal}
45 */ 45 */
46 createInternalDevice_: function(session) { 46 createInternalDevice_: function(session) {
47 var tabs = []; 47 var tabs = [];
48 var separatorIndexes = []; 48 var separatorIndexes = [];
49 for (var i = 0; i < session.windows.length; i++) { 49 for (var i = 0; i < session.windows.length; i++) {
50 var newTabs = session.windows[i].tabs; 50 var newTabs = session.windows[i].tabs;
51 if (newTabs.length == 0) 51 if (newTabs.length == 0)
52 continue; 52 continue;
53 53
54 54
55 if (!this.searchedTerm) { 55 if (!this.searchTerm) {
56 // Add all the tabs if there is no search term. 56 // Add all the tabs if there is no search term.
57 tabs = tabs.concat(newTabs); 57 tabs = tabs.concat(newTabs);
58 separatorIndexes.push(tabs.length - 1); 58 separatorIndexes.push(tabs.length - 1);
59 } else { 59 } else {
60 var searchText = this.searchedTerm.toLowerCase(); 60 var searchText = this.searchTerm.toLowerCase();
61 var windowAdded = false; 61 var windowAdded = false;
62 for (var j = 0; j < newTabs.length; j++) { 62 for (var j = 0; j < newTabs.length; j++) {
63 var tab = newTabs[j]; 63 var tab = newTabs[j];
64 if (tab.title.toLowerCase().indexOf(searchText) != -1) { 64 if (tab.title.toLowerCase().indexOf(searchText) != -1) {
65 tabs.push(tab); 65 tabs.push(tab);
66 windowAdded = true; 66 windowAdded = true;
67 } 67 }
68 } 68 }
69 if (windowAdded) 69 if (windowAdded)
70 separatorIndexes.push(tabs.length - 1); 70 separatorIndexes.push(tabs.length - 1);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 'syncedDevices_', i, 1, this.createInternalDevice_(sessionList[i])); 103 'syncedDevices_', i, 1, this.createInternalDevice_(sessionList[i]));
104 } 104 }
105 } 105 }
106 106
107 // Then, append any new devices. 107 // Then, append any new devices.
108 for (var i = updateCount; i < sessionList.length; i++) { 108 for (var i = updateCount; i < sessionList.length; i++) {
109 this.push('syncedDevices_', this.createInternalDevice_(sessionList[i])); 109 this.push('syncedDevices_', this.createInternalDevice_(sessionList[i]));
110 } 110 }
111 }, 111 },
112 112
113 searchTermChanged: function(searchedTerm) { 113 searchTermChanged: function(searchTerm) {
114 this.syncedDevices_ = []; 114 this.syncedDevices_ = [];
115 this.updateSyncedDevices(this.sessionList); 115 this.updateSyncedDevices(this.sessionList);
116 } 116 }
117 }); 117 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698