| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/extensions/api/storage/settings_test_util.h" | 5 #include "extensions/browser/api/storage/settings_test_util.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "chrome/browser/extensions/api/storage/settings_frontend.h" | 8 #include "extensions/browser/api/storage/settings_frontend.h" |
| 9 #include "chrome/browser/extensions/extension_system_factory.h" | |
| 10 #include "extensions/browser/extension_registry.h" | 9 #include "extensions/browser/extension_registry.h" |
| 10 #include "extensions/browser/extension_system_provider.h" |
| 11 #include "extensions/browser/extensions_browser_client.h" |
| 11 #include "extensions/common/extension.h" | 12 #include "extensions/common/extension.h" |
| 12 #include "extensions/common/permissions/permissions_data.h" | 13 #include "extensions/common/permissions/permissions_data.h" |
| 13 | 14 |
| 14 namespace extensions { | 15 namespace extensions { |
| 15 | 16 |
| 16 namespace settings_test_util { | 17 namespace settings_test_util { |
| 17 | 18 |
| 18 // Intended as a StorageCallback from GetStorage. | 19 // Intended as a StorageCallback from GetStorage. |
| 19 static void AssignStorage(ValueStore** dst, ValueStore* src) { | 20 static void AssignStorage(ValueStore** dst, ValueStore* src) { |
| 20 *dst = src; | 21 *dst = src; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 MockExtensionSystem::MockExtensionSystem(Profile* profile) | 104 MockExtensionSystem::MockExtensionSystem(Profile* profile) |
| 104 : TestExtensionSystem(profile) {} | 105 : TestExtensionSystem(profile) {} |
| 105 MockExtensionSystem::~MockExtensionSystem() {} | 106 MockExtensionSystem::~MockExtensionSystem() {} |
| 106 | 107 |
| 107 EventRouter* MockExtensionSystem::event_router() { | 108 EventRouter* MockExtensionSystem::event_router() { |
| 108 if (!event_router_.get()) | 109 if (!event_router_.get()) |
| 109 event_router_.reset(new EventRouter(profile_, NULL)); | 110 event_router_.reset(new EventRouter(profile_, NULL)); |
| 110 return event_router_.get(); | 111 return event_router_.get(); |
| 111 } | 112 } |
| 112 | 113 |
| 113 ExtensionService* MockExtensionSystem::extension_service() { | |
| 114 ExtensionServiceInterface* as_interface = | |
| 115 static_cast<ExtensionServiceInterface*>(&extension_service_); | |
| 116 return static_cast<ExtensionService*>(as_interface); | |
| 117 } | |
| 118 | |
| 119 BrowserContextKeyedService* BuildMockExtensionSystem( | 114 BrowserContextKeyedService* BuildMockExtensionSystem( |
| 120 content::BrowserContext* profile) { | 115 content::BrowserContext* profile) { |
| 121 return new MockExtensionSystem(static_cast<Profile*>(profile)); | 116 return new MockExtensionSystem(static_cast<Profile*>(profile)); |
| 122 } | 117 } |
| 123 | 118 |
| 124 // MockProfile | 119 // MockProfile |
| 125 | 120 |
| 126 MockProfile::MockProfile(const base::FilePath& file_path) | 121 MockProfile::MockProfile(const base::FilePath& file_path) |
| 127 : TestingProfile(file_path) { | 122 : TestingProfile(file_path) { |
| 128 ExtensionSystemFactory::GetInstance()->SetTestingFactoryAndUse(this, | 123 ExtensionsBrowserClient::Get() |
| 129 &BuildMockExtensionSystem); | 124 ->GetExtensionSystemFactory() |
| 125 ->SetTestingFactoryAndUse(this, &BuildMockExtensionSystem); |
| 130 } | 126 } |
| 131 | 127 |
| 132 MockProfile::~MockProfile() {} | 128 MockProfile::~MockProfile() {} |
| 133 | 129 |
| 134 // ScopedSettingsFactory | 130 // ScopedSettingsFactory |
| 135 | 131 |
| 136 ScopedSettingsStorageFactory::ScopedSettingsStorageFactory() {} | 132 ScopedSettingsStorageFactory::ScopedSettingsStorageFactory() {} |
| 137 | 133 |
| 138 ScopedSettingsStorageFactory::ScopedSettingsStorageFactory( | 134 ScopedSettingsStorageFactory::ScopedSettingsStorageFactory( |
| 139 const scoped_refptr<SettingsStorageFactory>& delegate) | 135 const scoped_refptr<SettingsStorageFactory>& delegate) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 155 | 151 |
| 156 void ScopedSettingsStorageFactory::DeleteDatabaseIfExists( | 152 void ScopedSettingsStorageFactory::DeleteDatabaseIfExists( |
| 157 const base::FilePath& base_path, | 153 const base::FilePath& base_path, |
| 158 const std::string& extension_id) { | 154 const std::string& extension_id) { |
| 159 delegate_->DeleteDatabaseIfExists(base_path, extension_id); | 155 delegate_->DeleteDatabaseIfExists(base_path, extension_id); |
| 160 } | 156 } |
| 161 | 157 |
| 162 } // namespace settings_test_util | 158 } // namespace settings_test_util |
| 163 | 159 |
| 164 } // namespace extensions | 160 } // namespace extensions |
| OLD | NEW |