| OLD | NEW |
| (Empty) |
| 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 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_SERVICE_INTERFACE_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_SERVICE_INTERFACE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 // TODO(kochi): Further split gdata_operations.h and include only necessary | |
| 11 // headers. http://crbug.com/141469 | |
| 12 // DownloadActionCallback/InitiateUploadParams/ResulmeUploadParams | |
| 13 #include "chrome/browser/chromeos/gdata/gdata_operations.h" | |
| 14 #include "chrome/browser/google_apis/operations_base.h" | |
| 15 | |
| 16 class Profile; | |
| 17 | |
| 18 namespace gdata { | |
| 19 | |
| 20 class OperationRegistry; | |
| 21 | |
| 22 // Document export format. | |
| 23 enum DocumentExportFormat { | |
| 24 PDF, // Portable Document Format. (all documents) | |
| 25 PNG, // Portable Networks Graphic Image Format (all documents) | |
| 26 HTML, // HTML Format (text documents and spreadsheets). | |
| 27 TXT, // Text file (text documents and presentations). | |
| 28 DOC, // Word (text documents only). | |
| 29 ODT, // Open Document Format (text documents only). | |
| 30 RTF, // Rich Text Format (text documents only). | |
| 31 ZIP, // ZIP archive (text documents only). Contains the images (if any) | |
| 32 // used in the document as well as a .html file containing the | |
| 33 // document's text. | |
| 34 JPEG, // JPEG (drawings only). | |
| 35 SVG, // Scalable Vector Graphics Image Format (drawings only). | |
| 36 PPT, // Powerpoint (presentations only). | |
| 37 XLS, // Excel (spreadsheets only). | |
| 38 CSV, // Excel (spreadsheets only). | |
| 39 ODS, // Open Document Spreadsheet (spreadsheets only). | |
| 40 TSV, // Tab Separated Value (spreadsheets only). Only the first worksheet | |
| 41 // is returned in TSV by default. | |
| 42 }; | |
| 43 | |
| 44 // Observer interface for DriveServiceInterface. | |
| 45 class DriveServiceObserver { | |
| 46 public: | |
| 47 // Triggered when the service gets ready to perform operations. | |
| 48 virtual void OnReadyToPerformOperations() = 0; | |
| 49 | |
| 50 protected: | |
| 51 virtual ~DriveServiceObserver() {} | |
| 52 }; | |
| 53 | |
| 54 // This defines an interface for sharing by DocumentService and | |
| 55 // MockDocumentService so that we can do testing of clients of DocumentService. | |
| 56 // | |
| 57 // All functions must be called on UI thread. DocumentService is built on top | |
| 58 // of URLFetcher that runs on UI thread. | |
| 59 // | |
| 60 // TODO(zel,benchan): Make the terminology/naming convention (e.g. file vs | |
| 61 // document vs resource, directory vs collection) more consistent and precise. | |
| 62 class DriveServiceInterface { | |
| 63 public: | |
| 64 virtual ~DriveServiceInterface() {} | |
| 65 | |
| 66 // Common service: | |
| 67 | |
| 68 // Initializes the documents service tied with |profile|. | |
| 69 virtual void Initialize(Profile* profile) = 0; | |
| 70 | |
| 71 // Adds an observer. | |
| 72 virtual void AddObserver(DriveServiceObserver* observer) = 0; | |
| 73 | |
| 74 // Removes an observer. | |
| 75 virtual void RemoveObserver(DriveServiceObserver* observer) = 0; | |
| 76 | |
| 77 // Retrieves the operation registry. | |
| 78 virtual OperationRegistry* operation_registry() const = 0; | |
| 79 | |
| 80 // True if ready to start operations. | |
| 81 virtual bool CanStartOperation() const = 0; | |
| 82 | |
| 83 // Cancels all in-flight operations. | |
| 84 virtual void CancelAll() = 0; | |
| 85 | |
| 86 // Authentication service: | |
| 87 | |
| 88 // Authenticates the user by fetching the auth token as | |
| 89 // needed. |callback| will be run with the error code and the auth | |
| 90 // token, on the thread this function is run. | |
| 91 virtual void Authenticate(const AuthStatusCallback& callback) = 0; | |
| 92 | |
| 93 // True if OAuth2 access token is retrieved and believed to be fresh. | |
| 94 virtual bool HasAccessToken() const = 0; | |
| 95 | |
| 96 // True if OAuth2 refresh token is present. | |
| 97 virtual bool HasRefreshToken() const = 0; | |
| 98 | |
| 99 // Document access: | |
| 100 | |
| 101 // Fetches the document feed from |feed_url| with |start_changestamp|. If this | |
| 102 // URL is empty, the call will fetch the default root or change document feed. | |
| 103 // |start_changestamp| specifies the starting point from change feeds only. | |
| 104 // Value different than 0, it would trigger delta feed fetching. | |
| 105 // | |
| 106 // |search_query| specifies search query to be sent to the server. It will be | |
| 107 // used only if |start_changestamp| is 0. If empty string is passed, | |
| 108 // |search_query| is ignored. | |
| 109 // | |
| 110 // |directory_resource_id| specifies the directory from which documents are | |
| 111 // fetched. It will be used only if |start_changestamp| is 0. If empty | |
| 112 // string is passed, |directory_resource_id| is ignored. | |
| 113 // | |
| 114 // Upon completion, invokes |callback| with results on the calling thread. | |
| 115 // TODO(satorux): Refactor this function: crbug.com/128746 | |
| 116 virtual void GetDocuments(const GURL& feed_url, | |
| 117 int64 start_changestamp, | |
| 118 const std::string& search_query, | |
| 119 const std::string& directory_resource_id, | |
| 120 const GetDataCallback& callback) = 0; | |
| 121 | |
| 122 // Fetches single entry metadata from server. The entry's resource id equals | |
| 123 // |resource_id|. | |
| 124 // Upon completion, invokes |callback| with results on the calling thread. | |
| 125 virtual void GetDocumentEntry(const std::string& resource_id, | |
| 126 const GetDataCallback& callback) = 0; | |
| 127 | |
| 128 // Gets the account metadata from the server using the default account | |
| 129 // metadata URL. Upon completion, invokes |callback| with results on the | |
| 130 // calling thread. | |
| 131 virtual void GetAccountMetadata(const GetDataCallback& callback) = 0; | |
| 132 | |
| 133 // Gets the application information from the server. | |
| 134 // Upon completion, invokes |callback| with results on the calling thread. | |
| 135 virtual void GetApplicationInfo(const GetDataCallback& callback) = 0; | |
| 136 | |
| 137 // Deletes a document identified by its 'self' |url| and |etag|. | |
| 138 // Upon completion, invokes |callback| with results on the calling thread. | |
| 139 virtual void DeleteDocument(const GURL& document_url, | |
| 140 const EntryActionCallback& callback) = 0; | |
| 141 | |
| 142 // Downloads a document identified by its |content_url| in a given |format|. | |
| 143 // Upon completion, invokes |callback| with results on the calling thread. | |
| 144 virtual void DownloadDocument(const FilePath& virtual_path, | |
| 145 const FilePath& local_cache_path, | |
| 146 const GURL& content_url, | |
| 147 DocumentExportFormat format, | |
| 148 const DownloadActionCallback& callback) = 0; | |
| 149 | |
| 150 // Makes a copy of a document identified by its |resource_id|. | |
| 151 // The copy is named as the UTF-8 encoded |new_name| and is not added to any | |
| 152 // collection. Use AddResourceToDirectory() to add the copy to a collection | |
| 153 // when needed. Upon completion, invokes |callback| with results on the | |
| 154 // calling thread. | |
| 155 virtual void CopyDocument(const std::string& resource_id, | |
| 156 const FilePath::StringType& new_name, | |
| 157 const GetDataCallback& callback) = 0; | |
| 158 | |
| 159 // Renames a document or collection identified by its 'self' link | |
| 160 // |document_url| to the UTF-8 encoded |new_name|. Upon completion, | |
| 161 // invokes |callback| with results on the calling thread. | |
| 162 virtual void RenameResource(const GURL& resource_url, | |
| 163 const FilePath::StringType& new_name, | |
| 164 const EntryActionCallback& callback) = 0; | |
| 165 | |
| 166 // Adds a resource (document, file, or collection) identified by its | |
| 167 // 'self' link |resource_url| to a collection with a content link | |
| 168 // |parent_content_url|. Upon completion, invokes |callback| with | |
| 169 // results on the calling thread. | |
| 170 virtual void AddResourceToDirectory(const GURL& parent_content_url, | |
| 171 const GURL& resource_url, | |
| 172 const EntryActionCallback& callback) = 0; | |
| 173 | |
| 174 // Removes a resource (document, file, collection) identified by its | |
| 175 // 'self' link |resource_url| from a collection with a content link | |
| 176 // |parent_content_url|. Upon completion, invokes |callback| with | |
| 177 // results on the calling thread. | |
| 178 virtual void RemoveResourceFromDirectory( | |
| 179 const GURL& parent_content_url, | |
| 180 const GURL& resource_url, | |
| 181 const std::string& resource_id, | |
| 182 const EntryActionCallback& callback) = 0; | |
| 183 | |
| 184 // Creates new collection with |directory_name| under parent directory | |
| 185 // identified with |parent_content_url|. If |parent_content_url| is empty, | |
| 186 // the new collection will be created in the root. Upon completion, | |
| 187 // invokes |callback| and passes newly created entry on the calling thread. | |
| 188 virtual void CreateDirectory(const GURL& parent_content_url, | |
| 189 const FilePath::StringType& directory_name, | |
| 190 const GetDataCallback& callback) = 0; | |
| 191 | |
| 192 // Downloads a file identified by its |content_url|. The downloaded file will | |
| 193 // be stored at |local_cache_path| location. Upon completion, invokes | |
| 194 // |download_action_callback| with results on the calling thread. | |
| 195 // If |get_content_callback| is not empty, | |
| 196 // URLFetcherDelegate::OnURLFetchDownloadData will be called, which will in | |
| 197 // turn invoke |get_content_callback| on the calling thread. | |
| 198 virtual void DownloadFile( | |
| 199 const FilePath& virtual_path, | |
| 200 const FilePath& local_cache_path, | |
| 201 const GURL& content_url, | |
| 202 const DownloadActionCallback& download_action_callback, | |
| 203 const GetContentCallback& get_content_callback) = 0; | |
| 204 | |
| 205 // Initiates uploading of a document/file. | |
| 206 virtual void InitiateUpload(const InitiateUploadParams& params, | |
| 207 const InitiateUploadCallback& callback) = 0; | |
| 208 | |
| 209 // Resumes uploading of a document/file on the calling thread. | |
| 210 virtual void ResumeUpload(const ResumeUploadParams& params, | |
| 211 const ResumeUploadCallback& callback) = 0; | |
| 212 | |
| 213 // Authorizes a Drive app with the id |app_id| to open the given document. | |
| 214 // Upon completion, invokes |callback| with results on the calling thread. | |
| 215 virtual void AuthorizeApp(const GURL& resource_url, | |
| 216 const std::string& app_id, | |
| 217 const GetDataCallback& callback) = 0; | |
| 218 }; | |
| 219 | |
| 220 } // namespace gdata | |
| 221 | |
| 222 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_SERVICE_INTERFACE_H_ | |
| OLD | NEW |