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 <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/files/file.h" | 12 #include "base/files/file.h" |
| 13 #include "base/files/file_path.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
15 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
16 #include "base/values.h" | 17 #include "base/values.h" |
17 #include "chrome/browser/chromeos/file_system_provider/observer.h" | 18 #include "chrome/browser/chromeos/file_system_provider/observer.h" |
18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/common/extensions/api/file_system_provider.h" | 20 #include "chrome/common/extensions/api/file_system_provider.h" |
20 #include "components/keyed_service/core/keyed_service.h" | 21 #include "components/keyed_service/core/keyed_service.h" |
21 #include "content/public/browser/browser_context.h" | 22 #include "content/public/browser/browser_context.h" |
22 #include "extensions/browser/extension_registry_observer.h" | 23 #include "extensions/browser/extension_registry_observer.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // Returns a list of information of all currently provided file systems. All | 72 // Returns a list of information of all currently provided file systems. All |
72 // items are copied. | 73 // items are copied. |
73 std::vector<ProvidedFileSystemInfo> GetProvidedFileSystemInfoList(); | 74 std::vector<ProvidedFileSystemInfo> GetProvidedFileSystemInfoList(); |
74 | 75 |
75 // Returns a provided file system with |file_system_id|, handled by | 76 // Returns a provided file system with |file_system_id|, handled by |
76 // the extension with |extension_id|. If not found, then returns NULL. | 77 // the extension with |extension_id|. If not found, then returns NULL. |
77 ProvidedFileSystemInterface* GetProvidedFileSystem( | 78 ProvidedFileSystemInterface* GetProvidedFileSystem( |
78 const std::string& extension_id, | 79 const std::string& extension_id, |
79 int file_system_id); | 80 int file_system_id); |
80 | 81 |
| 82 // Returns a provided file system attached to the the passed |
| 83 // |mount_point_name|. If not found, then returns NULL. |
| 84 ProvidedFileSystemInterface* GetProvidedFileSystem( |
| 85 const std::string& mount_point_name); |
| 86 |
81 // Adds and removes observers. | 87 // Adds and removes observers. |
82 void AddObserver(Observer* observer); | 88 void AddObserver(Observer* observer); |
83 void RemoveObserver(Observer* observer); | 89 void RemoveObserver(Observer* observer); |
84 | 90 |
85 // Gets the singleton instance for the |context|. | 91 // Gets the singleton instance for the |context|. |
86 static Service* Get(content::BrowserContext* context); | 92 static Service* Get(content::BrowserContext* context); |
87 | 93 |
88 // extensions::ExtensionRegistryObserver overrides. | 94 // extensions::ExtensionRegistryObserver overrides. |
89 virtual void OnExtensionUnloaded( | 95 virtual void OnExtensionUnloaded( |
90 content::BrowserContext* browser_context, | 96 content::BrowserContext* browser_context, |
91 const extensions::Extension* extension, | 97 const extensions::Extension* extension, |
92 extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; | 98 extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; |
93 | 99 |
94 private: | 100 private: |
95 typedef std::map<int, ProvidedFileSystemInterface*> ProvidedFileSystemMap; | 101 typedef std::map<int, ProvidedFileSystemInterface*> ProvidedFileSystemMap; |
| 102 typedef std::map<std::string, int> MountPointNameToIdMap; |
96 | 103 |
97 // Called when the providing extension accepts or refuses a unmount request. | 104 // Called when the providing extension accepts or refuses a unmount request. |
98 // If |error| is equal to FILE_OK, then the request is accepted. | 105 // If |error| is equal to FILE_OK, then the request is accepted. |
99 void OnRequestUnmountStatus(const ProvidedFileSystemInfo& file_system_info, | 106 void OnRequestUnmountStatus(const ProvidedFileSystemInfo& file_system_info, |
100 base::File::Error error); | 107 base::File::Error error); |
101 | 108 |
102 Profile* profile_; | 109 Profile* profile_; |
103 extensions::ExtensionRegistry* extension_registry_; // Not owned. | 110 extensions::ExtensionRegistry* extension_registry_; // Not owned. |
104 FileSystemFactoryCallback file_system_factory_; | 111 FileSystemFactoryCallback file_system_factory_; |
105 ObserverList<Observer> observers_; | 112 ObserverList<Observer> observers_; |
106 ProvidedFileSystemMap file_system_map_; // Owns pointers. | 113 ProvidedFileSystemMap file_system_map_; // Owns pointers. |
| 114 MountPointNameToIdMap mount_point_name_to_id_map_; |
107 int next_id_; | 115 int next_id_; |
108 base::WeakPtrFactory<Service> weak_ptr_factory_; | 116 base::WeakPtrFactory<Service> weak_ptr_factory_; |
109 | 117 |
110 DISALLOW_COPY_AND_ASSIGN(Service); | 118 DISALLOW_COPY_AND_ASSIGN(Service); |
111 }; | 119 }; |
112 | 120 |
113 } // namespace file_system_provider | 121 } // namespace file_system_provider |
114 } // namespace chromeos | 122 } // namespace chromeos |
115 | 123 |
116 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ | 124 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ |
OLD | NEW |