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 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "chrome/browser/chromeos/drive/drive_file_system_interface.h" | 11 #include "chrome/browser/chromeos/drive/drive_file_system_interface.h" |
12 | 12 |
13 namespace drive { | 13 namespace drive { |
14 | 14 |
15 // Struct to represent a search result for SearchMetadata(). | 15 // Struct to represent a search result for SearchMetadata(). |
16 struct MetadataSearchResult { | 16 struct MetadataSearchResult { |
17 MetadataSearchResult(const base::FilePath& in_path, | 17 MetadataSearchResult(const base::FilePath& in_path, |
18 const DriveEntryProto& in_entry_proto, | 18 const DriveEntryProto& in_entry_proto, |
19 const std::string& in_highlighted_base_name) | 19 const std::string& in_highlighted_base_name) |
20 : path(in_path), | 20 : path(in_path), |
21 entry_proto(in_entry_proto), | 21 entry_proto(in_entry_proto), |
22 highlighted_base_name(in_highlighted_base_name) { | 22 highlighted_base_name(in_highlighted_base_name) { |
23 } | 23 } |
24 | 24 |
25 // The two members are used to create FileEntry object. | 25 // The two members are used to create FileEntry object. |
26 base::FilePath path; | 26 base::FilePath path; |
27 DriveEntryProto entry_proto; | 27 DriveEntryProto entry_proto; |
28 | 28 |
29 // The base name to be displayed in the UI. The parts matched the search | 29 // The base name to be displayed in the UI. The parts matched the search |
30 // query are highlited with <b> tag. Meta characters are escaped like < | 30 // query are highlighted with <b> tag. Meta characters are escaped like < |
31 // | 31 // |
32 // Why HTML? we could instead provide matched ranges using pairs of | 32 // Why HTML? we could instead provide matched ranges using pairs of |
33 // integers, but this is fragile as we'll eventually converting strings | 33 // integers, but this is fragile as we'll eventually converting strings |
34 // from UTF-8 (StringValue in base/values.h uses std::string) to UTF-16 | 34 // from UTF-8 (StringValue in base/values.h uses std::string) to UTF-16 |
35 // when sending strings from C++ to JavaSCript. | 35 // when sending strings from C++ to JavaScript. |
36 // | 36 // |
37 // Why <b> instead of <strong>? Because <b> is shorter. | 37 // Why <b> instead of <strong>? Because <b> is shorter. |
38 std::string highlighted_base_name; | 38 std::string highlighted_base_name; |
39 }; | 39 }; |
40 | 40 |
41 typedef std::vector<MetadataSearchResult> MetadataSearchResultVector; | 41 typedef std::vector<MetadataSearchResult> MetadataSearchResultVector; |
42 | 42 |
43 // Callback for SearchMetadata(). On success, |error| is DRIVE_FILE_OK, and | 43 // Callback for SearchMetadata(). On success, |error| is DRIVE_FILE_OK, and |
44 // |result| contains the search result. | 44 // |result| contains the search result. |
45 typedef base::Callback<void( | 45 typedef base::Callback<void( |
(...skipping 14 matching lines...) Expand all Loading... |
60 // will have the original text with matched portions highlighted with <b> tag | 60 // will have the original text with matched portions highlighted with <b> tag |
61 // (multiple portions can be highlighted). Meta characters are escaped like | 61 // (multiple portions can be highlighted). Meta characters are escaped like |
62 // <. The original contents of |highlighted| will be lost. | 62 // <. The original contents of |highlighted| will be lost. |
63 bool FindAndHighlight(const std::string& text, | 63 bool FindAndHighlight(const std::string& text, |
64 const std::string& query, | 64 const std::string& query, |
65 std::string* highlighted_text); | 65 std::string* highlighted_text); |
66 | 66 |
67 } // namespace drive | 67 } // namespace drive |
68 | 68 |
69 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_SEARCH_METADATA_H_ | 69 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_SEARCH_METADATA_H_ |
OLD | NEW |