1 // Copyright (c) 2012 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 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_private_api.h" 6 7 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h" 8 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_private_api_factory.h" 9 #include "chrome/browser/chromeos/extensions/file_manager/private_api_dialog.h" 10 #include "chrome/browser/chromeos/extensions/file_manager/private_api_drive.h" 11 #include "chrome/browser/chromeos/extensions/file_manager/private_api_file_system.h" 12 #include "chrome/browser/chromeos/extensions/file_manager/private_api_misc.h" 13 #include "chrome/browser/chromeos/extensions/file_manager/private_api_mount.h" 14 #include "chrome/browser/chromeos/extensions/file_manager/private_api_strings.h" 15 #include "chrome/browser/chromeos/extensions/file_manager/private_api_tasks.h" 16 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" 17 #include "chrome/browser/extensions/extension_function_registry.h" 18 19 namespace file_manager { 20 21 FileBrowserPrivateAPI::FileBrowserPrivateAPI(Profile* profile) 22 : event_router_(new EventRouter(profile)) { 23 ExtensionFunctionRegistry* registry = 24 ExtensionFunctionRegistry::GetInstance(); 25 // Tasks related functions. 26 registry->RegisterFunction<ExecuteTaskFunction>(); 27 registry->RegisterFunction<GetFileTasksFunction>(); 28 registry->RegisterFunction<SetDefaultTaskFunction>(); 29 registry->RegisterFunction<ViewFilesFunction>(); 30 31 // Drive related functions. 32 registry->RegisterFunction<GetDriveEntryPropertiesFunction>(); 33 registry->RegisterFunction<PinDriveFileFunction>(); 34 registry->RegisterFunction<GetDriveFilesFunction>(); 35 registry->RegisterFunction<CancelFileTransfersFunction>(); 36 registry->RegisterFunction<SearchDriveFunction>(); 37 registry->RegisterFunction<SearchDriveMetadataFunction>(); 38 registry->RegisterFunction<ClearDriveCacheFunction>(); 39 registry->RegisterFunction<GetDriveConnectionStateFunction>(); 40 registry->RegisterFunction<RequestAccessTokenFunction>(); 41 registry->RegisterFunction<GetShareUrlFunction>(); 42 43 // Select file dialog related functions. 44 registry->RegisterFunction<CancelFileDialogFunction>(); 45 registry->RegisterFunction<SelectFileFunction>(); 46 registry->RegisterFunction<SelectFilesFunction>(); 47 48 // Mount points related functions. 49 registry->RegisterFunction<AddMountFunction>(); 50 registry->RegisterFunction<RemoveMountFunction>(); 51 registry->RegisterFunction<GetMountPointsFunction>(); 52 53 // Hundreds of strings for the file manager. 54 registry->RegisterFunction<GetStringsFunction>(); 55 56 // File system related functions. 57 registry->RegisterFunction<RequestFileSystemFunction>(); 58 registry->RegisterFunction<AddFileWatchFunction>(); 59 registry->RegisterFunction<RemoveFileWatchFunction>(); 60 registry->RegisterFunction<SetLastModifiedFunction>(); 61 registry->RegisterFunction<GetSizeStatsFunction>(); 62 registry->RegisterFunction<GetVolumeMetadataFunction>(); 63 registry->RegisterFunction<ValidatePathNameLengthFunction>(); 64 registry->RegisterFunction<FormatDeviceFunction>(); 65 66 // Miscellaneous functions. 67 registry->RegisterFunction<LogoutUserFunction>(); 68 registry->RegisterFunction<GetPreferencesFunction>(); 69 registry->RegisterFunction<SetPreferencesFunction>(); 70 registry->RegisterFunction<ZipSelectionFunction>(); 71 registry->RegisterFunction<ZoomFunction>(); 72 event_router_->ObserveFileSystemEvents(); 73 } 74 75 FileBrowserPrivateAPI::~FileBrowserPrivateAPI() { 76 } 77 78 void FileBrowserPrivateAPI::Shutdown() { 79 event_router_->Shutdown(); 80 } 81 82 // static 83 FileBrowserPrivateAPI* FileBrowserPrivateAPI::Get(Profile* profile) { 84 return FileBrowserPrivateAPIFactory::GetForProfile(profile); 85 } 86 87 } // namespace file_manager 88