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.
5 // This file provides miscellaneous API functions, which don't belong to
8 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_MISC_H_
9 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_MISC_H_
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
28 class FileManagerPrivateLogoutUserForReauthenticationFunction
29 : public ChromeSyncExtensionFunction
{
31 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.logoutUserForReauthentication",
32 FILEMANAGERPRIVATE_LOGOUTUSERFORREAUTHENTICATION
)
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
{
46 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.getPreferences",
47 FILEMANAGERPRIVATE_GETPREFERENCES
)
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
{
60 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.setPreferences",
61 FILEMANAGERPRIVATE_SETPREFERENCES
)
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
{
74 DECLARE_EXTENSION_FUNCTION("fileManagerPrivateInternal.zipSelection",
75 FILEMANAGERPRIVATEINTERNAL_ZIPSELECTION
)
77 FileManagerPrivateInternalZipSelectionFunction();
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
{
95 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.zoom",
96 FILEMANAGERPRIVATE_ZOOM
);
99 ~FileManagerPrivateZoomFunction() override
{}
101 // AsyncExtensionFunction overrides.
102 bool RunSync() override
;
105 class FileManagerPrivateRequestWebStoreAccessTokenFunction
106 : public LoggedAsyncExtensionFunction
{
108 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.requestWebStoreAccessToken",
109 FILEMANAGERPRIVATE_REQUESTWEBSTOREACCESSTOKEN
);
111 FileManagerPrivateRequestWebStoreAccessTokenFunction();
114 ~FileManagerPrivateRequestWebStoreAccessTokenFunction() override
;
115 bool RunAsync() override
;
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
{
127 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.getProfiles",
128 FILEMANAGERPRIVATE_GETPROFILES
);
131 ~FileManagerPrivateGetProfilesFunction() override
{}
133 // AsyncExtensionFunction overrides.
134 bool RunSync() override
;
137 // Implements the chrome.fileManagerPrivate.openInspector method.
138 class FileManagerPrivateOpenInspectorFunction
139 : public ChromeSyncExtensionFunction
{
141 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.openInspector",
142 FILEMANAGERPRIVATE_OPENINSPECTOR
);
145 ~FileManagerPrivateOpenInspectorFunction() override
{}
147 bool RunSync() override
;
150 // Implements the chrome.fileManagerPrivate.getMimeType method.
151 class FileManagerPrivateInternalGetMimeTypeFunction
152 : public LoggedAsyncExtensionFunction
{
154 DECLARE_EXTENSION_FUNCTION("fileManagerPrivateInternal.getMimeType",
155 FILEMANAGERPRIVATEINTERNAL_GETMIMETYPE
)
157 FileManagerPrivateInternalGetMimeTypeFunction();
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
{
172 FileManagerPrivateIsPiexLoaderEnabledFunction() {}
173 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.isPiexLoaderEnabled",
174 FILEMANAGERPRIVATE_ISPIEXLOADERENABLED
)
176 ~FileManagerPrivateIsPiexLoaderEnabledFunction() override
{}
179 ResponseAction
Run() override
;
180 DISALLOW_COPY_AND_ASSIGN(FileManagerPrivateIsPiexLoaderEnabledFunction
);
183 // Implements the chrome.fileManagerPrivate.getProvidingExtensions method.
184 class FileManagerPrivateGetProvidingExtensionsFunction
185 : public UIThreadExtensionFunction
{
187 FileManagerPrivateGetProvidingExtensionsFunction();
188 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.getProvidingExtensions",
189 FILEMANAGERPRIVATE_GETPROVIDINGEXTENSIONS
)
191 ~FileManagerPrivateGetProvidingExtensionsFunction() override
{}
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
{
203 FileManagerPrivateAddProvidedFileSystemFunction();
204 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.addProvidedFileSystem",
205 FILEMANAGERPRIVATE_ADDPROVIDEDFILESYSTEM
)
207 ~FileManagerPrivateAddProvidedFileSystemFunction() override
{}
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
{
219 FileManagerPrivateConfigureVolumeFunction();
220 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.configureVolume",
221 FILEMANAGERPRIVATE_CONFIGUREVOLUME
)
223 ~FileManagerPrivateConfigureVolumeFunction() override
{}
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
{
237 FileManagerPrivateInternalGetEntryActionsFunction();
238 DECLARE_EXTENSION_FUNCTION("fileManagerPrivateInternal.getEntryActions",
239 FILEMANAGERPRIVATEINTERNAL_GETENTRYACTIONS
)
241 ~FileManagerPrivateInternalGetEntryActionsFunction() override
{}
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
{
256 FileManagerPrivateInternalExecuteEntryActionFunction();
257 DECLARE_EXTENSION_FUNCTION("fileManagerPrivateInternal.executeEntryAction",
258 FILEMANAGERPRIVATEINTERNAL_EXECUTEENTRYACTION
)
260 ~FileManagerPrivateInternalExecuteEntryActionFunction() override
{}
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_