Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / chromeos / extensions / file_manager / private_api_misc.h
blobbbab3361aee590109a2e2d77dd3e1f4cf68f5eba
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
3 // found in the LICENSE file.
4 //
5 // This file provides miscellaneous API functions, which don't belong to
6 // other files.
8 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_MISC_H_
9 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_MISC_H_
11 #include <string>
13 #include "base/files/file.h"
14 #include "chrome/browser/chromeos/extensions/file_manager/private_api_base.h"
15 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_interface.h"
16 #include "chrome/browser/extensions/chrome_extension_function.h"
17 #include "chrome/browser/extensions/chrome_extension_function_details.h"
18 #include "google_apis/drive/drive_api_error_codes.h"
20 namespace google_apis {
21 class AuthServiceInterface;
22 } // namespace google_apis
24 namespace extensions {
26 // Implements the chrome.fileManagerPrivate.logoutUserForReauthentication
27 // method.
28 class FileManagerPrivateLogoutUserForReauthenticationFunction
29 : public ChromeSyncExtensionFunction {
30 public:
31 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.logoutUserForReauthentication",
32 FILEMANAGERPRIVATE_LOGOUTUSERFORREAUTHENTICATION)
34 protected:
35 ~FileManagerPrivateLogoutUserForReauthenticationFunction() override {}
37 // SyncExtensionFunction overrides.
38 bool RunSync() override;
41 // Implements the chrome.fileManagerPrivate.getPreferences method.
42 // Gets settings for Files.app.
43 class FileManagerPrivateGetPreferencesFunction
44 : public ChromeSyncExtensionFunction {
45 public:
46 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.getPreferences",
47 FILEMANAGERPRIVATE_GETPREFERENCES)
49 protected:
50 ~FileManagerPrivateGetPreferencesFunction() override {}
52 bool RunSync() override;
55 // Implements the chrome.fileManagerPrivate.setPreferences method.
56 // Sets settings for Files.app.
57 class FileManagerPrivateSetPreferencesFunction
58 : public ChromeSyncExtensionFunction {
59 public:
60 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.setPreferences",
61 FILEMANAGERPRIVATE_SETPREFERENCES)
63 protected:
64 ~FileManagerPrivateSetPreferencesFunction() override {}
66 bool RunSync() override;
69 // Implements the chrome.fileManagerPrivate.zipSelection method.
70 // Creates a zip file for the selected files.
71 class FileManagerPrivateInternalZipSelectionFunction
72 : public LoggedAsyncExtensionFunction {
73 public:
74 DECLARE_EXTENSION_FUNCTION("fileManagerPrivateInternal.zipSelection",
75 FILEMANAGERPRIVATEINTERNAL_ZIPSELECTION)
77 FileManagerPrivateInternalZipSelectionFunction();
79 protected:
80 ~FileManagerPrivateInternalZipSelectionFunction() override;
82 // AsyncExtensionFunction overrides.
83 bool RunAsync() override;
85 // Receives the result from ZipFileCreator.
86 void OnZipDone(bool success);
89 // Implements the chrome.fileManagerPrivate.zoom method.
90 // Changes the zoom level of the file manager by internally calling
91 // RenderViewHost::Zoom(). TODO(hirono): Remove this function once the zoom
92 // level change is supported for all apps. crbug.com/227175.
93 class FileManagerPrivateZoomFunction : public ChromeSyncExtensionFunction {
94 public:
95 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.zoom",
96 FILEMANAGERPRIVATE_ZOOM);
98 protected:
99 ~FileManagerPrivateZoomFunction() override {}
101 // AsyncExtensionFunction overrides.
102 bool RunSync() override;
105 class FileManagerPrivateRequestWebStoreAccessTokenFunction
106 : public LoggedAsyncExtensionFunction {
107 public:
108 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.requestWebStoreAccessToken",
109 FILEMANAGERPRIVATE_REQUESTWEBSTOREACCESSTOKEN);
111 FileManagerPrivateRequestWebStoreAccessTokenFunction();
113 protected:
114 ~FileManagerPrivateRequestWebStoreAccessTokenFunction() override;
115 bool RunAsync() override;
117 private:
118 scoped_ptr<google_apis::AuthServiceInterface> auth_service_;
120 void OnAccessTokenFetched(google_apis::DriveApiErrorCode code,
121 const std::string& access_token);
124 class FileManagerPrivateGetProfilesFunction
125 : public ChromeSyncExtensionFunction {
126 public:
127 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.getProfiles",
128 FILEMANAGERPRIVATE_GETPROFILES);
130 protected:
131 ~FileManagerPrivateGetProfilesFunction() override {}
133 // AsyncExtensionFunction overrides.
134 bool RunSync() override;
137 // Implements the chrome.fileManagerPrivate.openInspector method.
138 class FileManagerPrivateOpenInspectorFunction
139 : public ChromeSyncExtensionFunction {
140 public:
141 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.openInspector",
142 FILEMANAGERPRIVATE_OPENINSPECTOR);
144 protected:
145 ~FileManagerPrivateOpenInspectorFunction() override {}
147 bool RunSync() override;
150 // Implements the chrome.fileManagerPrivate.getMimeType method.
151 class FileManagerPrivateInternalGetMimeTypeFunction
152 : public LoggedAsyncExtensionFunction {
153 public:
154 DECLARE_EXTENSION_FUNCTION("fileManagerPrivateInternal.getMimeType",
155 FILEMANAGERPRIVATEINTERNAL_GETMIMETYPE)
157 FileManagerPrivateInternalGetMimeTypeFunction();
159 protected:
160 ~FileManagerPrivateInternalGetMimeTypeFunction() override;
162 // AsyncExtensionFunction overrides.
163 bool RunAsync() override;
165 void OnGetMimeType(const std::string& mimeType);
168 // Implements the chrome.fileManagerPrivate.isPiexLoaderEnabled method.
169 class FileManagerPrivateIsPiexLoaderEnabledFunction
170 : public UIThreadExtensionFunction {
171 public:
172 FileManagerPrivateIsPiexLoaderEnabledFunction() {}
173 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.isPiexLoaderEnabled",
174 FILEMANAGERPRIVATE_ISPIEXLOADERENABLED)
175 protected:
176 ~FileManagerPrivateIsPiexLoaderEnabledFunction() override {}
178 private:
179 ResponseAction Run() override;
180 DISALLOW_COPY_AND_ASSIGN(FileManagerPrivateIsPiexLoaderEnabledFunction);
183 // Implements the chrome.fileManagerPrivate.getProvidingExtensions method.
184 class FileManagerPrivateGetProvidingExtensionsFunction
185 : public UIThreadExtensionFunction {
186 public:
187 FileManagerPrivateGetProvidingExtensionsFunction();
188 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.getProvidingExtensions",
189 FILEMANAGERPRIVATE_GETPROVIDINGEXTENSIONS)
190 protected:
191 ~FileManagerPrivateGetProvidingExtensionsFunction() override {}
193 private:
194 ResponseAction Run() override;
195 const ChromeExtensionFunctionDetails chrome_details_;
196 DISALLOW_COPY_AND_ASSIGN(FileManagerPrivateGetProvidingExtensionsFunction);
199 // Implements the chrome.fileManagerPrivate.addProvidedFileSystem method.
200 class FileManagerPrivateAddProvidedFileSystemFunction
201 : public UIThreadExtensionFunction {
202 public:
203 FileManagerPrivateAddProvidedFileSystemFunction();
204 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.addProvidedFileSystem",
205 FILEMANAGERPRIVATE_ADDPROVIDEDFILESYSTEM)
206 protected:
207 ~FileManagerPrivateAddProvidedFileSystemFunction() override {}
209 private:
210 ResponseAction Run() override;
211 const ChromeExtensionFunctionDetails chrome_details_;
212 DISALLOW_COPY_AND_ASSIGN(FileManagerPrivateAddProvidedFileSystemFunction);
215 // Implements the chrome.fileManagerPrivate.configureVolume method.
216 class FileManagerPrivateConfigureVolumeFunction
217 : public UIThreadExtensionFunction {
218 public:
219 FileManagerPrivateConfigureVolumeFunction();
220 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.configureVolume",
221 FILEMANAGERPRIVATE_CONFIGUREVOLUME)
222 protected:
223 ~FileManagerPrivateConfigureVolumeFunction() override {}
225 private:
226 ResponseAction Run() override;
227 void OnCompleted(base::File::Error result);
229 const ChromeExtensionFunctionDetails chrome_details_;
230 DISALLOW_COPY_AND_ASSIGN(FileManagerPrivateConfigureVolumeFunction);
233 // Implements the chrome.fileManagerPrivate.getEntryActions method.
234 class FileManagerPrivateInternalGetEntryActionsFunction
235 : public UIThreadExtensionFunction {
236 public:
237 FileManagerPrivateInternalGetEntryActionsFunction();
238 DECLARE_EXTENSION_FUNCTION("fileManagerPrivateInternal.getEntryActions",
239 FILEMANAGERPRIVATEINTERNAL_GETENTRYACTIONS)
240 protected:
241 ~FileManagerPrivateInternalGetEntryActionsFunction() override {}
243 private:
244 ResponseAction Run() override;
245 void OnCompleted(const chromeos::file_system_provider::Actions& actions,
246 base::File::Error result);
248 const ChromeExtensionFunctionDetails chrome_details_;
249 DISALLOW_COPY_AND_ASSIGN(FileManagerPrivateInternalGetEntryActionsFunction);
252 // Implements the chrome.fileManagerPrivate.executeEntryAction method.
253 class FileManagerPrivateInternalExecuteEntryActionFunction
254 : public UIThreadExtensionFunction {
255 public:
256 FileManagerPrivateInternalExecuteEntryActionFunction();
257 DECLARE_EXTENSION_FUNCTION("fileManagerPrivateInternal.executeEntryAction",
258 FILEMANAGERPRIVATEINTERNAL_EXECUTEENTRYACTION)
259 protected:
260 ~FileManagerPrivateInternalExecuteEntryActionFunction() override {}
262 private:
263 ResponseAction Run() override;
264 void OnCompleted(base::File::Error result);
266 const ChromeExtensionFunctionDetails chrome_details_;
267 DISALLOW_COPY_AND_ASSIGN(
268 FileManagerPrivateInternalExecuteEntryActionFunction);
271 } // namespace extensions
273 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_MISC_H_