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 "chrome/browser/chromeos/drive/file_errors.h" | 10 #include "chrome/browser/chromeos/drive/file_errors.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 public: | 34 public: |
35 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getDriveEntryProperties", | 35 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getDriveEntryProperties", |
36 FILEBROWSERPRIVATE_GETDRIVEFILEPROPERTIES) | 36 FILEBROWSERPRIVATE_GETDRIVEFILEPROPERTIES) |
37 | 37 |
38 FileBrowserPrivateGetDriveEntryPropertiesFunction(); | 38 FileBrowserPrivateGetDriveEntryPropertiesFunction(); |
39 | 39 |
40 protected: | 40 protected: |
41 virtual ~FileBrowserPrivateGetDriveEntryPropertiesFunction(); | 41 virtual ~FileBrowserPrivateGetDriveEntryPropertiesFunction(); |
42 | 42 |
43 // AsyncExtensionFunction overrides. | 43 // AsyncExtensionFunction overrides. |
44 virtual bool RunImpl() OVERRIDE; | 44 virtual bool RunAsync() OVERRIDE; |
45 | 45 |
46 private: | 46 private: |
47 void CompleteGetFileProperties(drive::FileError error); | 47 void CompleteGetFileProperties(drive::FileError error); |
48 | 48 |
49 size_t processed_count_; | 49 size_t processed_count_; |
50 std::vector<linked_ptr<api::file_browser_private::DriveEntryProperties> > | 50 std::vector<linked_ptr<api::file_browser_private::DriveEntryProperties> > |
51 properties_list_; | 51 properties_list_; |
52 }; | 52 }; |
53 | 53 |
54 // Implements the chrome.fileBrowserPrivate.pinDriveFile method. | 54 // Implements the chrome.fileBrowserPrivate.pinDriveFile method. |
55 class FileBrowserPrivatePinDriveFileFunction | 55 class FileBrowserPrivatePinDriveFileFunction |
56 : public LoggedAsyncExtensionFunction { | 56 : public LoggedAsyncExtensionFunction { |
57 public: | 57 public: |
58 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.pinDriveFile", | 58 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.pinDriveFile", |
59 FILEBROWSERPRIVATE_PINDRIVEFILE) | 59 FILEBROWSERPRIVATE_PINDRIVEFILE) |
60 | 60 |
61 protected: | 61 protected: |
62 virtual ~FileBrowserPrivatePinDriveFileFunction() {} | 62 virtual ~FileBrowserPrivatePinDriveFileFunction() {} |
63 | 63 |
64 // AsyncExtensionFunction overrides. | 64 // AsyncExtensionFunction overrides. |
65 virtual bool RunImpl() OVERRIDE; | 65 virtual bool RunAsync() OVERRIDE; |
66 | 66 |
67 private: | 67 private: |
68 // Callback for RunImpl(). | 68 // Callback for RunAsync(). |
69 void OnPinStateSet(drive::FileError error); | 69 void OnPinStateSet(drive::FileError error); |
70 }; | 70 }; |
71 | 71 |
72 // Get drive files for the given list of file URLs. Initiate downloading of | 72 // Get drive files for the given list of file URLs. Initiate downloading of |
73 // drive files if these are not cached. Return a list of local file names. | 73 // drive files if these are not cached. Return a list of local file names. |
74 // This function puts empty strings instead of local paths for files could | 74 // This function puts empty strings instead of local paths for files could |
75 // not be obtained. For instance, this can happen if the user specifies a new | 75 // not be obtained. For instance, this can happen if the user specifies a new |
76 // file name to save a file on drive. There may be other reasons to fail. The | 76 // file name to save a file on drive. There may be other reasons to fail. The |
77 // file manager should check if the local paths returned from getDriveFiles() | 77 // file manager should check if the local paths returned from getDriveFiles() |
78 // contain empty paths. | 78 // contain empty paths. |
79 // TODO(satorux): Should we propagate error types to the JavaScript layer? | 79 // TODO(satorux): Should we propagate error types to the JavaScript layer? |
80 class FileBrowserPrivateGetDriveFilesFunction | 80 class FileBrowserPrivateGetDriveFilesFunction |
81 : public LoggedAsyncExtensionFunction { | 81 : public LoggedAsyncExtensionFunction { |
82 public: | 82 public: |
83 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getDriveFiles", | 83 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getDriveFiles", |
84 FILEBROWSERPRIVATE_GETDRIVEFILES) | 84 FILEBROWSERPRIVATE_GETDRIVEFILES) |
85 | 85 |
86 FileBrowserPrivateGetDriveFilesFunction(); | 86 FileBrowserPrivateGetDriveFilesFunction(); |
87 | 87 |
88 protected: | 88 protected: |
89 virtual ~FileBrowserPrivateGetDriveFilesFunction(); | 89 virtual ~FileBrowserPrivateGetDriveFilesFunction(); |
90 | 90 |
91 // AsyncExtensionFunction overrides. | 91 // AsyncExtensionFunction overrides. |
92 virtual bool RunImpl() OVERRIDE; | 92 virtual bool RunAsync() OVERRIDE; |
93 | 93 |
94 private: | 94 private: |
95 // Gets the file on the top of the |remaining_drive_paths_| or sends the | 95 // Gets the file on the top of the |remaining_drive_paths_| or sends the |
96 // response if the queue is empty. | 96 // response if the queue is empty. |
97 void GetFileOrSendResponse(); | 97 void GetFileOrSendResponse(); |
98 | 98 |
99 // Called by FileSystem::GetFile(). Pops the file from | 99 // Called by FileSystem::GetFile(). Pops the file from |
100 // |remaining_drive_paths_|, and calls GetFileOrSendResponse(). | 100 // |remaining_drive_paths_|, and calls GetFileOrSendResponse(). |
101 void OnFileReady(drive::FileError error, | 101 void OnFileReady(drive::FileError error, |
102 const base::FilePath& local_path, | 102 const base::FilePath& local_path, |
103 scoped_ptr<drive::ResourceEntry> entry); | 103 scoped_ptr<drive::ResourceEntry> entry); |
104 | 104 |
105 std::queue<base::FilePath> remaining_drive_paths_; | 105 std::queue<base::FilePath> remaining_drive_paths_; |
106 std::vector<std::string> local_paths_; | 106 std::vector<std::string> local_paths_; |
107 }; | 107 }; |
108 | 108 |
109 // Implements the chrome.fileBrowserPrivate.cancelFileTransfers method. | 109 // Implements the chrome.fileBrowserPrivate.cancelFileTransfers method. |
110 class FileBrowserPrivateCancelFileTransfersFunction | 110 class FileBrowserPrivateCancelFileTransfersFunction |
111 : public LoggedAsyncExtensionFunction { | 111 : public LoggedAsyncExtensionFunction { |
112 public: | 112 public: |
113 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.cancelFileTransfers", | 113 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.cancelFileTransfers", |
114 FILEBROWSERPRIVATE_CANCELFILETRANSFERS) | 114 FILEBROWSERPRIVATE_CANCELFILETRANSFERS) |
115 | 115 |
116 protected: | 116 protected: |
117 virtual ~FileBrowserPrivateCancelFileTransfersFunction() {} | 117 virtual ~FileBrowserPrivateCancelFileTransfersFunction() {} |
118 | 118 |
119 // AsyncExtensionFunction overrides. | 119 // AsyncExtensionFunction overrides. |
120 virtual bool RunImpl() OVERRIDE; | 120 virtual bool RunAsync() OVERRIDE; |
121 }; | 121 }; |
122 | 122 |
123 class FileBrowserPrivateSearchDriveFunction | 123 class FileBrowserPrivateSearchDriveFunction |
124 : public LoggedAsyncExtensionFunction { | 124 : public LoggedAsyncExtensionFunction { |
125 public: | 125 public: |
126 typedef std::vector<drive::SearchResultInfo> SearchResultInfoList; | 126 typedef std::vector<drive::SearchResultInfo> SearchResultInfoList; |
127 | 127 |
128 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.searchDrive", | 128 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.searchDrive", |
129 FILEBROWSERPRIVATE_SEARCHDRIVE) | 129 FILEBROWSERPRIVATE_SEARCHDRIVE) |
130 | 130 |
131 protected: | 131 protected: |
132 virtual ~FileBrowserPrivateSearchDriveFunction() {} | 132 virtual ~FileBrowserPrivateSearchDriveFunction() {} |
133 | 133 |
134 virtual bool RunImpl() OVERRIDE; | 134 virtual bool RunAsync() OVERRIDE; |
135 | 135 |
136 private: | 136 private: |
137 // Callback for Search(). | 137 // Callback for Search(). |
138 void OnSearch(drive::FileError error, | 138 void OnSearch(drive::FileError error, |
139 const GURL& next_link, | 139 const GURL& next_link, |
140 scoped_ptr<std::vector<drive::SearchResultInfo> > result_paths); | 140 scoped_ptr<std::vector<drive::SearchResultInfo> > result_paths); |
141 | 141 |
142 // Called when |result_paths| in OnSearch() are converted to a list of | 142 // Called when |result_paths| in OnSearch() are converted to a list of |
143 // entry definitions. | 143 // entry definitions. |
144 void OnEntryDefinitionList( | 144 void OnEntryDefinitionList( |
145 const GURL& next_link, | 145 const GURL& next_link, |
146 scoped_ptr<SearchResultInfoList> search_result_info_list, | 146 scoped_ptr<SearchResultInfoList> search_result_info_list, |
147 scoped_ptr<file_manager::util::EntryDefinitionList> | 147 scoped_ptr<file_manager::util::EntryDefinitionList> |
148 entry_definition_list); | 148 entry_definition_list); |
149 }; | 149 }; |
150 | 150 |
151 // Similar to FileBrowserPrivateSearchDriveFunction but this one is used for | 151 // Similar to FileBrowserPrivateSearchDriveFunction but this one is used for |
152 // searching drive metadata which is stored locally. | 152 // searching drive metadata which is stored locally. |
153 class FileBrowserPrivateSearchDriveMetadataFunction | 153 class FileBrowserPrivateSearchDriveMetadataFunction |
154 : public LoggedAsyncExtensionFunction { | 154 : public LoggedAsyncExtensionFunction { |
155 public: | 155 public: |
156 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.searchDriveMetadata", | 156 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.searchDriveMetadata", |
157 FILEBROWSERPRIVATE_SEARCHDRIVEMETADATA) | 157 FILEBROWSERPRIVATE_SEARCHDRIVEMETADATA) |
158 | 158 |
159 protected: | 159 protected: |
160 virtual ~FileBrowserPrivateSearchDriveMetadataFunction() {} | 160 virtual ~FileBrowserPrivateSearchDriveMetadataFunction() {} |
161 | 161 |
162 virtual bool RunImpl() OVERRIDE; | 162 virtual bool RunAsync() OVERRIDE; |
163 | 163 |
164 private: | 164 private: |
165 // Callback for SearchMetadata(); | 165 // Callback for SearchMetadata(); |
166 void OnSearchMetadata(drive::FileError error, | 166 void OnSearchMetadata(drive::FileError error, |
167 scoped_ptr<drive::MetadataSearchResultVector> results); | 167 scoped_ptr<drive::MetadataSearchResultVector> results); |
168 | 168 |
169 // Called when |results| in OnSearchMetadata() are converted to a list of | 169 // Called when |results| in OnSearchMetadata() are converted to a list of |
170 // entry definitions. | 170 // entry definitions. |
171 void OnEntryDefinitionList( | 171 void OnEntryDefinitionList( |
172 scoped_ptr<drive::MetadataSearchResultVector> search_result_info_list, | 172 scoped_ptr<drive::MetadataSearchResultVector> search_result_info_list, |
(...skipping 19 matching lines...) Expand all Loading... |
192 class FileBrowserPrivateRequestAccessTokenFunction | 192 class FileBrowserPrivateRequestAccessTokenFunction |
193 : public LoggedAsyncExtensionFunction { | 193 : public LoggedAsyncExtensionFunction { |
194 public: | 194 public: |
195 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.requestAccessToken", | 195 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.requestAccessToken", |
196 FILEBROWSERPRIVATE_REQUESTACCESSTOKEN) | 196 FILEBROWSERPRIVATE_REQUESTACCESSTOKEN) |
197 | 197 |
198 protected: | 198 protected: |
199 virtual ~FileBrowserPrivateRequestAccessTokenFunction() {} | 199 virtual ~FileBrowserPrivateRequestAccessTokenFunction() {} |
200 | 200 |
201 // AsyncExtensionFunction overrides. | 201 // AsyncExtensionFunction overrides. |
202 virtual bool RunImpl() OVERRIDE; | 202 virtual bool RunAsync() OVERRIDE; |
203 | 203 |
204 // Callback with a cached auth token (if available) or a fetched one. | 204 // Callback with a cached auth token (if available) or a fetched one. |
205 void OnAccessTokenFetched(google_apis::GDataErrorCode code, | 205 void OnAccessTokenFetched(google_apis::GDataErrorCode code, |
206 const std::string& access_token); | 206 const std::string& access_token); |
207 }; | 207 }; |
208 | 208 |
209 // Implements the chrome.fileBrowserPrivate.getShareUrl method. | 209 // Implements the chrome.fileBrowserPrivate.getShareUrl method. |
210 class FileBrowserPrivateGetShareUrlFunction | 210 class FileBrowserPrivateGetShareUrlFunction |
211 : public LoggedAsyncExtensionFunction { | 211 : public LoggedAsyncExtensionFunction { |
212 public: | 212 public: |
213 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getShareUrl", | 213 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getShareUrl", |
214 FILEBROWSERPRIVATE_GETSHAREURL) | 214 FILEBROWSERPRIVATE_GETSHAREURL) |
215 | 215 |
216 protected: | 216 protected: |
217 virtual ~FileBrowserPrivateGetShareUrlFunction() {} | 217 virtual ~FileBrowserPrivateGetShareUrlFunction() {} |
218 | 218 |
219 // AsyncExtensionFunction overrides. | 219 // AsyncExtensionFunction overrides. |
220 virtual bool RunImpl() OVERRIDE; | 220 virtual bool RunAsync() OVERRIDE; |
221 | 221 |
222 // Callback with an url to the sharing dialog as |share_url|, called by | 222 // Callback with an url to the sharing dialog as |share_url|, called by |
223 // FileSystem::GetShareUrl. | 223 // FileSystem::GetShareUrl. |
224 void OnGetShareUrl(drive::FileError error, const GURL& share_url); | 224 void OnGetShareUrl(drive::FileError error, const GURL& share_url); |
225 }; | 225 }; |
226 | 226 |
227 // Implements the chrome.fileBrowserPrivate.requestDriveShare method. | 227 // Implements the chrome.fileBrowserPrivate.requestDriveShare method. |
228 class FileBrowserPrivateRequestDriveShareFunction | 228 class FileBrowserPrivateRequestDriveShareFunction |
229 : public LoggedAsyncExtensionFunction { | 229 : public LoggedAsyncExtensionFunction { |
230 public: | 230 public: |
231 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.requestDriveShare", | 231 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.requestDriveShare", |
232 FILEBROWSERPRIVATE_REQUESTDRIVESHARE); | 232 FILEBROWSERPRIVATE_REQUESTDRIVESHARE); |
233 | 233 |
234 protected: | 234 protected: |
235 virtual ~FileBrowserPrivateRequestDriveShareFunction() {} | 235 virtual ~FileBrowserPrivateRequestDriveShareFunction() {} |
236 virtual bool RunImpl() OVERRIDE; | 236 virtual bool RunAsync() OVERRIDE; |
237 | 237 |
238 private: | 238 private: |
239 // Called back after the drive file system operation is finished. | 239 // Called back after the drive file system operation is finished. |
240 void OnAddPermission(drive::FileError error); | 240 void OnAddPermission(drive::FileError error); |
241 }; | 241 }; |
242 | 242 |
243 } // namespace extensions | 243 } // namespace extensions |
244 | 244 |
245 #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 |