| 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 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_SEARCH_METADATA_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_SEARCH_METADATA_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_SEARCH_METADATA_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_SEARCH_METADATA_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/browser/chromeos/drive/file_system_interface.h" | 10 #include "chrome/browser/chromeos/drive/file_system_interface.h" |
| 11 | 11 |
| 12 namespace base { | 12 namespace base { |
| 13 namespace i18n { | 13 namespace i18n { |
| 14 class FixedPatternStringSearchIgnoringCaseAndAccents; | 14 class FixedPatternStringSearchIgnoringCaseAndAccents; |
| 15 } // namespace i18n | 15 } // namespace i18n |
| 16 } // namespace base | 16 } // namespace base |
| 17 | 17 |
| 18 namespace drive { | 18 namespace drive { |
| 19 namespace internal { | 19 namespace internal { |
| 20 | 20 |
| 21 class FileCache; | |
| 22 class ResourceMetadata; | 21 class ResourceMetadata; |
| 23 | 22 |
| 24 // Searches the local resource metadata, and returns the entries | 23 // Searches the local resource metadata, and returns the entries |
| 25 // |at_most_num_matches| that contain |query| in their base names. Search is | 24 // |at_most_num_matches| that contain |query| in their base names. Search is |
| 26 // done in a case-insensitive fashion. The eligible entries are selected based | 25 // done in a case-insensitive fashion. The eligible entries are selected based |
| 27 // on the given |options|, which is a bit-wise OR of SearchMetadataOptions. | 26 // on the given |options|, which is a bit-wise OR of SearchMetadataOptions. |
| 28 // |callback| must not be null. Must be called on UI thread. Empty |query| | 27 // |callback| must not be null. Must be called on UI thread. Empty |query| |
| 29 // matches any base name. i.e. returns everything. |blocking_task_runner| must | 28 // matches any base name. i.e. returns everything. |blocking_task_runner| must |
| 30 // be the same one as |resource_metadata| uses. | 29 // be the same one as |resource_metadata| uses. |
| 31 void SearchMetadata( | 30 void SearchMetadata( |
| 32 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, | 31 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, |
| 33 ResourceMetadata* resource_metadata, | 32 ResourceMetadata* resource_metadata, |
| 34 FileCache* cache, | |
| 35 const std::string& query, | 33 const std::string& query, |
| 36 int search_options, | 34 int search_options, |
| 37 int at_most_num_matches, | 35 int at_most_num_matches, |
| 38 const SearchMetadataCallback& callback); | 36 const SearchMetadataCallback& callback); |
| 39 | 37 |
| 40 // Finds |query| in |text| while ignoring cases or accents. Cases of non-ASCII | 38 // Finds |query| in |text| while ignoring cases or accents. Cases of non-ASCII |
| 41 // characters are also ignored; they are compared in the 'Primary Level' of | 39 // characters are also ignored; they are compared in the 'Primary Level' of |
| 42 // http://userguide.icu-project.org/collation/concepts. | 40 // http://userguide.icu-project.org/collation/concepts. |
| 43 // Returns true if |query| is found. |highlighted_text| will have the original | 41 // Returns true if |query| is found. |highlighted_text| will have the original |
| 44 // text with matched portions highlighted with <b> tag (only the first match | 42 // text with matched portions highlighted with <b> tag (only the first match |
| 45 // is highlighted). Meta characters are escaped like <. The original | 43 // is highlighted). Meta characters are escaped like <. The original |
| 46 // contents of |highlighted_text| will be lost. | 44 // contents of |highlighted_text| will be lost. |
| 47 bool FindAndHighlight( | 45 bool FindAndHighlight( |
| 48 const std::string& text, | 46 const std::string& text, |
| 49 base::i18n::FixedPatternStringSearchIgnoringCaseAndAccents* query, | 47 base::i18n::FixedPatternStringSearchIgnoringCaseAndAccents* query, |
| 50 std::string* highlighted_text); | 48 std::string* highlighted_text); |
| 51 | 49 |
| 52 } // namespace internal | 50 } // namespace internal |
| 53 } // namespace drive | 51 } // namespace drive |
| 54 | 52 |
| 55 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_SEARCH_METADATA_H_ | 53 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_SEARCH_METADATA_H_ |
| OLD | NEW |