blob: 39afcf48c203f10a2d764378625e548f2bde4bde [file] [log] [blame]
[email protected]583d46f2012-11-15 03:22:321// 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
lukasza8acc4eb2015-07-20 20:57:205#ifndef COMPONENTS_DRIVE_DRIVE_API_UTIL_H_
6#define COMPONENTS_DRIVE_DRIVE_API_UTIL_H_
[email protected]583d46f2012-11-15 03:22:327
[email protected]002aec6a2013-04-18 15:14:388#include <string>
9
[email protected]71cdf6b2013-08-01 19:20:2910namespace base {
Francois Doray374612f2019-06-27 16:33:3111class AtomicFlag;
[email protected]47494272013-11-07 12:36:4012class FilePath;
[email protected]71cdf6b2013-08-01 19:20:2913} // namespace base
14
[email protected]e50af7652013-06-20 06:39:3115namespace drive {
[email protected]583d46f2012-11-15 03:22:3216namespace util {
17
[email protected]19f13a22014-04-23 08:19:0218// Google Apps MIME types:
19const char kGoogleDocumentMimeType[] = "application/vnd.google-apps.document";
20const char kGoogleDrawingMimeType[] = "application/vnd.google-apps.drawing";
21const char kGooglePresentationMimeType[] =
22 "application/vnd.google-apps.presentation";
23const char kGoogleSpreadsheetMimeType[] =
24 "application/vnd.google-apps.spreadsheet";
25const char kGoogleTableMimeType[] = "application/vnd.google-apps.table";
26const char kGoogleFormMimeType[] = "application/vnd.google-apps.form";
fukino22708902014-11-04 09:00:0727const char kGoogleMapMimeType[] = "application/vnd.google-apps.map";
fukino672cd5a92016-07-01 01:35:0228const char kGoogleSiteMimeType[] = "application/vnd.google-apps.site";
[email protected]19f13a22014-04-23 08:19:0229const char kDriveFolderMimeType[] = "application/vnd.google-apps.folder";
30
[email protected]002aec6a2013-04-18 15:14:3831// 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
34std::string EscapeQueryStringValue(const std::string& str);
35
[email protected]c39ee69e2013-04-19 12:57:2136// 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
44std::string TranslateQuery(const std::string& original_query);
45
[email protected]7b697872013-05-23 16:39:1846// If |resource_id| is in the old resource ID format used by WAPI, converts it
47// into the new format.
48std::string CanonicalizeResourceId(const std::string& resource_id);
49
[email protected]47494272013-11-07 12:36:4050// Returns the (base-16 encoded) MD5 digest of the file content at |file_path|,
51// or an empty string if an error is found.
hashimoto246e4a82015-04-17 07:44:4952std::string GetMd5Digest(const base::FilePath& file_path,
Francois Doray374612f2019-06-27 16:33:3153 const base::AtomicFlag* cancellation_flag);
[email protected]47494272013-11-07 12:36:4054
[email protected]4979eaf02014-07-31 11:34:2055// Returns true if the given mime type is corresponding to one of known hosted
56// document types.
57bool IsKnownHostedDocumentMimeType(const std::string& mime_type);
[email protected]51ed7bd42014-07-14 13:58:2258
[email protected]d8d92532014-07-25 10:06:2659// Returns true if the given file path has an extension corresponding to one of
60// hosted document types.
61bool HasHostedDocumentExtension(const base::FilePath& path);
[email protected]51ed7bd42014-07-14 13:58:2262
[email protected]002aec6a2013-04-18 15:14:3863} // namespace util
64} // namespace drive
[email protected]583d46f2012-11-15 03:22:3265
lukasza8acc4eb2015-07-20 20:57:2066#endif // COMPONENTS_DRIVE_DRIVE_API_UTIL_H_