OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // This file provides Drive specific API functions. | 5 // This file provides Drive specific API functions. |
6 | 6 |
7 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_DRIVE_H_ | 7 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_DRIVE_H_ |
8 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_DRIVE_H_ | 8 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_DRIVE_H_ |
9 | 9 |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 virtual ~FileManagerPrivatePinDriveFileFunction() {} | 71 virtual ~FileManagerPrivatePinDriveFileFunction() {} |
72 | 72 |
73 // AsyncExtensionFunction overrides. | 73 // AsyncExtensionFunction overrides. |
74 virtual bool RunAsync() OVERRIDE; | 74 virtual bool RunAsync() OVERRIDE; |
75 | 75 |
76 private: | 76 private: |
77 // Callback for RunAsync(). | 77 // Callback for RunAsync(). |
78 void OnPinStateSet(drive::FileError error); | 78 void OnPinStateSet(drive::FileError error); |
79 }; | 79 }; |
80 | 80 |
81 // Get drive files for the given list of file URLs. Initiate downloading of | |
82 // drive files if these are not cached. Return a list of local file names. | |
83 // This function puts empty strings instead of local paths for files could | |
84 // not be obtained. For instance, this can happen if the user specifies a new | |
85 // file name to save a file on drive. There may be other reasons to fail. The | |
86 // file manager should check if the local paths returned from getDriveFiles() | |
87 // contain empty paths. | |
88 // TODO(satorux): Should we propagate error types to the JavaScript layer? | |
89 class FileManagerPrivateGetDriveFilesFunction | |
90 : public LoggedAsyncExtensionFunction { | |
91 public: | |
92 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.getDriveFiles", | |
93 FILEMANAGERPRIVATE_GETDRIVEFILES) | |
94 | |
95 FileManagerPrivateGetDriveFilesFunction(); | |
96 | |
97 protected: | |
98 virtual ~FileManagerPrivateGetDriveFilesFunction(); | |
99 | |
100 // AsyncExtensionFunction overrides. | |
101 virtual bool RunAsync() OVERRIDE; | |
102 | |
103 private: | |
104 // Gets the file on the top of the |remaining_drive_paths_| or sends the | |
105 // response if the queue is empty. | |
106 void GetFileOrSendResponse(); | |
107 | |
108 // Called by FileSystem::GetFile(). Pops the file from | |
109 // |remaining_drive_paths_|, and calls GetFileOrSendResponse(). | |
110 void OnFileReady(drive::FileError error, | |
111 const base::FilePath& local_path, | |
112 scoped_ptr<drive::ResourceEntry> entry); | |
113 | |
114 std::queue<base::FilePath> remaining_drive_paths_; | |
115 std::vector<std::string> local_paths_; | |
116 }; | |
117 | |
118 // Implements the chrome.fileManagerPrivate.cancelFileTransfers method. | 81 // Implements the chrome.fileManagerPrivate.cancelFileTransfers method. |
119 class FileManagerPrivateCancelFileTransfersFunction | 82 class FileManagerPrivateCancelFileTransfersFunction |
120 : public LoggedAsyncExtensionFunction { | 83 : public LoggedAsyncExtensionFunction { |
121 public: | 84 public: |
122 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.cancelFileTransfers", | 85 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.cancelFileTransfers", |
123 FILEMANAGERPRIVATE_CANCELFILETRANSFERS) | 86 FILEMANAGERPRIVATE_CANCELFILETRANSFERS) |
124 | 87 |
125 protected: | 88 protected: |
126 virtual ~FileManagerPrivateCancelFileTransfersFunction() {} | 89 virtual ~FileManagerPrivateCancelFileTransfersFunction() {} |
127 | 90 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 const std::string& access_token); | 236 const std::string& access_token); |
274 | 237 |
275 private: | 238 private: |
276 std::string download_url_; | 239 std::string download_url_; |
277 scoped_ptr<google_apis::AuthService> auth_service_; | 240 scoped_ptr<google_apis::AuthService> auth_service_; |
278 }; | 241 }; |
279 | 242 |
280 } // namespace extensions | 243 } // namespace extensions |
281 | 244 |
282 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_DRIVE_H_ | 245 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_DRIVE_H_ |
OLD | NEW |