| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_DRIVE_DRIVE_API_UTIL_H_ | 5 #ifndef CHROME_BROWSER_DRIVE_DRIVE_API_UTIL_H_ |
| 6 #define CHROME_BROWSER_DRIVE_DRIVE_API_UTIL_H_ | 6 #define CHROME_BROWSER_DRIVE_DRIVE_API_UTIL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "chrome/browser/drive/drive_service_interface.h" | 11 #include "chrome/browser/drive/drive_service_interface.h" |
| 12 #include "google_apis/drive/drive_common_callbacks.h" | 12 #include "google_apis/drive/drive_common_callbacks.h" |
| 13 #include "google_apis/drive/drive_entry_kinds.h" | |
| 14 #include "google_apis/drive/gdata_errorcode.h" | 13 #include "google_apis/drive/gdata_errorcode.h" |
| 15 | 14 |
| 16 class GURL; | 15 class GURL; |
| 17 | 16 |
| 18 namespace base { | 17 namespace base { |
| 19 class FilePath; | 18 class FilePath; |
| 20 class Value; | 19 class Value; |
| 21 } // namespace base | 20 } // namespace base |
| 22 | 21 |
| 23 namespace google_apis { | 22 namespace google_apis { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 // OAuth2 scopes for the GData WAPI. | 80 // OAuth2 scopes for the GData WAPI. |
| 82 extern const char kDocsListScope[]; | 81 extern const char kDocsListScope[]; |
| 83 extern const char kDriveAppsScope[]; | 82 extern const char kDriveAppsScope[]; |
| 84 | 83 |
| 85 // Extracts an url to the sharing dialog and returns it via |callback|. If | 84 // Extracts an url to the sharing dialog and returns it via |callback|. If |
| 86 // the share url doesn't exist, then an empty url is returned. | 85 // the share url doesn't exist, then an empty url is returned. |
| 87 void ParseShareUrlAndRun(const google_apis::GetShareUrlCallback& callback, | 86 void ParseShareUrlAndRun(const google_apis::GetShareUrlCallback& callback, |
| 88 google_apis::GDataErrorCode error, | 87 google_apis::GDataErrorCode error, |
| 89 scoped_ptr<base::Value> value); | 88 scoped_ptr<base::Value> value); |
| 90 | 89 |
| 91 // Converts ResourceEntry to FileResource. | |
| 92 scoped_ptr<google_apis::FileResource> | |
| 93 ConvertResourceEntryToFileResource(const google_apis::ResourceEntry& entry); | |
| 94 | |
| 95 // Returns the GData WAPI's Kind of the FileResource. | |
| 96 google_apis::DriveEntryKind GetKind( | |
| 97 const google_apis::FileResource& file_resource); | |
| 98 | |
| 99 // Converts FileResource to ResourceEntry. | 90 // Converts FileResource to ResourceEntry. |
| 100 scoped_ptr<google_apis::ResourceEntry> | 91 scoped_ptr<google_apis::ResourceEntry> |
| 101 ConvertFileResourceToResourceEntry( | 92 ConvertFileResourceToResourceEntry( |
| 102 const google_apis::FileResource& file_resource); | 93 const google_apis::FileResource& file_resource); |
| 103 | 94 |
| 104 // Converts ChangeResource to ResourceEntry. | 95 // Converts ChangeResource to ResourceEntry. |
| 105 scoped_ptr<google_apis::ResourceEntry> | 96 scoped_ptr<google_apis::ResourceEntry> |
| 106 ConvertChangeResourceToResourceEntry( | 97 ConvertChangeResourceToResourceEntry( |
| 107 const google_apis::ChangeResource& change_resource); | 98 const google_apis::ChangeResource& change_resource); |
| 108 | 99 |
| 109 // Converts FileList to ResourceList. | 100 // Converts FileList to ResourceList. |
| 110 scoped_ptr<google_apis::ResourceList> | 101 scoped_ptr<google_apis::ResourceList> |
| 111 ConvertFileListToResourceList(const google_apis::FileList& file_list); | 102 ConvertFileListToResourceList(const google_apis::FileList& file_list); |
| 112 | 103 |
| 113 // Converts ChangeList to ResourceList. | 104 // Converts ChangeList to ResourceList. |
| 114 scoped_ptr<google_apis::ResourceList> | 105 scoped_ptr<google_apis::ResourceList> |
| 115 ConvertChangeListToResourceList(const google_apis::ChangeList& change_list); | 106 ConvertChangeListToResourceList(const google_apis::ChangeList& change_list); |
| 116 | 107 |
| 117 // Returns the (base-16 encoded) MD5 digest of the file content at |file_path|, | 108 // Returns the (base-16 encoded) MD5 digest of the file content at |file_path|, |
| 118 // or an empty string if an error is found. | 109 // or an empty string if an error is found. |
| 119 std::string GetMd5Digest(const base::FilePath& file_path); | 110 std::string GetMd5Digest(const base::FilePath& file_path); |
| 120 | 111 |
| 121 // The resource ID for the root directory for WAPI is defined in the spec: | 112 // The resource ID for the root directory for WAPI is defined in the spec: |
| 122 // https://developers.google.com/google-apps/documents-list/ | 113 // https://developers.google.com/google-apps/documents-list/ |
| 123 extern const char kWapiRootDirectoryResourceId[]; | 114 extern const char kWapiRootDirectoryResourceId[]; |
| 124 | 115 |
| 116 // Returns preferred file extension for hosted documents which have given mime |
| 117 // type. If the given mime type is not known as one for hosted documents, |
| 118 // returns empty string. |
| 119 std::string GetHostedDocumentExtension(const std::string& mime_type); |
| 120 |
| 121 // Returns mime type for hosted documents which have given extension in form |
| 122 // ".xxx". If the given extension is not known as one for hosted documents, |
| 123 // returns empty string. |
| 124 std::string GetHostedDocumentMimeType(const std::string& extension); |
| 125 |
| 126 // Returns true if the given mime type is corresponding to one of hosted |
| 127 // documents. |
| 128 bool IsHostedDocument(const std::string& mime_type); |
| 129 |
| 130 // Returns true if the given extension is corresponding to one of hosted |
| 131 // documents. |
| 132 bool IsHostedDocumentByExtension(const std::string& extension); |
| 133 |
| 125 } // namespace util | 134 } // namespace util |
| 126 } // namespace drive | 135 } // namespace drive |
| 127 | 136 |
| 128 #endif // CHROME_BROWSER_DRIVE_DRIVE_API_UTIL_H_ | 137 #endif // CHROME_BROWSER_DRIVE_DRIVE_API_UTIL_H_ |
| OLD | NEW |