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.
5 #ifndef COMPONENTS_DRIVE_DRIVE_API_UTIL_H_
6 #define COMPONENTS_DRIVE_DRIVE_API_UTIL_H_
11 #include "base/memory/scoped_ptr.h"
12 #include "google_apis/drive/drive_api_error_codes.h"
13 #include "google_apis/drive/drive_common_callbacks.h"
18 class CancellationFlag
;
23 namespace google_apis
{
29 } // namespace google_apis
34 // Google Apps MIME types:
35 const char kGoogleDocumentMimeType
[] = "application/vnd.google-apps.document";
36 const char kGoogleDrawingMimeType
[] = "application/vnd.google-apps.drawing";
37 const char kGooglePresentationMimeType
[] =
38 "application/vnd.google-apps.presentation";
39 const char kGoogleSpreadsheetMimeType
[] =
40 "application/vnd.google-apps.spreadsheet";
41 const char kGoogleTableMimeType
[] = "application/vnd.google-apps.table";
42 const char kGoogleFormMimeType
[] = "application/vnd.google-apps.form";
43 const char kGoogleMapMimeType
[] = "application/vnd.google-apps.map";
44 const char kDriveFolderMimeType
[] = "application/vnd.google-apps.folder";
46 // Escapes ' to \' in the |str|. This is designed to use for string value of
47 // search parameter on Drive API v2.
48 // See also: https://developers.google.com/drive/search-parameters
49 std::string
EscapeQueryStringValue(const std::string
& str
);
51 // Parses the query, and builds a search query for Drive API v2.
52 // This only supports:
53 // Regular query (e.g. dog => fullText contains 'dog')
55 // (e.g. dog cat => fullText contains 'dog' and fullText contains 'cat')
56 // Exclusion query (e.g. -cat => not fullText contains 'cat').
57 // Quoted query (e.g. "dog cat" => fullText contains 'dog cat').
58 // See also: https://developers.google.com/drive/search-parameters
59 std::string
TranslateQuery(const std::string
& original_query
);
61 // If |resource_id| is in the old resource ID format used by WAPI, converts it
62 // into the new format.
63 std::string
CanonicalizeResourceId(const std::string
& resource_id
);
65 // Returns the (base-16 encoded) MD5 digest of the file content at |file_path|,
66 // or an empty string if an error is found.
67 std::string
GetMd5Digest(const base::FilePath
& file_path
,
68 const base::CancellationFlag
* cancellation_flag
);
70 // Returns preferred file extension for hosted documents which have given mime
72 std::string
GetHostedDocumentExtension(const std::string
& mime_type
);
74 // Returns true if the given mime type is corresponding to one of known hosted
76 bool IsKnownHostedDocumentMimeType(const std::string
& mime_type
);
78 // Returns true if the given file path has an extension corresponding to one of
79 // hosted document types.
80 bool HasHostedDocumentExtension(const base::FilePath
& path
);
85 #endif // COMPONENTS_DRIVE_DRIVE_API_UTIL_H_