Index: chrome/browser/chromeos/file_system_provider/service.h |
diff --git a/chrome/browser/chromeos/file_system_provider/service.h b/chrome/browser/chromeos/file_system_provider/service.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5becf38149a251b6d84e51a9060a626d23983788 |
--- /dev/null |
+++ b/chrome/browser/chromeos/file_system_provider/service.h |
@@ -0,0 +1,68 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ |
+#define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ |
+ |
+#include <map> |
+#include <string> |
+#include <vector> |
+ |
+#include "base/observer_list.h" |
+#include "chrome/browser/chromeos/file_system_provider/observer.h" |
+#include "chrome/browser/profiles/profile.h" |
+#include "chrome/common/extensions/api/file_system_provider.h" |
+#include "components/browser_context_keyed_service/browser_context_keyed_service.h" |
+#include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h" |
+#include "content/public/browser/browser_context.h" |
+ |
+namespace chromeos { |
+namespace file_system_provider { |
+ |
+class ServiceFactory; |
+ |
+// Manages and registers the fileSystemProvider service. |
+class Service : public BrowserContextKeyedService { |
+ public: |
+ explicit Service(Profile* profile); |
+ virtual ~Service(); |
+ |
+ // Registers a file system provided by an extension with the |extension_id|. |
+ // For success, it returns a file system id, which is of the following format: |
+ // |extension_id|-unique-hash, where unique is an auto-incremented non-zero |
+ // number, and hash is the user profile hash. |
+ // For failures, it returns an empty string. |
+ std::string RegisterFileSystem(const std::string& extension_id, |
+ const std::string& file_system_name); |
+ |
+ // Unregisters a file system with the specified |file_system_id| for the |
+ // |extension_id|. For success returns true, otherwise false. |
+ bool UnregisterFileSystem(const std::string& extension_id, |
+ const std::string& file_system_id); |
+ |
+ // Returns a list of currently registered file systems. All items are copied. |
+ std::vector<ProvidedFileSystem> GetRegisteredFileSystems(); |
+ |
+ // Adds and removes observers. |
+ void AddObserver(Observer* observer); |
+ void RemoveObserver(Observer* observer); |
+ |
+ // Gets the singleton instance for the |context|. |
+ static Service* Get(content::BrowserContext* context); |
+ |
+ private: |
+ typedef std::map<std::string, ProvidedFileSystem> FileSystemMap; |
+ |
+ Profile* profile_; |
+ ObserverList<Observer> observers_; |
+ FileSystemMap file_systems_; |
+ int next_handle_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(Service); |
+}; |
+ |
+} // namespace file_system_provider |
+} // namespace chromeos |
+ |
+#endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SERVICE_H_ |