OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/observer_list.h" |
| 13 #include "chrome/browser/chromeos/file_system_provider/observer.h" |
| 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/common/extensions/api/file_system_provider.h" |
| 16 #include "components/keyed_service/core/keyed_service.h" |
| 17 #include "content/public/browser/browser_context.h" |
| 18 |
| 19 namespace chromeos { |
| 20 namespace file_system_provider { |
| 21 |
| 22 class ServiceFactory; |
| 23 |
| 24 // Manages and registers the fileSystemProvider service. |
| 25 class Service : public KeyedService { |
| 26 public: |
| 27 explicit Service(Profile* profile); |
| 28 virtual ~Service(); |
| 29 |
| 30 // Registers a file system provided by an extension with the |extension_id|. |
| 31 // For success, it returns a file system id, which is of the following format: |
| 32 // |extension_id|-unique-hash, where unique is an auto-incremented non-zero |
| 33 // number, and hash is the user profile hash. |
| 34 // For failures, it returns an empty string. |
| 35 std::string RegisterFileSystem(const std::string& extension_id, |
| 36 const std::string& file_system_name); |
| 37 |
| 38 // Unregisters a file system with the specified |file_system_id| for the |
| 39 // |extension_id|. For success returns true, otherwise false. |
| 40 bool UnregisterFileSystem(const std::string& extension_id, |
| 41 const std::string& file_system_id); |
| 42 |
| 43 // Returns a list of currently registered file systems. All items are copied. |
| 44 std::vector<ProvidedFileSystem> GetRegisteredFileSystems(); |
| 45 |
| 46 // Adds and removes observers. |
| 47 void AddObserver(Observer* observer); |
| 48 void RemoveObserver(Observer* observer); |
| 49 |
| 50 // Gets the singleton instance for the |context|. |
| 51 static Service* Get(content::BrowserContext* context); |
| 52 |
| 53 private: |
| 54 typedef std::map<std::string, ProvidedFileSystem> FileSystemMap; |
| 55 |
| 56 Profile* profile_; |
| 57 ObserverList<Observer> observers_; |
| 58 FileSystemMap file_systems_; |
| 59 int next_handle_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(Service); |
| 62 }; |
| 63 |
| 64 } // namespace file_system_provider |
| 65 } // namespace chromeos |
| 66 |
| 67 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ |
OLD | NEW |