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 * Provides drive search results to chrome launcher. | 6 * Provides drive search results to chrome launcher. |
7 * @constructor | 7 * @constructor |
8 * @struct | 8 * @struct |
9 */ | 9 */ |
10 function LauncherSearch() { | 10 function LauncherSearch() { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 types: 'ALL', | 111 types: 'ALL', |
112 maxResults: limit | 112 maxResults: limit |
113 }, function(results) { | 113 }, function(results) { |
114 // If query is already changed, discard the results. | 114 // If query is already changed, discard the results. |
115 if (queryId !== this.queryId_ || results.length === 0) | 115 if (queryId !== this.queryId_ || results.length === 0) |
116 return; | 116 return; |
117 | 117 |
118 chrome.launcherSearchProvider.setSearchResults( | 118 chrome.launcherSearchProvider.setSearchResults( |
119 queryId, | 119 queryId, |
120 results.map(function(result) { | 120 results.map(function(result) { |
121 // TODO(yawano): Set custome icon to a result when the API becomes | 121 // Use high-dpi icons since preferred icon size is 24px in the |
122 // to support it. | 122 // current implementation. |
| 123 // |
| 124 // TODO(yawano): Use filetype_folder_shared.png for a shared |
| 125 // folder. |
| 126 var iconUrl = chrome.runtime.getURL( |
| 127 'foreground/images/filetype/2x/filetype_' + |
| 128 FileType.getIcon(result.entry) + '.png'); |
123 return { | 129 return { |
124 itemId: result.entry.toURL(), | 130 itemId: result.entry.toURL(), |
125 title: result.entry.name, | 131 title: result.entry.name, |
| 132 iconUrl: iconUrl, |
126 // Relevance is set as 2 for all results as a temporary | 133 // Relevance is set as 2 for all results as a temporary |
127 // implementation. 2 is the middle value. | 134 // implementation. 2 is the middle value. |
128 // TODO(yawano): Implement practical relevance calculation. | 135 // TODO(yawano): Implement practical relevance calculation. |
129 relevance: 2 | 136 relevance: 2 |
130 }; | 137 }; |
131 })); | 138 })); |
132 }.bind(this)); | 139 }.bind(this)); |
133 }; | 140 }; |
134 | 141 |
135 /** | 142 /** |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 * @param {string} selectionURL A url to be selected. | 211 * @param {string} selectionURL A url to be selected. |
205 * @private | 212 * @private |
206 */ | 213 */ |
207 LauncherSearch.prototype.openFileManagerWithSelectionURL_ = function( | 214 LauncherSearch.prototype.openFileManagerWithSelectionURL_ = function( |
208 selectionURL) { | 215 selectionURL) { |
209 launchFileManager( | 216 launchFileManager( |
210 { selectionURL: selectionURL }, | 217 { selectionURL: selectionURL }, |
211 undefined, /* App ID */ | 218 undefined, /* App ID */ |
212 LaunchType.FOCUS_SAME_OR_CREATE); | 219 LaunchType.FOCUS_SAME_OR_CREATE); |
213 }; | 220 }; |
OLD | NEW |