ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chrome / browser / chromeos / extensions / file_manager / private_api_drive.h
blobaf9b20dddc873115db9e2addf0e18f136cafaea7
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 Drive specific API functions.
7 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_DRIVE_H_
8 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_DRIVE_H_
10 #include <string>
11 #include <vector>
13 #include "base/files/file.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "chrome/browser/chromeos/drive/file_errors.h"
16 #include "chrome/browser/chromeos/drive/file_system_interface.h"
17 #include "chrome/browser/chromeos/extensions/file_manager/private_api_base.h"
18 #include "chrome/browser/chromeos/file_manager/fileapi_util.h"
20 namespace drive {
21 class FileCacheEntry;
22 class ResourceEntry;
23 struct SearchResultInfo;
26 namespace google_apis {
27 class AuthService;
30 namespace extensions {
32 namespace api {
33 namespace file_manager_private {
34 struct EntryProperties;
35 } // namespace file_manager_private
36 } // namespace api
38 // Retrieves property information for an entry and returns it as a dictionary.
39 // On error, returns a dictionary with the key "error" set to the error number
40 // (base::File::Error).
41 class FileManagerPrivateGetEntryPropertiesFunction
42 : public LoggedAsyncExtensionFunction {
43 public:
44 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.getEntryProperties",
45 FILEMANAGERPRIVATE_GETENTRYPROPERTIES)
47 FileManagerPrivateGetEntryPropertiesFunction();
49 protected:
50 ~FileManagerPrivateGetEntryPropertiesFunction() override;
52 // AsyncExtensionFunction overrides.
53 bool RunAsync() override;
55 private:
56 void CompleteGetEntryProperties(
57 size_t index,
58 const storage::FileSystemURL& url,
59 scoped_ptr<api::file_manager_private::EntryProperties> properties,
60 base::File::Error error);
62 size_t processed_count_;
63 std::vector<linked_ptr<api::file_manager_private::EntryProperties> >
64 properties_list_;
67 // Implements the chrome.fileManagerPrivate.pinDriveFile method.
68 class FileManagerPrivatePinDriveFileFunction
69 : public LoggedAsyncExtensionFunction {
70 public:
71 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.pinDriveFile",
72 FILEMANAGERPRIVATE_PINDRIVEFILE)
74 protected:
75 ~FileManagerPrivatePinDriveFileFunction() override {}
77 // AsyncExtensionFunction overrides.
78 bool RunAsync() override;
80 private:
81 // Callback for RunAsync().
82 void OnPinStateSet(drive::FileError error);
85 // Implements the chrome.fileManagerPrivate.cancelFileTransfers method.
86 class FileManagerPrivateCancelFileTransfersFunction
87 : public LoggedAsyncExtensionFunction {
88 public:
89 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.cancelFileTransfers",
90 FILEMANAGERPRIVATE_CANCELFILETRANSFERS)
92 protected:
93 ~FileManagerPrivateCancelFileTransfersFunction() override {}
95 // AsyncExtensionFunction overrides.
96 bool RunAsync() override;
99 class FileManagerPrivateSearchDriveFunction
100 : public LoggedAsyncExtensionFunction {
101 public:
102 typedef std::vector<drive::SearchResultInfo> SearchResultInfoList;
104 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.searchDrive",
105 FILEMANAGERPRIVATE_SEARCHDRIVE)
107 protected:
108 ~FileManagerPrivateSearchDriveFunction() override {}
110 bool RunAsync() override;
112 private:
113 // Callback for Search().
114 void OnSearch(drive::FileError error,
115 const GURL& next_link,
116 scoped_ptr<std::vector<drive::SearchResultInfo> > result_paths);
118 // Called when |result_paths| in OnSearch() are converted to a list of
119 // entry definitions.
120 void OnEntryDefinitionList(
121 const GURL& next_link,
122 scoped_ptr<SearchResultInfoList> search_result_info_list,
123 scoped_ptr<file_manager::util::EntryDefinitionList>
124 entry_definition_list);
127 // Similar to FileManagerPrivateSearchDriveFunction but this one is used for
128 // searching drive metadata which is stored locally.
129 class FileManagerPrivateSearchDriveMetadataFunction
130 : public LoggedAsyncExtensionFunction {
131 public:
132 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.searchDriveMetadata",
133 FILEMANAGERPRIVATE_SEARCHDRIVEMETADATA)
135 protected:
136 ~FileManagerPrivateSearchDriveMetadataFunction() override {}
138 bool RunAsync() override;
140 private:
141 // Callback for SearchMetadata();
142 void OnSearchMetadata(drive::FileError error,
143 scoped_ptr<drive::MetadataSearchResultVector> results);
145 // Called when |results| in OnSearchMetadata() are converted to a list of
146 // entry definitions.
147 void OnEntryDefinitionList(
148 scoped_ptr<drive::MetadataSearchResultVector> search_result_info_list,
149 scoped_ptr<file_manager::util::EntryDefinitionList>
150 entry_definition_list);
153 // Implements the chrome.fileManagerPrivate.getDriveConnectionState method.
154 class FileManagerPrivateGetDriveConnectionStateFunction
155 : public ChromeSyncExtensionFunction {
156 public:
157 DECLARE_EXTENSION_FUNCTION(
158 "fileManagerPrivate.getDriveConnectionState",
159 FILEMANAGERPRIVATE_GETDRIVECONNECTIONSTATE);
161 protected:
162 ~FileManagerPrivateGetDriveConnectionStateFunction() override {}
164 bool RunSync() override;
167 // Implements the chrome.fileManagerPrivate.requestAccessToken method.
168 class FileManagerPrivateRequestAccessTokenFunction
169 : public LoggedAsyncExtensionFunction {
170 public:
171 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.requestAccessToken",
172 FILEMANAGERPRIVATE_REQUESTACCESSTOKEN)
174 protected:
175 ~FileManagerPrivateRequestAccessTokenFunction() override {}
177 // AsyncExtensionFunction overrides.
178 bool RunAsync() override;
180 // Callback with a cached auth token (if available) or a fetched one.
181 void OnAccessTokenFetched(google_apis::DriveApiErrorCode code,
182 const std::string& access_token);
185 // Implements the chrome.fileManagerPrivate.getShareUrl method.
186 class FileManagerPrivateGetShareUrlFunction
187 : public LoggedAsyncExtensionFunction {
188 public:
189 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.getShareUrl",
190 FILEMANAGERPRIVATE_GETSHAREURL)
192 protected:
193 ~FileManagerPrivateGetShareUrlFunction() override {}
195 // AsyncExtensionFunction overrides.
196 bool RunAsync() override;
198 // Callback with an url to the sharing dialog as |share_url|, called by
199 // FileSystem::GetShareUrl.
200 void OnGetShareUrl(drive::FileError error, const GURL& share_url);
203 // Implements the chrome.fileManagerPrivate.requestDriveShare method.
204 class FileManagerPrivateRequestDriveShareFunction
205 : public LoggedAsyncExtensionFunction {
206 public:
207 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.requestDriveShare",
208 FILEMANAGERPRIVATE_REQUESTDRIVESHARE);
210 protected:
211 ~FileManagerPrivateRequestDriveShareFunction() override {}
212 bool RunAsync() override;
214 private:
215 // Called back after the drive file system operation is finished.
216 void OnAddPermission(drive::FileError error);
219 // Implements the chrome.fileManagerPrivate.getDownloadUrl method.
220 class FileManagerPrivateGetDownloadUrlFunction
221 : public LoggedAsyncExtensionFunction {
222 public:
223 FileManagerPrivateGetDownloadUrlFunction();
225 DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.getDownloadUrl",
226 FILEMANAGERPRIVATE_GETDOWNLOADURL)
228 protected:
229 ~FileManagerPrivateGetDownloadUrlFunction() override;
231 // AsyncExtensionFunction overrides.
232 bool RunAsync() override;
234 void OnGetResourceEntry(drive::FileError error,
235 scoped_ptr<drive::ResourceEntry> entry);
237 // Callback with an |access_token|, called by
238 // drive::DriveReadonlyTokenFetcher.
239 void OnTokenFetched(google_apis::DriveApiErrorCode code,
240 const std::string& access_token);
242 private:
243 std::string download_url_;
244 scoped_ptr<google_apis::AuthService> auth_service_;
247 } // namespace extensions
249 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_DRIVE_H_