| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "components/keyed_service/core/keyed_service.h" | 22 #include "components/keyed_service/core/keyed_service.h" |
| 23 #include "content/public/browser/browser_context.h" | 23 #include "content/public/browser/browser_context.h" |
| 24 #include "extensions/browser/extension_registry_observer.h" | 24 #include "extensions/browser/extension_registry_observer.h" |
| 25 #include "extensions/common/extension.h" | 25 #include "extensions/common/extension.h" |
| 26 | 26 |
| 27 namespace extensions { | 27 namespace extensions { |
| 28 class EventRouter; | 28 class EventRouter; |
| 29 class ExtensionRegistry; | 29 class ExtensionRegistry; |
| 30 } // namespace extensions | 30 } // namespace extensions |
| 31 | 31 |
| 32 namespace user_prefs { |
| 33 class PrefRegistrySyncable; |
| 34 } // namespace user_prefs |
| 35 |
| 32 namespace chromeos { | 36 namespace chromeos { |
| 33 namespace file_system_provider { | 37 namespace file_system_provider { |
| 34 | 38 |
| 35 class ProvidedFileSystemFactoryInterface; | 39 class ProvidedFileSystemFactoryInterface; |
| 36 class ProvidedFileSystemInfo; | 40 class ProvidedFileSystemInfo; |
| 37 class ProvidedFileSystemInterface; | 41 class ProvidedFileSystemInterface; |
| 38 class ServiceFactory; | 42 class ServiceFactory; |
| 39 | 43 |
| 44 // Registers preferences to remember registered file systems between reboots. |
| 45 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 46 |
| 40 // Manages and registers the file system provider service. Maintains provided | 47 // Manages and registers the file system provider service. Maintains provided |
| 41 // file systems. | 48 // file systems. |
| 42 class Service : public KeyedService, | 49 class Service : public KeyedService, |
| 43 public extensions::ExtensionRegistryObserver { | 50 public extensions::ExtensionRegistryObserver { |
| 44 public: | 51 public: |
| 45 typedef base::Callback<ProvidedFileSystemInterface*( | 52 typedef base::Callback<ProvidedFileSystemInterface*( |
| 46 extensions::EventRouter* event_router, | 53 extensions::EventRouter* event_router, |
| 47 const ProvidedFileSystemInfo& file_system_info)> | 54 const ProvidedFileSystemInfo& file_system_info)> |
| 48 FileSystemFactoryCallback; | 55 FileSystemFactoryCallback; |
| 49 | 56 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 void RemoveObserver(Observer* observer); | 99 void RemoveObserver(Observer* observer); |
| 93 | 100 |
| 94 // Gets the singleton instance for the |context|. | 101 // Gets the singleton instance for the |context|. |
| 95 static Service* Get(content::BrowserContext* context); | 102 static Service* Get(content::BrowserContext* context); |
| 96 | 103 |
| 97 // extensions::ExtensionRegistryObserver overrides. | 104 // extensions::ExtensionRegistryObserver overrides. |
| 98 virtual void OnExtensionUnloaded( | 105 virtual void OnExtensionUnloaded( |
| 99 content::BrowserContext* browser_context, | 106 content::BrowserContext* browser_context, |
| 100 const extensions::Extension* extension, | 107 const extensions::Extension* extension, |
| 101 extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; | 108 extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; |
| 109 virtual void OnExtensionLoaded( |
| 110 content::BrowserContext* browser_context, |
| 111 const extensions::Extension* extension) OVERRIDE; |
| 102 | 112 |
| 103 private: | 113 private: |
| 104 // Key is a pair of an extension id and file system id, which makes it | 114 // Key is a pair of an extension id and file system id, which makes it |
| 105 // unique among the entire service instance. | 115 // unique among the entire service instance. |
| 106 typedef std::pair<std::string, std::string> FileSystemKey; | 116 typedef std::pair<std::string, std::string> FileSystemKey; |
| 107 | 117 |
| 108 typedef std::map<FileSystemKey, ProvidedFileSystemInterface*> | 118 typedef std::map<FileSystemKey, ProvidedFileSystemInterface*> |
| 109 ProvidedFileSystemMap; | 119 ProvidedFileSystemMap; |
| 110 typedef std::map<std::string, FileSystemKey> MountPointNameToKeyMap; | 120 typedef std::map<std::string, FileSystemKey> MountPointNameToKeyMap; |
| 111 | 121 |
| 112 // Called when the providing extension accepts or refuses a unmount request. | 122 // Called when the providing extension accepts or refuses a unmount request. |
| 113 // If |error| is equal to FILE_OK, then the request is accepted. | 123 // If |error| is equal to FILE_OK, then the request is accepted. |
| 114 void OnRequestUnmountStatus(const ProvidedFileSystemInfo& file_system_info, | 124 void OnRequestUnmountStatus(const ProvidedFileSystemInfo& file_system_info, |
| 115 base::File::Error error); | 125 base::File::Error error); |
| 116 | 126 |
| 127 // Saves a list of currently mounted file systems to preferences. Called |
| 128 // from a destructor (on shutdown). |
| 129 void RememberFileSystems(); |
| 130 |
| 131 // Removes all of the file systems mounted by the |extension_id| from |
| 132 // preferences, so they are not loaded again after reboot. |
| 133 void ForgetFileSystems(const std::string& extension_id); |
| 134 |
| 135 // Restores from preferences file systems mounted previously by the |
| 136 // |extension_id| providing extension. |
| 137 void RestoreFileSystems(const std::string& extension_id); |
| 138 |
| 117 Profile* profile_; | 139 Profile* profile_; |
| 118 extensions::ExtensionRegistry* extension_registry_; // Not owned. | 140 extensions::ExtensionRegistry* extension_registry_; // Not owned. |
| 119 FileSystemFactoryCallback file_system_factory_; | 141 FileSystemFactoryCallback file_system_factory_; |
| 120 ObserverList<Observer> observers_; | 142 ObserverList<Observer> observers_; |
| 121 ProvidedFileSystemMap file_system_map_; // Owns pointers. | 143 ProvidedFileSystemMap file_system_map_; // Owns pointers. |
| 122 MountPointNameToKeyMap mount_point_name_to_key_map_; | 144 MountPointNameToKeyMap mount_point_name_to_key_map_; |
| 123 base::WeakPtrFactory<Service> weak_ptr_factory_; | 145 base::WeakPtrFactory<Service> weak_ptr_factory_; |
| 124 | 146 |
| 125 DISALLOW_COPY_AND_ASSIGN(Service); | 147 DISALLOW_COPY_AND_ASSIGN(Service); |
| 126 }; | 148 }; |
| 127 | 149 |
| 128 } // namespace file_system_provider | 150 } // namespace file_system_provider |
| 129 } // namespace chromeos | 151 } // namespace chromeos |
| 130 | 152 |
| 131 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ | 153 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ |
| OLD | NEW |