Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / chromeos / drive / search_metadata.h
blob2acb281942d7211e01090d49b08272fdd351ee44
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_SEARCH_METADATA_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_SEARCH_METADATA_H_
8 #include <string>
10 #include "chrome/browser/chromeos/drive/file_system_interface.h"
12 namespace base {
13 namespace i18n {
14 class FixedPatternStringSearchIgnoringCaseAndAccents;
15 } // namespace i18n
16 } // namespace base
18 namespace drive {
19 namespace internal {
21 class ResourceMetadata;
23 typedef base::Callback<bool(const ResourceEntry&)> SearchMetadataPredicate;
25 // Searches the local resource metadata, and returns the entries
26 // |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 // on the given |options|, which is a bit-wise OR of SearchMetadataOptions.
29 // |callback| must not be null. Must be called on UI thread. Empty |query|
30 // matches any base name. i.e. returns everything. |blocking_task_runner| must
31 // be the same one as |resource_metadata| uses.
32 void SearchMetadata(
33 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner,
34 ResourceMetadata* resource_metadata,
35 const std::string& query,
36 const SearchMetadataPredicate& predicate,
37 size_t at_most_num_matches,
38 const SearchMetadataCallback& callback);
40 // Returns true if |entry| is eligible for the search |options| and should be
41 // tested for the match with the query. If
42 // SEARCH_METADATA_EXCLUDE_HOSTED_DOCUMENTS is requested, the hosted documents
43 // are skipped. If SEARCH_METADATA_EXCLUDE_DIRECTORIES is requested, the
44 // directories are skipped. If SEARCH_METADATA_SHARED_WITH_ME is requested, only
45 // the entries with shared-with-me label will be tested. If
46 // 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.
48 bool MatchesType(int options, const ResourceEntry& entry);
50 // Finds |query| in |text| while ignoring cases or accents. Cases of non-ASCII
51 // characters are also ignored; they are compared in the 'Primary Level' of
52 // http://userguide.icu-project.org/collation/concepts.
53 // Returns true if |query| is found. |highlighted_text| will have the original
54 // text with matched portions highlighted with <b> tag (only the first match
55 // is highlighted). Meta characters are escaped like &lt;. The original
56 // contents of |highlighted_text| will be lost.
57 bool FindAndHighlight(
58 const std::string& text,
59 base::i18n::FixedPatternStringSearchIgnoringCaseAndAccents* query,
60 std::string* highlighted_text);
62 } // namespace internal
63 } // namespace drive
65 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_SEARCH_METADATA_H_