| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 EXTENSIONS_BROWSER_VALUE_STORE_LEGACY_VALUE_STORE_FACTORY_H_ | 5 #ifndef EXTENSIONS_BROWSER_VALUE_STORE_LEGACY_VALUE_STORE_FACTORY_H_ |
| 6 #define EXTENSIONS_BROWSER_VALUE_STORE_LEGACY_VALUE_STORE_FACTORY_H_ | 6 #define EXTENSIONS_BROWSER_VALUE_STORE_LEGACY_VALUE_STORE_FACTORY_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <set> | 9 #include <set> |
| 9 #include <string> | 10 #include <string> |
| 10 | 11 |
| 11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "extensions/browser/value_store/value_store.h" | 14 #include "extensions/browser/value_store/value_store.h" |
| 15 #include "extensions/browser/value_store/value_store_factory.h" | 15 #include "extensions/browser/value_store/value_store_factory.h" |
| 16 #include "extensions/common/extension.h" | 16 #include "extensions/common/extension.h" |
| 17 | 17 |
| 18 namespace extensions { | 18 namespace extensions { |
| 19 | 19 |
| 20 // A factory to create legacy ValueStore instances for storing extension | 20 // A factory to create legacy ValueStore instances for storing extension |
| 21 // state/rules/settings. "legacy" refers to the initial storage implementation | 21 // state/rules/settings. "legacy" refers to the initial storage implementation |
| 22 // which created a settings database per extension. | 22 // which created a settings database per extension. |
| 23 class LegacyValueStoreFactory : public ValueStoreFactory { | 23 class LegacyValueStoreFactory : public ValueStoreFactory { |
| 24 public: | 24 public: |
| 25 explicit LegacyValueStoreFactory(const base::FilePath& profile_path); | 25 explicit LegacyValueStoreFactory(const base::FilePath& profile_path); |
| 26 | 26 |
| 27 bool RulesDBExists() const; | 27 bool RulesDBExists() const; |
| 28 bool StateDBExists() const; | 28 bool StateDBExists() const; |
| 29 | 29 |
| 30 // ValueStoreFactory: | 30 // ValueStoreFactory: |
| 31 scoped_ptr<ValueStore> CreateRulesStore() override; | 31 std::unique_ptr<ValueStore> CreateRulesStore() override; |
| 32 scoped_ptr<ValueStore> CreateStateStore() override; | 32 std::unique_ptr<ValueStore> CreateStateStore() override; |
| 33 scoped_ptr<ValueStore> CreateSettingsStore( | 33 std::unique_ptr<ValueStore> CreateSettingsStore( |
| 34 settings_namespace::Namespace settings_namespace, | 34 settings_namespace::Namespace settings_namespace, |
| 35 ModelType model_type, | 35 ModelType model_type, |
| 36 const ExtensionId& extension_id) override; | 36 const ExtensionId& extension_id) override; |
| 37 | 37 |
| 38 void DeleteSettings(settings_namespace::Namespace settings_namespace, | 38 void DeleteSettings(settings_namespace::Namespace settings_namespace, |
| 39 ModelType model_type, | 39 ModelType model_type, |
| 40 const ExtensionId& extension_id) override; | 40 const ExtensionId& extension_id) override; |
| 41 bool HasSettings(settings_namespace::Namespace settings_namespace, | 41 bool HasSettings(settings_namespace::Namespace settings_namespace, |
| 42 ModelType model_type, | 42 ModelType model_type, |
| 43 const ExtensionId& extension_id) override; | 43 const ExtensionId& extension_id) override; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 SettingsRoot(const base::FilePath& base_path, | 75 SettingsRoot(const base::FilePath& base_path, |
| 76 const std::string& extension_dirname, | 76 const std::string& extension_dirname, |
| 77 const std::string& app_dirname); | 77 const std::string& app_dirname); |
| 78 ~SettingsRoot(); | 78 ~SettingsRoot(); |
| 79 | 79 |
| 80 std::set<ExtensionId> GetKnownExtensionIDs(ModelType model_type) const; | 80 std::set<ExtensionId> GetKnownExtensionIDs(ModelType model_type) const; |
| 81 const ModelSettings* GetModel(ModelType model_type) const; | 81 const ModelSettings* GetModel(ModelType model_type) const; |
| 82 ModelSettings* GetModel(ModelType model_type); | 82 ModelSettings* GetModel(ModelType model_type); |
| 83 | 83 |
| 84 private: | 84 private: |
| 85 scoped_ptr<ModelSettings> extensions_; | 85 std::unique_ptr<ModelSettings> extensions_; |
| 86 scoped_ptr<ModelSettings> apps_; | 86 std::unique_ptr<ModelSettings> apps_; |
| 87 | 87 |
| 88 DISALLOW_COPY_AND_ASSIGN(SettingsRoot); | 88 DISALLOW_COPY_AND_ASSIGN(SettingsRoot); |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 ~LegacyValueStoreFactory() override; | 91 ~LegacyValueStoreFactory() override; |
| 92 | 92 |
| 93 const SettingsRoot& GetSettingsRoot( | 93 const SettingsRoot& GetSettingsRoot( |
| 94 settings_namespace::Namespace settings_namespace) const; | 94 settings_namespace::Namespace settings_namespace) const; |
| 95 SettingsRoot& GetSettingsRoot( | 95 SettingsRoot& GetSettingsRoot( |
| 96 settings_namespace::Namespace settings_namespace); | 96 settings_namespace::Namespace settings_namespace); |
| 97 | 97 |
| 98 base::FilePath GetRulesDBPath() const; | 98 base::FilePath GetRulesDBPath() const; |
| 99 base::FilePath GetStateDBPath() const; | 99 base::FilePath GetStateDBPath() const; |
| 100 | 100 |
| 101 const base::FilePath profile_path_; | 101 const base::FilePath profile_path_; |
| 102 SettingsRoot local_settings_; | 102 SettingsRoot local_settings_; |
| 103 SettingsRoot sync_settings_; | 103 SettingsRoot sync_settings_; |
| 104 SettingsRoot managed_settings_; | 104 SettingsRoot managed_settings_; |
| 105 | 105 |
| 106 DISALLOW_COPY_AND_ASSIGN(LegacyValueStoreFactory); | 106 DISALLOW_COPY_AND_ASSIGN(LegacyValueStoreFactory); |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 } // namespace extensions | 109 } // namespace extensions |
| 110 | 110 |
| 111 #endif // EXTENSIONS_BROWSER_VALUE_STORE_LEGACY_VALUE_STORE_FACTORY_H_ | 111 #endif // EXTENSIONS_BROWSER_VALUE_STORE_LEGACY_VALUE_STORE_FACTORY_H_ |
| OLD | NEW |