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

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

Issue 23581006: Reland 220012: Move the functions of filebrowserPrivateApi from the file_manager namespace to the e… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 file_manager { 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 GetDriveEntryPropertiesFunction
27 : public file_manager::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 GetDriveEntryPropertiesFunction();
32 33
33 protected: 34 protected:
34 virtual ~GetDriveEntryPropertiesFunction(); 35 virtual ~GetDriveEntryPropertiesFunction();
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 PinDriveFileFunction : public file_manager::LoggedAsyncExtensionFunction {
54 public: 55 public:
55 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.pinDriveFile", 56 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.pinDriveFile",
56 FILEBROWSERPRIVATE_PINDRIVEFILE) 57 FILEBROWSERPRIVATE_PINDRIVEFILE)
57 58
58 PinDriveFileFunction(); 59 PinDriveFileFunction();
59 60
60 protected: 61 protected:
61 virtual ~PinDriveFileFunction(); 62 virtual ~PinDriveFileFunction();
62 63
63 // AsyncExtensionFunction overrides. 64 // AsyncExtensionFunction overrides.
64 virtual bool RunImpl() OVERRIDE; 65 virtual bool RunImpl() OVERRIDE;
65 66
66 private: 67 private:
67 // Callback for RunImpl(). 68 // Callback for RunImpl().
68 void OnPinStateSet(drive::FileError error); 69 void OnPinStateSet(drive::FileError error);
69 }; 70 };
70 71
71 // 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
72 // 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.
73 // 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
74 // 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
75 // 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
76 // file manager should check if the local paths returned from getDriveFiles() 77 // file manager should check if the local paths returned from getDriveFiles()
77 // contain empty paths. 78 // contain empty paths.
78 // TODO(satorux): Should we propagate error types to the JavaScript layer? 79 // TODO(satorux): Should we propagate error types to the JavaScript layer?
79 class GetDriveFilesFunction : public LoggedAsyncExtensionFunction { 80 class GetDriveFilesFunction
81 : public file_manager::LoggedAsyncExtensionFunction {
80 public: 82 public:
81 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getDriveFiles", 83 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getDriveFiles",
82 FILEBROWSERPRIVATE_GETDRIVEFILES) 84 FILEBROWSERPRIVATE_GETDRIVEFILES)
83 85
84 GetDriveFilesFunction(); 86 GetDriveFilesFunction();
85 87
86 protected: 88 protected:
87 virtual ~GetDriveFilesFunction(); 89 virtual ~GetDriveFilesFunction();
88 90
89 // AsyncExtensionFunction overrides. 91 // AsyncExtensionFunction overrides.
90 virtual bool RunImpl() OVERRIDE; 92 virtual bool RunImpl() OVERRIDE;
91 93
92 private: 94 private:
93 // 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
94 // response if the queue is empty. 96 // response if the queue is empty.
95 void GetFileOrSendResponse(); 97 void GetFileOrSendResponse();
96 98
97 // Called by FileSystem::GetFile(). Pops the file from 99 // Called by FileSystem::GetFile(). Pops the file from
98 // |remaining_drive_paths_|, and calls GetFileOrSendResponse(). 100 // |remaining_drive_paths_|, and calls GetFileOrSendResponse().
99 void OnFileReady(drive::FileError error, 101 void OnFileReady(drive::FileError error,
100 const base::FilePath& local_path, 102 const base::FilePath& local_path,
101 scoped_ptr<drive::ResourceEntry> entry); 103 scoped_ptr<drive::ResourceEntry> entry);
102 104
103 std::queue<base::FilePath> remaining_drive_paths_; 105 std::queue<base::FilePath> remaining_drive_paths_;
104 ListValue* local_paths_; 106 ListValue* local_paths_;
105 }; 107 };
106 108
107 // Implements the chrome.fileBrowserPrivate.cancelFileTransfers method. 109 // Implements the chrome.fileBrowserPrivate.cancelFileTransfers method.
108 class CancelFileTransfersFunction : public LoggedAsyncExtensionFunction { 110 class CancelFileTransfersFunction
111 : public file_manager::LoggedAsyncExtensionFunction {
109 public: 112 public:
110 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.cancelFileTransfers", 113 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.cancelFileTransfers",
111 FILEBROWSERPRIVATE_CANCELFILETRANSFERS) 114 FILEBROWSERPRIVATE_CANCELFILETRANSFERS)
112 115
113 CancelFileTransfersFunction(); 116 CancelFileTransfersFunction();
114 117
115 protected: 118 protected:
116 virtual ~CancelFileTransfersFunction(); 119 virtual ~CancelFileTransfersFunction();
117 120
118 // AsyncExtensionFunction overrides. 121 // AsyncExtensionFunction overrides.
119 virtual bool RunImpl() OVERRIDE; 122 virtual bool RunImpl() OVERRIDE;
120 }; 123 };
121 124
122 class SearchDriveFunction : public LoggedAsyncExtensionFunction { 125 class SearchDriveFunction : public file_manager::LoggedAsyncExtensionFunction {
123 public: 126 public:
124 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.searchDrive", 127 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.searchDrive",
125 FILEBROWSERPRIVATE_SEARCHDRIVE) 128 FILEBROWSERPRIVATE_SEARCHDRIVE)
126 129
127 SearchDriveFunction(); 130 SearchDriveFunction();
128 131
129 protected: 132 protected:
130 virtual ~SearchDriveFunction(); 133 virtual ~SearchDriveFunction();
131 134
132 virtual bool RunImpl() OVERRIDE; 135 virtual bool RunImpl() OVERRIDE;
133 136
134 private: 137 private:
135 // Callback for Search(). 138 // Callback for Search().
136 void OnSearch(drive::FileError error, 139 void OnSearch(drive::FileError error,
137 const GURL& next_feed, 140 const GURL& next_feed,
138 scoped_ptr<std::vector<drive::SearchResultInfo> > result_paths); 141 scoped_ptr<std::vector<drive::SearchResultInfo> > result_paths);
139 }; 142 };
140 143
141 // Similar to SearchDriveFunction but this one is used for searching drive 144 // Similar to SearchDriveFunction but this one is used for searching drive
142 // metadata which is stored locally. 145 // metadata which is stored locally.
143 class SearchDriveMetadataFunction : public LoggedAsyncExtensionFunction { 146 class SearchDriveMetadataFunction
147 : public file_manager::LoggedAsyncExtensionFunction {
144 public: 148 public:
145 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.searchDriveMetadata", 149 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.searchDriveMetadata",
146 FILEBROWSERPRIVATE_SEARCHDRIVEMETADATA) 150 FILEBROWSERPRIVATE_SEARCHDRIVEMETADATA)
147 151
148 SearchDriveMetadataFunction(); 152 SearchDriveMetadataFunction();
149 153
150 protected: 154 protected:
151 virtual ~SearchDriveMetadataFunction(); 155 virtual ~SearchDriveMetadataFunction();
152 156
153 virtual bool RunImpl() OVERRIDE; 157 virtual bool RunImpl() OVERRIDE;
154 158
155 private: 159 private:
156 // Callback for SearchMetadata(); 160 // Callback for SearchMetadata();
157 void OnSearchMetadata(drive::FileError error, 161 void OnSearchMetadata(drive::FileError error,
158 scoped_ptr<drive::MetadataSearchResultVector> results); 162 scoped_ptr<drive::MetadataSearchResultVector> results);
159 }; 163 };
160 164
161 class ClearDriveCacheFunction : public LoggedAsyncExtensionFunction { 165 class ClearDriveCacheFunction
166 : public file_manager::LoggedAsyncExtensionFunction {
162 public: 167 public:
163 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.clearDriveCache", 168 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.clearDriveCache",
164 FILEBROWSERPRIVATE_CLEARDRIVECACHE) 169 FILEBROWSERPRIVATE_CLEARDRIVECACHE)
165 170
166 ClearDriveCacheFunction(); 171 ClearDriveCacheFunction();
167 172
168 protected: 173 protected:
169 virtual ~ClearDriveCacheFunction(); 174 virtual ~ClearDriveCacheFunction();
170 175
171 virtual bool RunImpl() OVERRIDE; 176 virtual bool RunImpl() OVERRIDE;
172 }; 177 };
173 178
174 // Implements the chrome.fileBrowserPrivate.getDriveConnectionState method. 179 // Implements the chrome.fileBrowserPrivate.getDriveConnectionState method.
175 class GetDriveConnectionStateFunction : public SyncExtensionFunction { 180 class GetDriveConnectionStateFunction : public SyncExtensionFunction {
176 public: 181 public:
177 DECLARE_EXTENSION_FUNCTION( 182 DECLARE_EXTENSION_FUNCTION(
178 "fileBrowserPrivate.getDriveConnectionState", 183 "fileBrowserPrivate.getDriveConnectionState",
179 FILEBROWSERPRIVATE_GETDRIVECONNECTIONSTATE); 184 FILEBROWSERPRIVATE_GETDRIVECONNECTIONSTATE);
180 185
181 GetDriveConnectionStateFunction(); 186 GetDriveConnectionStateFunction();
182 187
183 protected: 188 protected:
184 virtual ~GetDriveConnectionStateFunction(); 189 virtual ~GetDriveConnectionStateFunction();
185 190
186 virtual bool RunImpl() OVERRIDE; 191 virtual bool RunImpl() OVERRIDE;
187 }; 192 };
188 193
189 // Implements the chrome.fileBrowserPrivate.requestAccessToken method. 194 // Implements the chrome.fileBrowserPrivate.requestAccessToken method.
190 class RequestAccessTokenFunction : public LoggedAsyncExtensionFunction { 195 class RequestAccessTokenFunction
196 : public file_manager::LoggedAsyncExtensionFunction {
191 public: 197 public:
192 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.requestAccessToken", 198 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.requestAccessToken",
193 FILEBROWSERPRIVATE_REQUESTACCESSTOKEN) 199 FILEBROWSERPRIVATE_REQUESTACCESSTOKEN)
194 200
195 RequestAccessTokenFunction(); 201 RequestAccessTokenFunction();
196 202
197 protected: 203 protected:
198 virtual ~RequestAccessTokenFunction(); 204 virtual ~RequestAccessTokenFunction();
199 205
200 // AsyncExtensionFunction overrides. 206 // AsyncExtensionFunction overrides.
201 virtual bool RunImpl() OVERRIDE; 207 virtual bool RunImpl() OVERRIDE;
202 208
203 // Callback with a cached auth token (if available) or a fetched one. 209 // Callback with a cached auth token (if available) or a fetched one.
204 void OnAccessTokenFetched(google_apis::GDataErrorCode code, 210 void OnAccessTokenFetched(google_apis::GDataErrorCode code,
205 const std::string& access_token); 211 const std::string& access_token);
206 }; 212 };
207 213
208 // Implements the chrome.fileBrowserPrivate.getShareUrl method. 214 // Implements the chrome.fileBrowserPrivate.getShareUrl method.
209 class GetShareUrlFunction : public LoggedAsyncExtensionFunction { 215 class GetShareUrlFunction : public file_manager::LoggedAsyncExtensionFunction {
210 public: 216 public:
211 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getShareUrl", 217 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getShareUrl",
212 FILEBROWSERPRIVATE_GETSHAREURL) 218 FILEBROWSERPRIVATE_GETSHAREURL)
213 219
214 GetShareUrlFunction(); 220 GetShareUrlFunction();
215 221
216 protected: 222 protected:
217 virtual ~GetShareUrlFunction(); 223 virtual ~GetShareUrlFunction();
218 224
219 // AsyncExtensionFunction overrides. 225 // AsyncExtensionFunction overrides.
220 virtual bool RunImpl() OVERRIDE; 226 virtual bool RunImpl() OVERRIDE;
221 227
222 // Callback with an url to the sharing dialog as |share_url|, called by 228 // Callback with an url to the sharing dialog as |share_url|, called by
223 // FileSystem::GetShareUrl. 229 // FileSystem::GetShareUrl.
224 void OnGetShareUrl(drive::FileError error, const GURL& share_url); 230 void OnGetShareUrl(drive::FileError error, const GURL& share_url);
225 }; 231 };
226 232
227 } // namespace file_manager 233 } // namespace extensions
228 234
229 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_DRIVE_H_ 235 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_DRIVE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698