| 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_FAKE_DRIVE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_DRIVE_FAKE_DRIVE_SERVICE_H_ |
| 6 #define CHROME_BROWSER_DRIVE_FAKE_DRIVE_SERVICE_H_ | 6 #define CHROME_BROWSER_DRIVE_FAKE_DRIVE_SERVICE_H_ |
| 7 | 7 |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "chrome/browser/drive/drive_service_interface.h" | 9 #include "chrome/browser/drive/drive_service_interface.h" |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // 3) Update the in-memory resource list by requests like DeleteResource(). | 28 // 3) Update the in-memory resource list by requests like DeleteResource(). |
| 29 class FakeDriveService : public DriveServiceInterface { | 29 class FakeDriveService : public DriveServiceInterface { |
| 30 public: | 30 public: |
| 31 class ChangeObserver { | 31 class ChangeObserver { |
| 32 public: | 32 public: |
| 33 virtual ~ChangeObserver() {} | 33 virtual ~ChangeObserver() {} |
| 34 virtual void OnNewChangeAvailable() = 0; | 34 virtual void OnNewChangeAvailable() = 0; |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 FakeDriveService(); | 37 FakeDriveService(); |
| 38 virtual ~FakeDriveService(); | 38 ~FakeDriveService() override; |
| 39 | 39 |
| 40 // Loads the app list for Drive API. Returns true on success. | 40 // Loads the app list for Drive API. Returns true on success. |
| 41 bool LoadAppListForDriveApi(const std::string& relative_path); | 41 bool LoadAppListForDriveApi(const std::string& relative_path); |
| 42 | 42 |
| 43 // Adds an app to app list. | 43 // Adds an app to app list. |
| 44 void AddApp(const std::string& app_id, | 44 void AddApp(const std::string& app_id, |
| 45 const std::string& app_name, | 45 const std::string& app_name, |
| 46 const std::string& product_id, | 46 const std::string& product_id, |
| 47 const std::string& create_url, | 47 const std::string& create_url, |
| 48 bool is_removable); | 48 bool is_removable); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 static GURL GetFakeLinkUrl(const std::string& resource_id); | 121 static GURL GetFakeLinkUrl(const std::string& resource_id); |
| 122 | 122 |
| 123 // Sets the printf format for constructing the response of AuthorizeApp(). | 123 // Sets the printf format for constructing the response of AuthorizeApp(). |
| 124 // The format string must include two %s that are to be filled with | 124 // The format string must include two %s that are to be filled with |
| 125 // resource_id and app_id. | 125 // resource_id and app_id. |
| 126 void set_open_url_format(const std::string& url_format) { | 126 void set_open_url_format(const std::string& url_format) { |
| 127 open_url_format_ = url_format; | 127 open_url_format_ = url_format; |
| 128 } | 128 } |
| 129 | 129 |
| 130 // DriveServiceInterface Overrides | 130 // DriveServiceInterface Overrides |
| 131 virtual void Initialize(const std::string& account_id) override; | 131 void Initialize(const std::string& account_id) override; |
| 132 virtual void AddObserver(DriveServiceObserver* observer) override; | 132 void AddObserver(DriveServiceObserver* observer) override; |
| 133 virtual void RemoveObserver(DriveServiceObserver* observer) override; | 133 void RemoveObserver(DriveServiceObserver* observer) override; |
| 134 virtual bool CanSendRequest() const override; | 134 bool CanSendRequest() const override; |
| 135 virtual std::string GetRootResourceId() const override; | 135 std::string GetRootResourceId() const override; |
| 136 virtual bool HasAccessToken() const override; | 136 bool HasAccessToken() const override; |
| 137 virtual void RequestAccessToken( | 137 void RequestAccessToken( |
| 138 const google_apis::AuthStatusCallback& callback) override; | 138 const google_apis::AuthStatusCallback& callback) override; |
| 139 virtual bool HasRefreshToken() const override; | 139 bool HasRefreshToken() const override; |
| 140 virtual void ClearAccessToken() override; | 140 void ClearAccessToken() override; |
| 141 virtual void ClearRefreshToken() override; | 141 void ClearRefreshToken() override; |
| 142 virtual google_apis::CancelCallback GetAllFileList( | 142 google_apis::CancelCallback GetAllFileList( |
| 143 const google_apis::FileListCallback& callback) override; | 143 const google_apis::FileListCallback& callback) override; |
| 144 virtual google_apis::CancelCallback GetFileListInDirectory( | 144 google_apis::CancelCallback GetFileListInDirectory( |
| 145 const std::string& directory_resource_id, | 145 const std::string& directory_resource_id, |
| 146 const google_apis::FileListCallback& callback) override; | 146 const google_apis::FileListCallback& callback) override; |
| 147 // See the comment for EntryMatchWidthQuery() in .cc file for details about | 147 // See the comment for EntryMatchWidthQuery() in .cc file for details about |
| 148 // the supported search query types. | 148 // the supported search query types. |
| 149 virtual google_apis::CancelCallback Search( | 149 google_apis::CancelCallback Search( |
| 150 const std::string& search_query, | 150 const std::string& search_query, |
| 151 const google_apis::FileListCallback& callback) override; | 151 const google_apis::FileListCallback& callback) override; |
| 152 virtual google_apis::CancelCallback SearchByTitle( | 152 google_apis::CancelCallback SearchByTitle( |
| 153 const std::string& title, | 153 const std::string& title, |
| 154 const std::string& directory_resource_id, | 154 const std::string& directory_resource_id, |
| 155 const google_apis::FileListCallback& callback) override; | 155 const google_apis::FileListCallback& callback) override; |
| 156 virtual google_apis::CancelCallback GetChangeList( | 156 google_apis::CancelCallback GetChangeList( |
| 157 int64 start_changestamp, | 157 int64 start_changestamp, |
| 158 const google_apis::ChangeListCallback& callback) override; | 158 const google_apis::ChangeListCallback& callback) override; |
| 159 virtual google_apis::CancelCallback GetRemainingChangeList( | 159 google_apis::CancelCallback GetRemainingChangeList( |
| 160 const GURL& next_link, | 160 const GURL& next_link, |
| 161 const google_apis::ChangeListCallback& callback) override; | 161 const google_apis::ChangeListCallback& callback) override; |
| 162 virtual google_apis::CancelCallback GetRemainingFileList( | 162 google_apis::CancelCallback GetRemainingFileList( |
| 163 const GURL& next_link, | 163 const GURL& next_link, |
| 164 const google_apis::FileListCallback& callback) override; | 164 const google_apis::FileListCallback& callback) override; |
| 165 virtual google_apis::CancelCallback GetFileResource( | 165 google_apis::CancelCallback GetFileResource( |
| 166 const std::string& resource_id, | 166 const std::string& resource_id, |
| 167 const google_apis::FileResourceCallback& callback) override; | 167 const google_apis::FileResourceCallback& callback) override; |
| 168 virtual google_apis::CancelCallback GetShareUrl( | 168 google_apis::CancelCallback GetShareUrl( |
| 169 const std::string& resource_id, | 169 const std::string& resource_id, |
| 170 const GURL& embed_origin, | 170 const GURL& embed_origin, |
| 171 const google_apis::GetShareUrlCallback& callback) override; | 171 const google_apis::GetShareUrlCallback& callback) override; |
| 172 virtual google_apis::CancelCallback GetAboutResource( | 172 google_apis::CancelCallback GetAboutResource( |
| 173 const google_apis::AboutResourceCallback& callback) override; | 173 const google_apis::AboutResourceCallback& callback) override; |
| 174 virtual google_apis::CancelCallback GetAppList( | 174 google_apis::CancelCallback GetAppList( |
| 175 const google_apis::AppListCallback& callback) override; | 175 const google_apis::AppListCallback& callback) override; |
| 176 virtual google_apis::CancelCallback DeleteResource( | 176 google_apis::CancelCallback DeleteResource( |
| 177 const std::string& resource_id, | 177 const std::string& resource_id, |
| 178 const std::string& etag, | 178 const std::string& etag, |
| 179 const google_apis::EntryActionCallback& callback) override; | 179 const google_apis::EntryActionCallback& callback) override; |
| 180 virtual google_apis::CancelCallback TrashResource( | 180 google_apis::CancelCallback TrashResource( |
| 181 const std::string& resource_id, | 181 const std::string& resource_id, |
| 182 const google_apis::EntryActionCallback& callback) override; | 182 const google_apis::EntryActionCallback& callback) override; |
| 183 virtual google_apis::CancelCallback DownloadFile( | 183 google_apis::CancelCallback DownloadFile( |
| 184 const base::FilePath& local_cache_path, | 184 const base::FilePath& local_cache_path, |
| 185 const std::string& resource_id, | 185 const std::string& resource_id, |
| 186 const google_apis::DownloadActionCallback& download_action_callback, | 186 const google_apis::DownloadActionCallback& download_action_callback, |
| 187 const google_apis::GetContentCallback& get_content_callback, | 187 const google_apis::GetContentCallback& get_content_callback, |
| 188 const google_apis::ProgressCallback& progress_callback) override; | 188 const google_apis::ProgressCallback& progress_callback) override; |
| 189 virtual google_apis::CancelCallback CopyResource( | 189 google_apis::CancelCallback CopyResource( |
| 190 const std::string& resource_id, | 190 const std::string& resource_id, |
| 191 const std::string& parent_resource_id, | 191 const std::string& parent_resource_id, |
| 192 const std::string& new_title, | 192 const std::string& new_title, |
| 193 const base::Time& last_modified, | 193 const base::Time& last_modified, |
| 194 const google_apis::FileResourceCallback& callback) override; | 194 const google_apis::FileResourceCallback& callback) override; |
| 195 virtual google_apis::CancelCallback UpdateResource( | 195 google_apis::CancelCallback UpdateResource( |
| 196 const std::string& resource_id, | 196 const std::string& resource_id, |
| 197 const std::string& parent_resource_id, | 197 const std::string& parent_resource_id, |
| 198 const std::string& new_title, | 198 const std::string& new_title, |
| 199 const base::Time& last_modified, | 199 const base::Time& last_modified, |
| 200 const base::Time& last_viewed_by_me, | 200 const base::Time& last_viewed_by_me, |
| 201 const google_apis::FileResourceCallback& callback) override; | 201 const google_apis::FileResourceCallback& callback) override; |
| 202 virtual google_apis::CancelCallback AddResourceToDirectory( | 202 google_apis::CancelCallback AddResourceToDirectory( |
| 203 const std::string& parent_resource_id, | 203 const std::string& parent_resource_id, |
| 204 const std::string& resource_id, | 204 const std::string& resource_id, |
| 205 const google_apis::EntryActionCallback& callback) override; | 205 const google_apis::EntryActionCallback& callback) override; |
| 206 virtual google_apis::CancelCallback RemoveResourceFromDirectory( | 206 google_apis::CancelCallback RemoveResourceFromDirectory( |
| 207 const std::string& parent_resource_id, | 207 const std::string& parent_resource_id, |
| 208 const std::string& resource_id, | 208 const std::string& resource_id, |
| 209 const google_apis::EntryActionCallback& callback) override; | 209 const google_apis::EntryActionCallback& callback) override; |
| 210 virtual google_apis::CancelCallback AddNewDirectory( | 210 google_apis::CancelCallback AddNewDirectory( |
| 211 const std::string& parent_resource_id, | 211 const std::string& parent_resource_id, |
| 212 const std::string& directory_title, | 212 const std::string& directory_title, |
| 213 const AddNewDirectoryOptions& options, | 213 const AddNewDirectoryOptions& options, |
| 214 const google_apis::FileResourceCallback& callback) override; | 214 const google_apis::FileResourceCallback& callback) override; |
| 215 virtual google_apis::CancelCallback InitiateUploadNewFile( | 215 google_apis::CancelCallback InitiateUploadNewFile( |
| 216 const std::string& content_type, | 216 const std::string& content_type, |
| 217 int64 content_length, | 217 int64 content_length, |
| 218 const std::string& parent_resource_id, | 218 const std::string& parent_resource_id, |
| 219 const std::string& title, | 219 const std::string& title, |
| 220 const InitiateUploadNewFileOptions& options, | 220 const InitiateUploadNewFileOptions& options, |
| 221 const google_apis::InitiateUploadCallback& callback) override; | 221 const google_apis::InitiateUploadCallback& callback) override; |
| 222 virtual google_apis::CancelCallback InitiateUploadExistingFile( | 222 google_apis::CancelCallback InitiateUploadExistingFile( |
| 223 const std::string& content_type, | 223 const std::string& content_type, |
| 224 int64 content_length, | 224 int64 content_length, |
| 225 const std::string& resource_id, | 225 const std::string& resource_id, |
| 226 const InitiateUploadExistingFileOptions& options, | 226 const InitiateUploadExistingFileOptions& options, |
| 227 const google_apis::InitiateUploadCallback& callback) override; | 227 const google_apis::InitiateUploadCallback& callback) override; |
| 228 virtual google_apis::CancelCallback ResumeUpload( | 228 google_apis::CancelCallback ResumeUpload( |
| 229 const GURL& upload_url, | 229 const GURL& upload_url, |
| 230 int64 start_position, | 230 int64 start_position, |
| 231 int64 end_position, | 231 int64 end_position, |
| 232 int64 content_length, | 232 int64 content_length, |
| 233 const std::string& content_type, | 233 const std::string& content_type, |
| 234 const base::FilePath& local_file_path, | 234 const base::FilePath& local_file_path, |
| 235 const google_apis::drive::UploadRangeCallback& callback, | 235 const google_apis::drive::UploadRangeCallback& callback, |
| 236 const google_apis::ProgressCallback& progress_callback) override; | 236 const google_apis::ProgressCallback& progress_callback) override; |
| 237 virtual google_apis::CancelCallback GetUploadStatus( | 237 google_apis::CancelCallback GetUploadStatus( |
| 238 const GURL& upload_url, | 238 const GURL& upload_url, |
| 239 int64 content_length, | 239 int64 content_length, |
| 240 const google_apis::drive::UploadRangeCallback& callback) override; | 240 const google_apis::drive::UploadRangeCallback& callback) override; |
| 241 virtual google_apis::CancelCallback AuthorizeApp( | 241 google_apis::CancelCallback AuthorizeApp( |
| 242 const std::string& resource_id, | 242 const std::string& resource_id, |
| 243 const std::string& app_id, | 243 const std::string& app_id, |
| 244 const google_apis::AuthorizeAppCallback& callback) override; | 244 const google_apis::AuthorizeAppCallback& callback) override; |
| 245 virtual google_apis::CancelCallback UninstallApp( | 245 google_apis::CancelCallback UninstallApp( |
| 246 const std::string& app_id, | 246 const std::string& app_id, |
| 247 const google_apis::EntryActionCallback& callback) override; | 247 const google_apis::EntryActionCallback& callback) override; |
| 248 virtual google_apis::CancelCallback AddPermission( | 248 google_apis::CancelCallback AddPermission( |
| 249 const std::string& resource_id, | 249 const std::string& resource_id, |
| 250 const std::string& email, | 250 const std::string& email, |
| 251 google_apis::drive::PermissionRole role, | 251 google_apis::drive::PermissionRole role, |
| 252 const google_apis::EntryActionCallback& callback) override; | 252 const google_apis::EntryActionCallback& callback) override; |
| 253 | 253 |
| 254 // Adds a new file with the given parameters. On success, returns | 254 // Adds a new file with the given parameters. On success, returns |
| 255 // HTTP_CREATED with the parsed entry. | 255 // HTTP_CREATED with the parsed entry. |
| 256 // |callback| must not be null. | 256 // |callback| must not be null. |
| 257 void AddNewFile(const std::string& content_type, | 257 void AddNewFile(const std::string& content_type, |
| 258 const std::string& content_data, | 258 const std::string& content_data, |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 ObserverList<ChangeObserver> change_observers_; | 372 ObserverList<ChangeObserver> change_observers_; |
| 373 | 373 |
| 374 base::WeakPtrFactory<FakeDriveService> weak_ptr_factory_; | 374 base::WeakPtrFactory<FakeDriveService> weak_ptr_factory_; |
| 375 | 375 |
| 376 DISALLOW_COPY_AND_ASSIGN(FakeDriveService); | 376 DISALLOW_COPY_AND_ASSIGN(FakeDriveService); |
| 377 }; | 377 }; |
| 378 | 378 |
| 379 } // namespace drive | 379 } // namespace drive |
| 380 | 380 |
| 381 #endif // CHROME_BROWSER_DRIVE_FAKE_DRIVE_SERVICE_H_ | 381 #endif // CHROME_BROWSER_DRIVE_FAKE_DRIVE_SERVICE_H_ |
| OLD | NEW |