[email protected] | 583d46f | 2012-11-15 03:22:32 | [diff] [blame] | 1 | // Copyright (c) 2012 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. | ||||
4 | |||||
lukasza | 8acc4eb | 2015-07-20 20:57:20 | [diff] [blame] | 5 | #ifndef COMPONENTS_DRIVE_DRIVE_API_UTIL_H_ |
6 | #define COMPONENTS_DRIVE_DRIVE_API_UTIL_H_ | ||||
[email protected] | 583d46f | 2012-11-15 03:22:32 | [diff] [blame] | 7 | |
[email protected] | 002aec6a | 2013-04-18 15:14:38 | [diff] [blame] | 8 | #include <string> |
9 | |||||
[email protected] | 71cdf6b | 2013-08-01 19:20:29 | [diff] [blame] | 10 | namespace base { |
Francois Doray | 374612f | 2019-06-27 16:33:31 | [diff] [blame] | 11 | class AtomicFlag; |
[email protected] | 4749427 | 2013-11-07 12:36:40 | [diff] [blame] | 12 | class FilePath; |
[email protected] | 71cdf6b | 2013-08-01 19:20:29 | [diff] [blame] | 13 | } // namespace base |
14 | |||||
[email protected] | e50af765 | 2013-06-20 06:39:31 | [diff] [blame] | 15 | namespace drive { |
[email protected] | 583d46f | 2012-11-15 03:22:32 | [diff] [blame] | 16 | namespace util { |
17 | |||||
[email protected] | 19f13a2 | 2014-04-23 08:19:02 | [diff] [blame] | 18 | // Google Apps MIME types: |
19 | const char kGoogleDocumentMimeType[] = "application/vnd.google-apps.document"; | ||||
20 | const char kGoogleDrawingMimeType[] = "application/vnd.google-apps.drawing"; | ||||
21 | const char kGooglePresentationMimeType[] = | ||||
22 | "application/vnd.google-apps.presentation"; | ||||
23 | const char kGoogleSpreadsheetMimeType[] = | ||||
24 | "application/vnd.google-apps.spreadsheet"; | ||||
25 | const char kGoogleTableMimeType[] = "application/vnd.google-apps.table"; | ||||
26 | const char kGoogleFormMimeType[] = "application/vnd.google-apps.form"; | ||||
fukino | 2270890 | 2014-11-04 09:00:07 | [diff] [blame] | 27 | const char kGoogleMapMimeType[] = "application/vnd.google-apps.map"; |
fukino | 672cd5a9 | 2016-07-01 01:35:02 | [diff] [blame] | 28 | const char kGoogleSiteMimeType[] = "application/vnd.google-apps.site"; |
[email protected] | 19f13a2 | 2014-04-23 08:19:02 | [diff] [blame] | 29 | const char kDriveFolderMimeType[] = "application/vnd.google-apps.folder"; |
30 | |||||
[email protected] | 002aec6a | 2013-04-18 15:14:38 | [diff] [blame] | 31 | // Escapes ' to \' in the |str|. This is designed to use for string value of |
32 | // search parameter on Drive API v2. | ||||
33 | // See also: https://developers.google.com/drive/search-parameters | ||||
34 | std::string EscapeQueryStringValue(const std::string& str); | ||||
35 | |||||
[email protected] | c39ee69e | 2013-04-19 12:57:21 | [diff] [blame] | 36 | // Parses the query, and builds a search query for Drive API v2. |
37 | // This only supports: | ||||
38 | // Regular query (e.g. dog => fullText contains 'dog') | ||||
39 | // Conjunctions | ||||
40 | // (e.g. dog cat => fullText contains 'dog' and fullText contains 'cat') | ||||
41 | // Exclusion query (e.g. -cat => not fullText contains 'cat'). | ||||
42 | // Quoted query (e.g. "dog cat" => fullText contains 'dog cat'). | ||||
43 | // See also: https://developers.google.com/drive/search-parameters | ||||
44 | std::string TranslateQuery(const std::string& original_query); | ||||
45 | |||||
[email protected] | 7b69787 | 2013-05-23 16:39:18 | [diff] [blame] | 46 | // If |resource_id| is in the old resource ID format used by WAPI, converts it |
47 | // into the new format. | ||||
48 | std::string CanonicalizeResourceId(const std::string& resource_id); | ||||
49 | |||||
[email protected] | 4749427 | 2013-11-07 12:36:40 | [diff] [blame] | 50 | // Returns the (base-16 encoded) MD5 digest of the file content at |file_path|, |
51 | // or an empty string if an error is found. | ||||
hashimoto | 246e4a8 | 2015-04-17 07:44:49 | [diff] [blame] | 52 | std::string GetMd5Digest(const base::FilePath& file_path, |
Francois Doray | 374612f | 2019-06-27 16:33:31 | [diff] [blame] | 53 | const base::AtomicFlag* cancellation_flag); |
[email protected] | 4749427 | 2013-11-07 12:36:40 | [diff] [blame] | 54 | |
[email protected] | 4979eaf0 | 2014-07-31 11:34:20 | [diff] [blame] | 55 | // Returns true if the given mime type is corresponding to one of known hosted |
56 | // document types. | ||||
57 | bool IsKnownHostedDocumentMimeType(const std::string& mime_type); | ||||
[email protected] | 51ed7bd4 | 2014-07-14 13:58:22 | [diff] [blame] | 58 | |
[email protected] | d8d9253 | 2014-07-25 10:06:26 | [diff] [blame] | 59 | // Returns true if the given file path has an extension corresponding to one of |
60 | // hosted document types. | ||||
61 | bool HasHostedDocumentExtension(const base::FilePath& path); | ||||
[email protected] | 51ed7bd4 | 2014-07-14 13:58:22 | [diff] [blame] | 62 | |
[email protected] | 002aec6a | 2013-04-18 15:14:38 | [diff] [blame] | 63 | } // namespace util |
64 | } // namespace drive | ||||
[email protected] | 583d46f | 2012-11-15 03:22:32 | [diff] [blame] | 65 | |
lukasza | 8acc4eb | 2015-07-20 20:57:20 | [diff] [blame] | 66 | #endif // COMPONENTS_DRIVE_DRIVE_API_UTIL_H_ |