private_api_misc.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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/browser/chromeos/file_manager/zip_file_creator.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 RunImpl() 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 RunImpl() 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 RunImpl() 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 file_manager::ZipFileCreator::Observer { 69 public: 70 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.zipSelection", 71 FILEBROWSERPRIVATE_ZIPSELECTION) 72 73 FileBrowserPrivateZipSelectionFunction(); 74 75 protected: 76 virtual ~FileBrowserPrivateZipSelectionFunction(); 77 78 // AsyncExtensionFunction overrides. 79 virtual bool RunImpl() OVERRIDE; 80 81 // extensions::ZipFileCreator::Delegate overrides. 82 virtual void OnZipDone(bool success) OVERRIDE; 83 84 private: 85 scoped_refptr<file_manager::ZipFileCreator> zip_file_creator_; 86}; 87 88// Implements the chrome.fileBrowserPrivate.zoom method. 89// Changes the zoom level of the file manager by internally calling 90// RenderViewHost::Zoom(). TODO(hirono): Remove this function once the zoom 91// level change is supported for all apps. crbug.com/227175. 92class FileBrowserPrivateZoomFunction : public ChromeSyncExtensionFunction { 93 public: 94 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.zoom", 95 FILEBROWSERPRIVATE_ZOOM); 96 97 protected: 98 virtual ~FileBrowserPrivateZoomFunction() {} 99 100 // AsyncExtensionFunction overrides. 101 virtual bool RunImpl() OVERRIDE; 102}; 103 104// Implements the chrome.fileBrowserPrivate.installWebstoreItem method. 105class FileBrowserPrivateInstallWebstoreItemFunction 106 : public LoggedAsyncExtensionFunction { 107 public: 108 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.installWebstoreItem", 109 FILEBROWSERPRIVATE_INSTALLWEBSTOREITEM); 110 111 protected: 112 virtual ~FileBrowserPrivateInstallWebstoreItemFunction() {} 113 114 // AsyncExtensionFunction overrides. 115 virtual bool RunImpl() OVERRIDE; 116 void OnInstallComplete(bool success, const std::string& error); 117 118 private: 119 std::string webstore_item_id_; 120}; 121 122class FileBrowserPrivateRequestWebStoreAccessTokenFunction 123 : public LoggedAsyncExtensionFunction { 124 public: 125 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.requestWebStoreAccessToken", 126 FILEBROWSERPRIVATE_REQUESTWEBSTOREACCESSTOKEN); 127 128 FileBrowserPrivateRequestWebStoreAccessTokenFunction(); 129 130 protected: 131 virtual ~FileBrowserPrivateRequestWebStoreAccessTokenFunction(); 132 virtual bool RunImpl() OVERRIDE; 133 134 private: 135 scoped_ptr<google_apis::AuthServiceInterface> auth_service_; 136 137 void OnAccessTokenFetched(google_apis::GDataErrorCode code, 138 const std::string& access_token); 139 140}; 141 142class FileBrowserPrivateGetProfilesFunction 143 : public ChromeSyncExtensionFunction { 144 public: 145 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getProfiles", 146 FILEBROWSERPRIVATE_GETPROFILES); 147 148 protected: 149 virtual ~FileBrowserPrivateGetProfilesFunction() {} 150 151 // AsyncExtensionFunction overrides. 152 virtual bool RunImpl() OVERRIDE; 153}; 154 155class FileBrowserPrivateVisitDesktopFunction 156 : public ChromeSyncExtensionFunction { 157 public: 158 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.visitDesktop", 159 FILEBROWSERPRIVATE_VISITDESKTOP); 160 161 protected: 162 virtual ~FileBrowserPrivateVisitDesktopFunction() {} 163 164 // AsyncExtensionFunction overrides. 165 virtual bool RunImpl() OVERRIDE; 166}; 167 168} // namespace extensions 169 170#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_MISC_H_ 171