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

Side by Side Diff: components/drive/search_metadata.h

Issue 1321553003: Files.app: split query into AND conditioned keywords in metadata search. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Empty query matches with anything. Created 5 years, 3 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
« no previous file with comments | « no previous file | components/drive/search_metadata.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 COMPONENTS_DRIVE_SEARCH_METADATA_H_ 5 #ifndef COMPONENTS_DRIVE_SEARCH_METADATA_H_
6 #define COMPONENTS_DRIVE_SEARCH_METADATA_H_ 6 #define COMPONENTS_DRIVE_SEARCH_METADATA_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_vector.h"
10 #include "components/drive/file_system_interface.h" 11 #include "components/drive/file_system_interface.h"
11 12
12 namespace base { 13 namespace base {
13 namespace i18n { 14 namespace i18n {
14 class FixedPatternStringSearchIgnoringCaseAndAccents; 15 class FixedPatternStringSearchIgnoringCaseAndAccents;
15 } // namespace i18n 16 } // namespace i18n
16 } // namespace base 17 } // namespace base
17 18
18 namespace drive { 19 namespace drive {
19 namespace internal { 20 namespace internal {
20 21
21 class ResourceMetadata; 22 class ResourceMetadata;
22 23
23 typedef base::Callback<bool(const ResourceEntry&)> SearchMetadataPredicate; 24 typedef base::Callback<bool(const ResourceEntry&)> SearchMetadataPredicate;
24 25
25 // Searches the local resource metadata, and returns the entries 26 // Searches the local resource metadata, and returns the entries
26 // |at_most_num_matches| that contain |query| in their base names. Search is 27 // |at_most_num_matches| that contain |query| in their base names. Search is
27 // done in a case-insensitive fashion. The eligible entries are selected based 28 // done in a case-insensitive fashion. |query| is splitted into keywords by
28 // on the given |options|, which is a bit-wise OR of SearchMetadataOptions. 29 // whitespace. All keywords are considered as AND condition. The eligible
29 // |callback| must not be null. Must be called on UI thread. Empty |query| 30 // entries are selected based on the given |options|, which is a bit-wise OR of
30 // matches any base name. i.e. returns everything. |blocking_task_runner| must 31 // SearchMetadataOptions. |callback| must not be null. Must be called on UI
31 // be the same one as |resource_metadata| uses. 32 // thread. Empty |query| matches any base name. i.e. returns everything.
33 // |blocking_task_runner| must be the same one as |resource_metadata| uses.
32 void SearchMetadata( 34 void SearchMetadata(
33 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, 35 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner,
34 ResourceMetadata* resource_metadata, 36 ResourceMetadata* resource_metadata,
35 const std::string& query, 37 const std::string& query,
36 const SearchMetadataPredicate& predicate, 38 const SearchMetadataPredicate& predicate,
37 size_t at_most_num_matches, 39 size_t at_most_num_matches,
38 const SearchMetadataCallback& callback); 40 const SearchMetadataCallback& callback);
39 41
40 // Returns true if |entry| is eligible for the search |options| and should be 42 // Returns true if |entry| is eligible for the search |options| and should be
41 // tested for the match with the query. If 43 // tested for the match with the query. If
42 // SEARCH_METADATA_EXCLUDE_HOSTED_DOCUMENTS is requested, the hosted documents 44 // SEARCH_METADATA_EXCLUDE_HOSTED_DOCUMENTS is requested, the hosted documents
43 // are skipped. If SEARCH_METADATA_EXCLUDE_DIRECTORIES is requested, the 45 // are skipped. If SEARCH_METADATA_EXCLUDE_DIRECTORIES is requested, the
44 // directories are skipped. If SEARCH_METADATA_SHARED_WITH_ME is requested, only 46 // directories are skipped. If SEARCH_METADATA_SHARED_WITH_ME is requested, only
45 // the entries with shared-with-me label will be tested. If 47 // the entries with shared-with-me label will be tested. If
46 // SEARCH_METADATA_OFFLINE is requested, only hosted documents and cached files 48 // SEARCH_METADATA_OFFLINE is requested, only hosted documents and cached files
47 // match with the query. This option can not be used with other options. 49 // match with the query. This option can not be used with other options.
48 bool MatchesType(int options, const ResourceEntry& entry); 50 bool MatchesType(int options, const ResourceEntry& entry);
49 51
50 // Finds |query| in |text| while ignoring cases or accents. Cases of non-ASCII 52 // Finds |queries| in |text| while ignoring cases or accents. Cases of non-ASCII
51 // characters are also ignored; they are compared in the 'Primary Level' of 53 // characters are also ignored; they are compared in the 'Primary Level' of
52 // http://userguide.icu-project.org/collation/concepts. 54 // http://userguide.icu-project.org/collation/concepts.
53 // Returns true if |query| is found. |highlighted_text| will have the original 55 // Returns true if |queries| are found. |highlighted_text| will have the
56 // original
54 // text with matched portions highlighted with <b> tag (only the first match 57 // text with matched portions highlighted with <b> tag (only the first match
55 // is highlighted). Meta characters are escaped like &lt;. The original 58 // is highlighted). Meta characters are escaped like &lt;. The original
56 // contents of |highlighted_text| will be lost. 59 // contents of |highlighted_text| will be lost.
57 bool FindAndHighlight( 60 bool FindAndHighlight(
58 const std::string& text, 61 const std::string& text,
59 base::i18n::FixedPatternStringSearchIgnoringCaseAndAccents* query, 62 const ScopedVector<
63 base::i18n::FixedPatternStringSearchIgnoringCaseAndAccents>& queries,
60 std::string* highlighted_text); 64 std::string* highlighted_text);
61 65
62 } // namespace internal 66 } // namespace internal
63 } // namespace drive 67 } // namespace drive
64 68
65 #endif // COMPONENTS_DRIVE_SEARCH_METADATA_H_ 69 #endif // COMPONENTS_DRIVE_SEARCH_METADATA_H_
OLDNEW
« no previous file with comments | « no previous file | components/drive/search_metadata.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698