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

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

Issue 23715003: Files.app: Rename the FileBrowserPrivateAPI's functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed the comments. Created 7 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 | Annotate | Revision Log
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 "chrome/browser/chromeos/drive/file_errors.h" 10 #include "chrome/browser/chromeos/drive/file_errors.h"
11 #include "chrome/browser/chromeos/drive/file_system_interface.h" 11 #include "chrome/browser/chromeos/drive/file_system_interface.h"
12 #include "chrome/browser/chromeos/extensions/file_manager/private_api_base.h" 12 #include "chrome/browser/chromeos/extensions/file_manager/private_api_base.h"
13 13
14 namespace drive { 14 namespace drive {
15 class FileCacheEntry; 15 class FileCacheEntry;
16 class ResourceEntry; 16 class ResourceEntry;
17 struct DriveAppInfo; 17 struct DriveAppInfo;
18 struct SearchResultInfo; 18 struct SearchResultInfo;
19 } 19 }
20 20
21 namespace extensions { 21 namespace extensions {
22 22
23 // Retrieves property information for an entry and returns it as a dictionary. 23 // Retrieves property information for an entry and returns it as a dictionary.
24 // On error, returns a dictionary with the key "error" set to the error number 24 // On error, returns a dictionary with the key "error" set to the error number
25 // (drive::FileError). 25 // (drive::FileError).
26 class GetDriveEntryPropertiesFunction : public LoggedAsyncExtensionFunction { 26 class FileBrowserPrivateGetDriveEntryPropertiesFunction
27 : public LoggedAsyncExtensionFunction {
27 public: 28 public:
28 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getDriveEntryProperties", 29 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getDriveEntryProperties",
29 FILEBROWSERPRIVATE_GETDRIVEFILEPROPERTIES) 30 FILEBROWSERPRIVATE_GETDRIVEFILEPROPERTIES)
30 31
31 GetDriveEntryPropertiesFunction(); 32 FileBrowserPrivateGetDriveEntryPropertiesFunction();
32 33
33 protected: 34 protected:
34 virtual ~GetDriveEntryPropertiesFunction(); 35 virtual ~FileBrowserPrivateGetDriveEntryPropertiesFunction();
35 36
36 // AsyncExtensionFunction overrides. 37 // AsyncExtensionFunction overrides.
37 virtual bool RunImpl() OVERRIDE; 38 virtual bool RunImpl() OVERRIDE;
38 39
39 private: 40 private:
40 void OnGetFileInfo(drive::FileError error, 41 void OnGetFileInfo(drive::FileError error,
41 scoped_ptr<drive::ResourceEntry> entry); 42 scoped_ptr<drive::ResourceEntry> entry);
42 43
43 void CacheStateReceived(bool success, 44 void CacheStateReceived(bool success,
44 const drive::FileCacheEntry& cache_entry); 45 const drive::FileCacheEntry& cache_entry);
45 46
46 void CompleteGetFileProperties(drive::FileError error); 47 void CompleteGetFileProperties(drive::FileError error);
47 48
48 base::FilePath file_path_; 49 base::FilePath file_path_;
49 scoped_ptr<base::DictionaryValue> properties_; 50 scoped_ptr<base::DictionaryValue> properties_;
50 }; 51 };
51 52
52 // Implements the chrome.fileBrowserPrivate.pinDriveFile method. 53 // Implements the chrome.fileBrowserPrivate.pinDriveFile method.
53 class PinDriveFileFunction : public LoggedAsyncExtensionFunction { 54 class FileBrowserPrivatePinDriveFileFunction
55 : public LoggedAsyncExtensionFunction {
54 public: 56 public:
55 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.pinDriveFile", 57 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.pinDriveFile",
56 FILEBROWSERPRIVATE_PINDRIVEFILE) 58 FILEBROWSERPRIVATE_PINDRIVEFILE)
57 59
58 PinDriveFileFunction(); 60 FileBrowserPrivatePinDriveFileFunction();
59 61
60 protected: 62 protected:
61 virtual ~PinDriveFileFunction(); 63 virtual ~FileBrowserPrivatePinDriveFileFunction();
62 64
63 // AsyncExtensionFunction overrides. 65 // AsyncExtensionFunction overrides.
64 virtual bool RunImpl() OVERRIDE; 66 virtual bool RunImpl() OVERRIDE;
65 67
66 private: 68 private:
67 // Callback for RunImpl(). 69 // Callback for RunImpl().
68 void OnPinStateSet(drive::FileError error); 70 void OnPinStateSet(drive::FileError error);
69 }; 71 };
70 72
71 // Get drive files for the given list of file URLs. Initiate downloading of 73 // Get drive files for the given list of file URLs. Initiate downloading of
72 // drive files if these are not cached. Return a list of local file names. 74 // drive files if these are not cached. Return a list of local file names.
73 // This function puts empty strings instead of local paths for files could 75 // This function puts empty strings instead of local paths for files could
74 // not be obtained. For instance, this can happen if the user specifies a new 76 // not be obtained. For instance, this can happen if the user specifies a new
75 // file name to save a file on drive. There may be other reasons to fail. The 77 // file name to save a file on drive. There may be other reasons to fail. The
76 // file manager should check if the local paths returned from getDriveFiles() 78 // file manager should check if the local paths returned from getDriveFiles()
77 // contain empty paths. 79 // contain empty paths.
78 // TODO(satorux): Should we propagate error types to the JavaScript layer? 80 // TODO(satorux): Should we propagate error types to the JavaScript layer?
79 class GetDriveFilesFunction : public LoggedAsyncExtensionFunction { 81 class FileBrowserPrivateGetDriveFilesFunction
82 : public LoggedAsyncExtensionFunction {
80 public: 83 public:
81 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getDriveFiles", 84 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getDriveFiles",
82 FILEBROWSERPRIVATE_GETDRIVEFILES) 85 FILEBROWSERPRIVATE_GETDRIVEFILES)
83 86
84 GetDriveFilesFunction(); 87 FileBrowserPrivateGetDriveFilesFunction();
85 88
86 protected: 89 protected:
87 virtual ~GetDriveFilesFunction(); 90 virtual ~FileBrowserPrivateGetDriveFilesFunction();
88 91
89 // AsyncExtensionFunction overrides. 92 // AsyncExtensionFunction overrides.
90 virtual bool RunImpl() OVERRIDE; 93 virtual bool RunImpl() OVERRIDE;
91 94
92 private: 95 private:
93 // Gets the file on the top of the |remaining_drive_paths_| or sends the 96 // Gets the file on the top of the |remaining_drive_paths_| or sends the
94 // response if the queue is empty. 97 // response if the queue is empty.
95 void GetFileOrSendResponse(); 98 void GetFileOrSendResponse();
96 99
97 // Called by FileSystem::GetFile(). Pops the file from 100 // Called by FileSystem::GetFile(). Pops the file from
98 // |remaining_drive_paths_|, and calls GetFileOrSendResponse(). 101 // |remaining_drive_paths_|, and calls GetFileOrSendResponse().
99 void OnFileReady(drive::FileError error, 102 void OnFileReady(drive::FileError error,
100 const base::FilePath& local_path, 103 const base::FilePath& local_path,
101 scoped_ptr<drive::ResourceEntry> entry); 104 scoped_ptr<drive::ResourceEntry> entry);
102 105
103 std::queue<base::FilePath> remaining_drive_paths_; 106 std::queue<base::FilePath> remaining_drive_paths_;
104 ListValue* local_paths_; 107 ListValue* local_paths_;
105 }; 108 };
106 109
107 // Implements the chrome.fileBrowserPrivate.cancelFileTransfers method. 110 // Implements the chrome.fileBrowserPrivate.cancelFileTransfers method.
108 class CancelFileTransfersFunction : public LoggedAsyncExtensionFunction { 111 class FileBrowserPrivateCancelFileTransfersFunction
112 : public LoggedAsyncExtensionFunction {
109 public: 113 public:
110 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.cancelFileTransfers", 114 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.cancelFileTransfers",
111 FILEBROWSERPRIVATE_CANCELFILETRANSFERS) 115 FILEBROWSERPRIVATE_CANCELFILETRANSFERS)
112 116
113 CancelFileTransfersFunction(); 117 FileBrowserPrivateCancelFileTransfersFunction();
114 118
115 protected: 119 protected:
116 virtual ~CancelFileTransfersFunction(); 120 virtual ~FileBrowserPrivateCancelFileTransfersFunction();
117 121
118 // AsyncExtensionFunction overrides. 122 // AsyncExtensionFunction overrides.
119 virtual bool RunImpl() OVERRIDE; 123 virtual bool RunImpl() OVERRIDE;
120 }; 124 };
121 125
122 class SearchDriveFunction : public LoggedAsyncExtensionFunction { 126 class FileBrowserPrivateSearchDriveFunction
127 : public LoggedAsyncExtensionFunction {
123 public: 128 public:
124 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.searchDrive", 129 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.searchDrive",
125 FILEBROWSERPRIVATE_SEARCHDRIVE) 130 FILEBROWSERPRIVATE_SEARCHDRIVE)
126 131
127 SearchDriveFunction(); 132 FileBrowserPrivateSearchDriveFunction();
128 133
129 protected: 134 protected:
130 virtual ~SearchDriveFunction(); 135 virtual ~FileBrowserPrivateSearchDriveFunction();
131 136
132 virtual bool RunImpl() OVERRIDE; 137 virtual bool RunImpl() OVERRIDE;
133 138
134 private: 139 private:
135 // Callback for Search(). 140 // Callback for Search().
136 void OnSearch(drive::FileError error, 141 void OnSearch(drive::FileError error,
137 const std::string& next_feed, 142 const std::string& next_feed,
138 scoped_ptr<std::vector<drive::SearchResultInfo> > result_paths); 143 scoped_ptr<std::vector<drive::SearchResultInfo> > result_paths);
139 }; 144 };
140 145
141 // Similar to SearchDriveFunction but this one is used for searching drive 146 // Similar to FileBrowserPrivateSearchDriveFunction but this one is used for
142 // metadata which is stored locally. 147 // searching drive metadata which is stored locally.
143 class SearchDriveMetadataFunction : public LoggedAsyncExtensionFunction { 148 class FileBrowserPrivateSearchDriveMetadataFunction
149 : public LoggedAsyncExtensionFunction {
144 public: 150 public:
145 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.searchDriveMetadata", 151 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.searchDriveMetadata",
146 FILEBROWSERPRIVATE_SEARCHDRIVEMETADATA) 152 FILEBROWSERPRIVATE_SEARCHDRIVEMETADATA)
147 153
148 SearchDriveMetadataFunction(); 154 FileBrowserPrivateSearchDriveMetadataFunction();
149 155
150 protected: 156 protected:
151 virtual ~SearchDriveMetadataFunction(); 157 virtual ~FileBrowserPrivateSearchDriveMetadataFunction();
152 158
153 virtual bool RunImpl() OVERRIDE; 159 virtual bool RunImpl() OVERRIDE;
154 160
155 private: 161 private:
156 // Callback for SearchMetadata(); 162 // Callback for SearchMetadata();
157 void OnSearchMetadata(drive::FileError error, 163 void OnSearchMetadata(drive::FileError error,
158 scoped_ptr<drive::MetadataSearchResultVector> results); 164 scoped_ptr<drive::MetadataSearchResultVector> results);
159 }; 165 };
160 166
161 class ClearDriveCacheFunction : public LoggedAsyncExtensionFunction { 167 class FileBrowserPrivateClearDriveCacheFunction
168 : public LoggedAsyncExtensionFunction {
162 public: 169 public:
163 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.clearDriveCache", 170 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.clearDriveCache",
164 FILEBROWSERPRIVATE_CLEARDRIVECACHE) 171 FILEBROWSERPRIVATE_CLEARDRIVECACHE)
165 172
166 ClearDriveCacheFunction(); 173 FileBrowserPrivateClearDriveCacheFunction();
167 174
168 protected: 175 protected:
169 virtual ~ClearDriveCacheFunction(); 176 virtual ~FileBrowserPrivateClearDriveCacheFunction();
170 177
171 virtual bool RunImpl() OVERRIDE; 178 virtual bool RunImpl() OVERRIDE;
172 }; 179 };
173 180
174 // Implements the chrome.fileBrowserPrivate.getDriveConnectionState method. 181 // Implements the chrome.fileBrowserPrivate.getDriveConnectionState method.
175 class GetDriveConnectionStateFunction : public SyncExtensionFunction { 182 class FileBrowserPrivateGetDriveConnectionStateFunction
183 : public SyncExtensionFunction {
176 public: 184 public:
177 DECLARE_EXTENSION_FUNCTION( 185 DECLARE_EXTENSION_FUNCTION(
178 "fileBrowserPrivate.getDriveConnectionState", 186 "fileBrowserPrivate.getDriveConnectionState",
179 FILEBROWSERPRIVATE_GETDRIVECONNECTIONSTATE); 187 FILEBROWSERPRIVATE_GETDRIVECONNECTIONSTATE);
180 188
181 GetDriveConnectionStateFunction(); 189 FileBrowserPrivateGetDriveConnectionStateFunction();
182 190
183 protected: 191 protected:
184 virtual ~GetDriveConnectionStateFunction(); 192 virtual ~FileBrowserPrivateGetDriveConnectionStateFunction();
185 193
186 virtual bool RunImpl() OVERRIDE; 194 virtual bool RunImpl() OVERRIDE;
187 }; 195 };
188 196
189 // Implements the chrome.fileBrowserPrivate.requestAccessToken method. 197 // Implements the chrome.fileBrowserPrivate.requestAccessToken method.
190 class RequestAccessTokenFunction : public LoggedAsyncExtensionFunction { 198 class FileBrowserPrivateRequestAccessTokenFunction
199 : public LoggedAsyncExtensionFunction {
191 public: 200 public:
192 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.requestAccessToken", 201 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.requestAccessToken",
193 FILEBROWSERPRIVATE_REQUESTACCESSTOKEN) 202 FILEBROWSERPRIVATE_REQUESTACCESSTOKEN)
194 203
195 RequestAccessTokenFunction(); 204 FileBrowserPrivateRequestAccessTokenFunction();
196 205
197 protected: 206 protected:
198 virtual ~RequestAccessTokenFunction(); 207 virtual ~FileBrowserPrivateRequestAccessTokenFunction();
199 208
200 // AsyncExtensionFunction overrides. 209 // AsyncExtensionFunction overrides.
201 virtual bool RunImpl() OVERRIDE; 210 virtual bool RunImpl() OVERRIDE;
202 211
203 // Callback with a cached auth token (if available) or a fetched one. 212 // Callback with a cached auth token (if available) or a fetched one.
204 void OnAccessTokenFetched(google_apis::GDataErrorCode code, 213 void OnAccessTokenFetched(google_apis::GDataErrorCode code,
205 const std::string& access_token); 214 const std::string& access_token);
206 }; 215 };
207 216
208 // Implements the chrome.fileBrowserPrivate.getShareUrl method. 217 // Implements the chrome.fileBrowserPrivate.getShareUrl method.
209 class GetShareUrlFunction : public LoggedAsyncExtensionFunction { 218 class FileBrowserPrivateGetShareUrlFunction
219 : public LoggedAsyncExtensionFunction {
210 public: 220 public:
211 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getShareUrl", 221 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getShareUrl",
212 FILEBROWSERPRIVATE_GETSHAREURL) 222 FILEBROWSERPRIVATE_GETSHAREURL)
213 223
214 GetShareUrlFunction(); 224 FileBrowserPrivateGetShareUrlFunction();
215 225
216 protected: 226 protected:
217 virtual ~GetShareUrlFunction(); 227 virtual ~FileBrowserPrivateGetShareUrlFunction();
218 228
219 // AsyncExtensionFunction overrides. 229 // AsyncExtensionFunction overrides.
220 virtual bool RunImpl() OVERRIDE; 230 virtual bool RunImpl() OVERRIDE;
221 231
222 // Callback with an url to the sharing dialog as |share_url|, called by 232 // Callback with an url to the sharing dialog as |share_url|, called by
223 // FileSystem::GetShareUrl. 233 // FileSystem::GetShareUrl.
224 void OnGetShareUrl(drive::FileError error, const GURL& share_url); 234 void OnGetShareUrl(drive::FileError error, const GURL& share_url);
225 }; 235 };
226 236
227 } // namespace extensions 237 } // namespace extensions
228 238
229 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_DRIVE_H_ 239 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_DRIVE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698