Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/private_api_drive.h

Issue 550863003: Rename fileBrowserPrivate to fileManagerPrivate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/chromeos/drive/file_errors.h" 12 #include "chrome/browser/chromeos/drive/file_errors.h"
13 #include "chrome/browser/chromeos/drive/file_system_interface.h" 13 #include "chrome/browser/chromeos/drive/file_system_interface.h"
14 #include "chrome/browser/chromeos/extensions/file_manager/private_api_base.h" 14 #include "chrome/browser/chromeos/extensions/file_manager/private_api_base.h"
15 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" 15 #include "chrome/browser/chromeos/file_manager/fileapi_util.h"
16 16
17 namespace drive { 17 namespace drive {
18 class FileCacheEntry; 18 class FileCacheEntry;
19 class ResourceEntry; 19 class ResourceEntry;
20 struct SearchResultInfo; 20 struct SearchResultInfo;
21 } 21 }
22 22
23 namespace google_apis { 23 namespace google_apis {
24 class AuthService; 24 class AuthService;
25 } 25 }
26 26
27 namespace extensions { 27 namespace extensions {
28 28
29 namespace api { 29 namespace api {
30 namespace file_browser_private { 30 namespace file_manager_private {
31 struct EntryProperties; 31 struct EntryProperties;
32 } // namespace file_browser_private 32 } // namespace file_manager_private
33 } // namespace api 33 } // namespace api
34 34
35 // Retrieves property information for an entry and returns it as a dictionary. 35 // Retrieves property information for an entry and returns it as a dictionary.
36 // On error, returns a dictionary with the key "error" set to the error number 36 // On error, returns a dictionary with the key "error" set to the error number
37 // (base::File::Error). 37 // (base::File::Error).
38 class FileBrowserPrivateGetEntryPropertiesFunction 38 class FileManagerPrivateGetEntryPropertiesFunction
39 : public LoggedAsyncExtensionFunction { 39 : public LoggedAsyncExtensionFunction {
40 public: 40 public:
41 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getEntryProperties", 41 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.getEntryProperties",
42 FILEBROWSERPRIVATE_GETENTRYPROPERTIES) 42 FILEMANAGERPRIVATE_GETENTRYPROPERTIES)
43 43
44 FileBrowserPrivateGetEntryPropertiesFunction(); 44 FileManagerPrivateGetEntryPropertiesFunction();
45 45
46 protected: 46 protected:
47 virtual ~FileBrowserPrivateGetEntryPropertiesFunction(); 47 virtual ~FileManagerPrivateGetEntryPropertiesFunction();
48 48
49 // AsyncExtensionFunction overrides. 49 // AsyncExtensionFunction overrides.
50 virtual bool RunAsync() OVERRIDE; 50 virtual bool RunAsync() OVERRIDE;
51 51
52 private: 52 private:
53 void CompleteGetEntryProperties( 53 void CompleteGetEntryProperties(
54 size_t index, 54 size_t index,
55 scoped_ptr<api::file_browser_private::EntryProperties> properties, 55 scoped_ptr<api::file_manager_private::EntryProperties> properties,
56 base::File::Error error); 56 base::File::Error error);
57 57
58 size_t processed_count_; 58 size_t processed_count_;
59 std::vector<linked_ptr<api::file_browser_private::EntryProperties> > 59 std::vector<linked_ptr<api::file_manager_private::EntryProperties> >
60 properties_list_; 60 properties_list_;
61 }; 61 };
62 62
63 // Implements the chrome.fileBrowserPrivate.pinDriveFile method. 63 // Implements the chrome.fileManagerPrivate.pinDriveFile method.
64 class FileBrowserPrivatePinDriveFileFunction 64 class FileManagerPrivatePinDriveFileFunction
65 : public LoggedAsyncExtensionFunction { 65 : public LoggedAsyncExtensionFunction {
66 public: 66 public:
67 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.pinDriveFile", 67 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.pinDriveFile",
68 FILEBROWSERPRIVATE_PINDRIVEFILE) 68 FILEMANAGERPRIVATE_PINDRIVEFILE)
69 69
70 protected: 70 protected:
71 virtual ~FileBrowserPrivatePinDriveFileFunction() {} 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 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. 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 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 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 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() 86 // file manager should check if the local paths returned from getDriveFiles()
87 // contain empty paths. 87 // contain empty paths.
88 // TODO(satorux): Should we propagate error types to the JavaScript layer? 88 // TODO(satorux): Should we propagate error types to the JavaScript layer?
89 class FileBrowserPrivateGetDriveFilesFunction 89 class FileManagerPrivateGetDriveFilesFunction
90 : public LoggedAsyncExtensionFunction { 90 : public LoggedAsyncExtensionFunction {
91 public: 91 public:
92 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getDriveFiles", 92 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.getDriveFiles",
93 FILEBROWSERPRIVATE_GETDRIVEFILES) 93 FILEMANAGERPRIVATE_GETDRIVEFILES)
94 94
95 FileBrowserPrivateGetDriveFilesFunction(); 95 FileManagerPrivateGetDriveFilesFunction();
96 96
97 protected: 97 protected:
98 virtual ~FileBrowserPrivateGetDriveFilesFunction(); 98 virtual ~FileManagerPrivateGetDriveFilesFunction();
99 99
100 // AsyncExtensionFunction overrides. 100 // AsyncExtensionFunction overrides.
101 virtual bool RunAsync() OVERRIDE; 101 virtual bool RunAsync() OVERRIDE;
102 102
103 private: 103 private:
104 // Gets the file on the top of the |remaining_drive_paths_| or sends the 104 // Gets the file on the top of the |remaining_drive_paths_| or sends the
105 // response if the queue is empty. 105 // response if the queue is empty.
106 void GetFileOrSendResponse(); 106 void GetFileOrSendResponse();
107 107
108 // Called by FileSystem::GetFile(). Pops the file from 108 // Called by FileSystem::GetFile(). Pops the file from
109 // |remaining_drive_paths_|, and calls GetFileOrSendResponse(). 109 // |remaining_drive_paths_|, and calls GetFileOrSendResponse().
110 void OnFileReady(drive::FileError error, 110 void OnFileReady(drive::FileError error,
111 const base::FilePath& local_path, 111 const base::FilePath& local_path,
112 scoped_ptr<drive::ResourceEntry> entry); 112 scoped_ptr<drive::ResourceEntry> entry);
113 113
114 std::queue<base::FilePath> remaining_drive_paths_; 114 std::queue<base::FilePath> remaining_drive_paths_;
115 std::vector<std::string> local_paths_; 115 std::vector<std::string> local_paths_;
116 }; 116 };
117 117
118 // Implements the chrome.fileBrowserPrivate.cancelFileTransfers method. 118 // Implements the chrome.fileManagerPrivate.cancelFileTransfers method.
119 class FileBrowserPrivateCancelFileTransfersFunction 119 class FileManagerPrivateCancelFileTransfersFunction
120 : public LoggedAsyncExtensionFunction { 120 : public LoggedAsyncExtensionFunction {
121 public: 121 public:
122 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.cancelFileTransfers", 122 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.cancelFileTransfers",
123 FILEBROWSERPRIVATE_CANCELFILETRANSFERS) 123 FILEMANAGERPRIVATE_CANCELFILETRANSFERS)
124 124
125 protected: 125 protected:
126 virtual ~FileBrowserPrivateCancelFileTransfersFunction() {} 126 virtual ~FileManagerPrivateCancelFileTransfersFunction() {}
127 127
128 // AsyncExtensionFunction overrides. 128 // AsyncExtensionFunction overrides.
129 virtual bool RunAsync() OVERRIDE; 129 virtual bool RunAsync() OVERRIDE;
130 }; 130 };
131 131
132 class FileBrowserPrivateSearchDriveFunction 132 class FileManagerPrivateSearchDriveFunction
133 : public LoggedAsyncExtensionFunction { 133 : public LoggedAsyncExtensionFunction {
134 public: 134 public:
135 typedef std::vector<drive::SearchResultInfo> SearchResultInfoList; 135 typedef std::vector<drive::SearchResultInfo> SearchResultInfoList;
136 136
137 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.searchDrive", 137 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.searchDrive",
138 FILEBROWSERPRIVATE_SEARCHDRIVE) 138 FILEMANAGERPRIVATE_SEARCHDRIVE)
139 139
140 protected: 140 protected:
141 virtual ~FileBrowserPrivateSearchDriveFunction() {} 141 virtual ~FileManagerPrivateSearchDriveFunction() {}
142 142
143 virtual bool RunAsync() OVERRIDE; 143 virtual bool RunAsync() OVERRIDE;
144 144
145 private: 145 private:
146 // Callback for Search(). 146 // Callback for Search().
147 void OnSearch(drive::FileError error, 147 void OnSearch(drive::FileError error,
148 const GURL& next_link, 148 const GURL& next_link,
149 scoped_ptr<std::vector<drive::SearchResultInfo> > result_paths); 149 scoped_ptr<std::vector<drive::SearchResultInfo> > result_paths);
150 150
151 // Called when |result_paths| in OnSearch() are converted to a list of 151 // Called when |result_paths| in OnSearch() are converted to a list of
152 // entry definitions. 152 // entry definitions.
153 void OnEntryDefinitionList( 153 void OnEntryDefinitionList(
154 const GURL& next_link, 154 const GURL& next_link,
155 scoped_ptr<SearchResultInfoList> search_result_info_list, 155 scoped_ptr<SearchResultInfoList> search_result_info_list,
156 scoped_ptr<file_manager::util::EntryDefinitionList> 156 scoped_ptr<file_manager::util::EntryDefinitionList>
157 entry_definition_list); 157 entry_definition_list);
158 }; 158 };
159 159
160 // Similar to FileBrowserPrivateSearchDriveFunction but this one is used for 160 // Similar to FileManagerPrivateSearchDriveFunction but this one is used for
161 // searching drive metadata which is stored locally. 161 // searching drive metadata which is stored locally.
162 class FileBrowserPrivateSearchDriveMetadataFunction 162 class FileManagerPrivateSearchDriveMetadataFunction
163 : public LoggedAsyncExtensionFunction { 163 : public LoggedAsyncExtensionFunction {
164 public: 164 public:
165 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.searchDriveMetadata", 165 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.searchDriveMetadata",
166 FILEBROWSERPRIVATE_SEARCHDRIVEMETADATA) 166 FILEMANAGERPRIVATE_SEARCHDRIVEMETADATA)
167 167
168 protected: 168 protected:
169 virtual ~FileBrowserPrivateSearchDriveMetadataFunction() {} 169 virtual ~FileManagerPrivateSearchDriveMetadataFunction() {}
170 170
171 virtual bool RunAsync() OVERRIDE; 171 virtual bool RunAsync() OVERRIDE;
172 172
173 private: 173 private:
174 // Callback for SearchMetadata(); 174 // Callback for SearchMetadata();
175 void OnSearchMetadata(drive::FileError error, 175 void OnSearchMetadata(drive::FileError error,
176 scoped_ptr<drive::MetadataSearchResultVector> results); 176 scoped_ptr<drive::MetadataSearchResultVector> results);
177 177
178 // Called when |results| in OnSearchMetadata() are converted to a list of 178 // Called when |results| in OnSearchMetadata() are converted to a list of
179 // entry definitions. 179 // entry definitions.
180 void OnEntryDefinitionList( 180 void OnEntryDefinitionList(
181 scoped_ptr<drive::MetadataSearchResultVector> search_result_info_list, 181 scoped_ptr<drive::MetadataSearchResultVector> search_result_info_list,
182 scoped_ptr<file_manager::util::EntryDefinitionList> 182 scoped_ptr<file_manager::util::EntryDefinitionList>
183 entry_definition_list); 183 entry_definition_list);
184 }; 184 };
185 185
186 // Implements the chrome.fileBrowserPrivate.getDriveConnectionState method. 186 // Implements the chrome.fileManagerPrivate.getDriveConnectionState method.
187 class FileBrowserPrivateGetDriveConnectionStateFunction 187 class FileManagerPrivateGetDriveConnectionStateFunction
188 : public ChromeSyncExtensionFunction { 188 : public ChromeSyncExtensionFunction {
189 public: 189 public:
190 DECLARE_EXTENSION_FUNCTION( 190 DECLARE_EXTENSION_FUNCTION(
191 "fileBrowserPrivate.getDriveConnectionState", 191 "fileManagerPrivate.getDriveConnectionState",
192 FILEBROWSERPRIVATE_GETDRIVECONNECTIONSTATE); 192 FILEMANAGERPRIVATE_GETDRIVECONNECTIONSTATE);
193 193
194 protected: 194 protected:
195 virtual ~FileBrowserPrivateGetDriveConnectionStateFunction() {} 195 virtual ~FileManagerPrivateGetDriveConnectionStateFunction() {}
196 196
197 virtual bool RunSync() OVERRIDE; 197 virtual bool RunSync() OVERRIDE;
198 }; 198 };
199 199
200 // Implements the chrome.fileBrowserPrivate.requestAccessToken method. 200 // Implements the chrome.fileManagerPrivate.requestAccessToken method.
201 class FileBrowserPrivateRequestAccessTokenFunction 201 class FileManagerPrivateRequestAccessTokenFunction
202 : public LoggedAsyncExtensionFunction { 202 : public LoggedAsyncExtensionFunction {
203 public: 203 public:
204 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.requestAccessToken", 204 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.requestAccessToken",
205 FILEBROWSERPRIVATE_REQUESTACCESSTOKEN) 205 FILEMANAGERPRIVATE_REQUESTACCESSTOKEN)
206 206
207 protected: 207 protected:
208 virtual ~FileBrowserPrivateRequestAccessTokenFunction() {} 208 virtual ~FileManagerPrivateRequestAccessTokenFunction() {}
209 209
210 // AsyncExtensionFunction overrides. 210 // AsyncExtensionFunction overrides.
211 virtual bool RunAsync() OVERRIDE; 211 virtual bool RunAsync() OVERRIDE;
212 212
213 // Callback with a cached auth token (if available) or a fetched one. 213 // Callback with a cached auth token (if available) or a fetched one.
214 void OnAccessTokenFetched(google_apis::GDataErrorCode code, 214 void OnAccessTokenFetched(google_apis::GDataErrorCode code,
215 const std::string& access_token); 215 const std::string& access_token);
216 }; 216 };
217 217
218 // Implements the chrome.fileBrowserPrivate.getShareUrl method. 218 // Implements the chrome.fileManagerPrivate.getShareUrl method.
219 class FileBrowserPrivateGetShareUrlFunction 219 class FileManagerPrivateGetShareUrlFunction
220 : public LoggedAsyncExtensionFunction { 220 : public LoggedAsyncExtensionFunction {
221 public: 221 public:
222 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getShareUrl", 222 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.getShareUrl",
223 FILEBROWSERPRIVATE_GETSHAREURL) 223 FILEMANAGERPRIVATE_GETSHAREURL)
224 224
225 protected: 225 protected:
226 virtual ~FileBrowserPrivateGetShareUrlFunction() {} 226 virtual ~FileManagerPrivateGetShareUrlFunction() {}
227 227
228 // AsyncExtensionFunction overrides. 228 // AsyncExtensionFunction overrides.
229 virtual bool RunAsync() OVERRIDE; 229 virtual bool RunAsync() OVERRIDE;
230 230
231 // Callback with an url to the sharing dialog as |share_url|, called by 231 // Callback with an url to the sharing dialog as |share_url|, called by
232 // FileSystem::GetShareUrl. 232 // FileSystem::GetShareUrl.
233 void OnGetShareUrl(drive::FileError error, const GURL& share_url); 233 void OnGetShareUrl(drive::FileError error, const GURL& share_url);
234 }; 234 };
235 235
236 // Implements the chrome.fileBrowserPrivate.requestDriveShare method. 236 // Implements the chrome.fileManagerPrivate.requestDriveShare method.
237 class FileBrowserPrivateRequestDriveShareFunction 237 class FileManagerPrivateRequestDriveShareFunction
238 : public LoggedAsyncExtensionFunction { 238 : public LoggedAsyncExtensionFunction {
239 public: 239 public:
240 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.requestDriveShare", 240 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.requestDriveShare",
241 FILEBROWSERPRIVATE_REQUESTDRIVESHARE); 241 FILEMANAGERPRIVATE_REQUESTDRIVESHARE);
242 242
243 protected: 243 protected:
244 virtual ~FileBrowserPrivateRequestDriveShareFunction() {} 244 virtual ~FileManagerPrivateRequestDriveShareFunction() {}
245 virtual bool RunAsync() OVERRIDE; 245 virtual bool RunAsync() OVERRIDE;
246 246
247 private: 247 private:
248 // Called back after the drive file system operation is finished. 248 // Called back after the drive file system operation is finished.
249 void OnAddPermission(drive::FileError error); 249 void OnAddPermission(drive::FileError error);
250 }; 250 };
251 251
252 // Implements the chrome.fileBrowserPrivate.getDownloadUrl method. 252 // Implements the chrome.fileManagerPrivate.getDownloadUrl method.
253 class FileBrowserPrivateGetDownloadUrlFunction 253 class FileManagerPrivateGetDownloadUrlFunction
254 : public LoggedAsyncExtensionFunction { 254 : public LoggedAsyncExtensionFunction {
255 public: 255 public:
256 FileBrowserPrivateGetDownloadUrlFunction(); 256 FileManagerPrivateGetDownloadUrlFunction();
257 257
258 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getDownloadUrl", 258 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.getDownloadUrl",
259 FILEBROWSERPRIVATE_GETDOWNLOADURL) 259 FILEMANAGERPRIVATE_GETDOWNLOADURL)
260 260
261 protected: 261 protected:
262 virtual ~FileBrowserPrivateGetDownloadUrlFunction(); 262 virtual ~FileManagerPrivateGetDownloadUrlFunction();
263 263
264 // AsyncExtensionFunction overrides. 264 // AsyncExtensionFunction overrides.
265 virtual bool RunAsync() OVERRIDE; 265 virtual bool RunAsync() OVERRIDE;
266 266
267 void OnGetResourceEntry(drive::FileError error, 267 void OnGetResourceEntry(drive::FileError error,
268 scoped_ptr<drive::ResourceEntry> entry); 268 scoped_ptr<drive::ResourceEntry> entry);
269 269
270 // Callback with an |access_token|, called by 270 // Callback with an |access_token|, called by
271 // drive::DriveReadonlyTokenFetcher. 271 // drive::DriveReadonlyTokenFetcher.
272 void OnTokenFetched(google_apis::GDataErrorCode code, 272 void OnTokenFetched(google_apis::GDataErrorCode code,
273 const std::string& access_token); 273 const std::string& access_token);
274 274
275 private: 275 private:
276 std::string download_url_; 276 std::string download_url_;
277 scoped_ptr<google_apis::AuthService> auth_service_; 277 scoped_ptr<google_apis::AuthService> auth_service_;
278 }; 278 };
279 279
280 } // namespace extensions 280 } // namespace extensions
281 281
282 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_DRIVE_H_ 282 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_DRIVE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698