private_api_misc.h revision 5f1c94371a64b3196d4be9466099bb892df9b88e
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.
7
8#ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_MISC_H_
9#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_MISC_H_
10
11#include "chrome/browser/chromeos/extensions/file_manager/private_api_base.h"
12#include "chrome/common/extensions/webstore_install_result.h"
13#include "google_apis/drive/gdata_errorcode.h"
14
15namespace google_apis {
16class AuthServiceInterface;
17}
18
19namespace extensions {
20
21// Implements the chrome.fileBrowserPrivate.logoutUserForReauthentication
22// method.
23class FileBrowserPrivateLogoutUserForReauthenticationFunction
24    : public ChromeSyncExtensionFunction {
25 public:
26  DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.logoutUserForReauthentication",
27                             FILEBROWSERPRIVATE_LOGOUTUSERFORREAUTHENTICATION)
28
29 protected:
30  virtual ~FileBrowserPrivateLogoutUserForReauthenticationFunction() {}
31
32  // SyncExtensionFunction overrides.
33  virtual bool RunSync() OVERRIDE;
34};
35
36// Implements the chrome.fileBrowserPrivate.getPreferences method.
37// Gets settings for Files.app.
38class FileBrowserPrivateGetPreferencesFunction
39    : public ChromeSyncExtensionFunction {
40 public:
41  DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getPreferences",
42                             FILEBROWSERPRIVATE_GETPREFERENCES)
43
44 protected:
45  virtual ~FileBrowserPrivateGetPreferencesFunction() {}
46
47  virtual bool RunSync() OVERRIDE;
48};
49
50// Implements the chrome.fileBrowserPrivate.setPreferences method.
51// Sets settings for Files.app.
52class FileBrowserPrivateSetPreferencesFunction
53    : public ChromeSyncExtensionFunction {
54 public:
55  DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.setPreferences",
56                             FILEBROWSERPRIVATE_SETPREFERENCES)
57
58 protected:
59  virtual ~FileBrowserPrivateSetPreferencesFunction() {}
60
61  virtual bool RunSync() OVERRIDE;
62};
63
64// Implements the chrome.fileBrowserPrivate.zipSelection method.
65// Creates a zip file for the selected files.
66class FileBrowserPrivateZipSelectionFunction
67    : public LoggedAsyncExtensionFunction {
68 public:
69  DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.zipSelection",
70                             FILEBROWSERPRIVATE_ZIPSELECTION)
71
72  FileBrowserPrivateZipSelectionFunction();
73
74 protected:
75  virtual ~FileBrowserPrivateZipSelectionFunction();
76
77  // AsyncExtensionFunction overrides.
78  virtual bool RunAsync() OVERRIDE;
79
80  // Receives the result from ZipFileCreator.
81  void OnZipDone(bool success);
82};
83
84// Implements the chrome.fileBrowserPrivate.zoom method.
85// Changes the zoom level of the file manager by internally calling
86// RenderViewHost::Zoom(). TODO(hirono): Remove this function once the zoom
87// level change is supported for all apps. crbug.com/227175.
88class FileBrowserPrivateZoomFunction : public ChromeSyncExtensionFunction {
89 public:
90  DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.zoom",
91                             FILEBROWSERPRIVATE_ZOOM);
92
93 protected:
94  virtual ~FileBrowserPrivateZoomFunction() {}
95
96  // AsyncExtensionFunction overrides.
97  virtual bool RunSync() OVERRIDE;
98};
99
100// Implements the chrome.fileBrowserPrivate.installWebstoreItem method.
101class FileBrowserPrivateInstallWebstoreItemFunction
102    : public LoggedAsyncExtensionFunction {
103 public:
104  DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.installWebstoreItem",
105                             FILEBROWSERPRIVATE_INSTALLWEBSTOREITEM);
106
107 protected:
108  virtual ~FileBrowserPrivateInstallWebstoreItemFunction() {}
109
110  // AsyncExtensionFunction overrides.
111  virtual bool RunAsync() OVERRIDE;
112  void OnInstallComplete(bool success,
113                         const std::string& error,
114                         extensions::webstore_install::Result result);
115
116 private:
117  std::string webstore_item_id_;
118};
119
120class FileBrowserPrivateRequestWebStoreAccessTokenFunction
121    : public LoggedAsyncExtensionFunction {
122 public:
123  DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.requestWebStoreAccessToken",
124                             FILEBROWSERPRIVATE_REQUESTWEBSTOREACCESSTOKEN);
125
126  FileBrowserPrivateRequestWebStoreAccessTokenFunction();
127
128 protected:
129  virtual ~FileBrowserPrivateRequestWebStoreAccessTokenFunction();
130  virtual bool RunAsync() OVERRIDE;
131
132 private:
133  scoped_ptr<google_apis::AuthServiceInterface> auth_service_;
134
135  void OnAccessTokenFetched(google_apis::GDataErrorCode code,
136                            const std::string& access_token);
137
138};
139
140class FileBrowserPrivateGetProfilesFunction
141    : public ChromeSyncExtensionFunction {
142 public:
143  DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getProfiles",
144                             FILEBROWSERPRIVATE_GETPROFILES);
145
146 protected:
147  virtual ~FileBrowserPrivateGetProfilesFunction() {}
148
149  // AsyncExtensionFunction overrides.
150  virtual bool RunSync() OVERRIDE;
151};
152
153class FileBrowserPrivateVisitDesktopFunction
154    : public ChromeSyncExtensionFunction {
155 public:
156  DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.visitDesktop",
157                             FILEBROWSERPRIVATE_VISITDESKTOP);
158
159 protected:
160  virtual ~FileBrowserPrivateVisitDesktopFunction() {}
161
162  // AsyncExtensionFunction overrides.
163  virtual bool RunSync() OVERRIDE;
164};
165
166// Implements the chrome.fileBrowserPrivate.openInspector method.
167class FileBrowserPrivateOpenInspectorFunction
168    : public ChromeSyncExtensionFunction {
169 public:
170  DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.openInspector",
171                             FILEBROWSERPRIVATE_OPENINSPECTOR);
172
173 protected:
174  virtual ~FileBrowserPrivateOpenInspectorFunction() {}
175
176  virtual bool RunSync() OVERRIDE;
177};
178
179}  // namespace extensions
180
181#endif  // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_MISC_H_
182