OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "chrome/browser/chromeos/drive/search_metadata.h" | 5 #include "chrome/browser/chromeos/drive/search_metadata.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <queue> | 8 #include <queue> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 const std::string& query, | 191 const std::string& query, |
192 int options, | 192 int options, |
193 int at_most_num_matches, | 193 int at_most_num_matches, |
194 const SearchMetadataCallback& callback) { | 194 const SearchMetadataCallback& callback) { |
195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
196 DCHECK_LE(0, at_most_num_matches); | 196 DCHECK_LE(0, at_most_num_matches); |
197 DCHECK(!callback.is_null()); | 197 DCHECK(!callback.is_null()); |
198 | 198 |
199 // TODO(hashimoto): Report error code from ResourceMetadata::IterateEntries | 199 // TODO(hashimoto): Report error code from ResourceMetadata::IterateEntries |
200 // and stop binding FILE_ERROR_OK to |callback|. | 200 // and stop binding FILE_ERROR_OK to |callback|. |
201 base::PostTaskAndReplyWithResult( | 201 base::PostTaskAndReplyWithResult(blocking_task_runner.get(), |
202 blocking_task_runner, | 202 FROM_HERE, |
203 FROM_HERE, | 203 base::Bind(&SearchMetadataOnBlockingPool, |
204 base::Bind(&SearchMetadataOnBlockingPool, | 204 resource_metadata, |
205 resource_metadata, | 205 cache, |
206 cache, | 206 query, |
207 query, | 207 options, |
208 options, | 208 at_most_num_matches), |
209 at_most_num_matches), | 209 base::Bind(callback, FILE_ERROR_OK)); |
210 base::Bind(callback, FILE_ERROR_OK)); | |
211 } | 210 } |
212 | 211 |
213 bool FindAndHighlight(const std::string& text, | 212 bool FindAndHighlight(const std::string& text, |
214 const std::string& query, | 213 const std::string& query, |
215 std::string* highlighted_text) { | 214 std::string* highlighted_text) { |
216 DCHECK(highlighted_text); | 215 DCHECK(highlighted_text); |
217 highlighted_text->clear(); | 216 highlighted_text->clear(); |
218 | 217 |
219 // For empty query, any filename matches with no highlighted text. | 218 // For empty query, any filename matches with no highlighted text. |
220 if (query.empty()) | 219 if (query.empty()) |
(...skipping 13 matching lines...) Expand all Loading... |
234 highlighted_text->append(net::EscapeForHTML(UTF16ToUTF8(pre))); | 233 highlighted_text->append(net::EscapeForHTML(UTF16ToUTF8(pre))); |
235 highlighted_text->append("<b>"); | 234 highlighted_text->append("<b>"); |
236 highlighted_text->append(net::EscapeForHTML(UTF16ToUTF8(match))); | 235 highlighted_text->append(net::EscapeForHTML(UTF16ToUTF8(match))); |
237 highlighted_text->append("</b>"); | 236 highlighted_text->append("</b>"); |
238 highlighted_text->append(net::EscapeForHTML(UTF16ToUTF8(post))); | 237 highlighted_text->append(net::EscapeForHTML(UTF16ToUTF8(post))); |
239 return true; | 238 return true; |
240 } | 239 } |
241 | 240 |
242 } // namespace internal | 241 } // namespace internal |
243 } // namespace drive | 242 } // namespace drive |
OLD | NEW |