| 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/test_extension_system.h" | 5 #include "chrome/browser/extensions/test_extension_system.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "chrome/browser/extensions/blacklist.h" | 9 #include "chrome/browser/extensions/blacklist.h" |
| 10 #include "chrome/browser/extensions/declarative_user_script_manager.h" | 10 #include "chrome/browser/extensions/declarative_user_script_manager.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 TestExtensionSystem::~TestExtensionSystem() { | 45 TestExtensionSystem::~TestExtensionSystem() { |
| 46 } | 46 } |
| 47 | 47 |
| 48 void TestExtensionSystem::Shutdown() { | 48 void TestExtensionSystem::Shutdown() { |
| 49 if (extension_service_) | 49 if (extension_service_) |
| 50 extension_service_->Shutdown(); | 50 extension_service_->Shutdown(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 ExtensionPrefs* TestExtensionSystem::CreateExtensionPrefs( | 53 ExtensionPrefs* TestExtensionSystem::CreateExtensionPrefs( |
| 54 const CommandLine* command_line, | 54 const base::CommandLine* command_line, |
| 55 const base::FilePath& install_directory) { | 55 const base::FilePath& install_directory) { |
| 56 bool extensions_disabled = | 56 bool extensions_disabled = |
| 57 command_line && command_line->HasSwitch(switches::kDisableExtensions); | 57 command_line && command_line->HasSwitch(switches::kDisableExtensions); |
| 58 | 58 |
| 59 // Note that the GetPrefs() creates a TestingPrefService, therefore | 59 // Note that the GetPrefs() creates a TestingPrefService, therefore |
| 60 // the extension controlled pref values set in ExtensionPrefs | 60 // the extension controlled pref values set in ExtensionPrefs |
| 61 // are not reflected in the pref service. One would need to | 61 // are not reflected in the pref service. One would need to |
| 62 // inject a new ExtensionPrefStore(extension_pref_value_map, false). | 62 // inject a new ExtensionPrefStore(extension_pref_value_map, false). |
| 63 | 63 |
| 64 ExtensionPrefs* extension_prefs = ExtensionPrefs::Create( | 64 ExtensionPrefs* extension_prefs = ExtensionPrefs::Create( |
| 65 profile_->GetPrefs(), | 65 profile_->GetPrefs(), |
| 66 install_directory, | 66 install_directory, |
| 67 ExtensionPrefValueMapFactory::GetForBrowserContext(profile_), | 67 ExtensionPrefValueMapFactory::GetForBrowserContext(profile_), |
| 68 ExtensionsBrowserClient::Get()->CreateAppSorting().Pass(), | 68 ExtensionsBrowserClient::Get()->CreateAppSorting().Pass(), |
| 69 extensions_disabled, | 69 extensions_disabled, |
| 70 std::vector<ExtensionPrefsObserver*>()); | 70 std::vector<ExtensionPrefsObserver*>()); |
| 71 ExtensionPrefsFactory::GetInstance()->SetInstanceForTesting( | 71 ExtensionPrefsFactory::GetInstance()->SetInstanceForTesting( |
| 72 profile_, | 72 profile_, |
| 73 extension_prefs); | 73 extension_prefs); |
| 74 return extension_prefs; | 74 return extension_prefs; |
| 75 } | 75 } |
| 76 | 76 |
| 77 ExtensionService* TestExtensionSystem::CreateExtensionService( | 77 ExtensionService* TestExtensionSystem::CreateExtensionService( |
| 78 const CommandLine* command_line, | 78 const base::CommandLine* command_line, |
| 79 const base::FilePath& install_directory, | 79 const base::FilePath& install_directory, |
| 80 bool autoupdate_enabled) { | 80 bool autoupdate_enabled) { |
| 81 if (!ExtensionPrefs::Get(profile_)) | 81 if (!ExtensionPrefs::Get(profile_)) |
| 82 CreateExtensionPrefs(command_line, install_directory); | 82 CreateExtensionPrefs(command_line, install_directory); |
| 83 install_verifier_.reset( | 83 install_verifier_.reset( |
| 84 new InstallVerifier(ExtensionPrefs::Get(profile_), profile_)); | 84 new InstallVerifier(ExtensionPrefs::Get(profile_), profile_)); |
| 85 // The ownership of |value_store_| is immediately transferred to state_store_, | 85 // The ownership of |value_store_| is immediately transferred to state_store_, |
| 86 // but we keep a naked pointer to the TestingValueStore. | 86 // but we keep a naked pointer to the TestingValueStore. |
| 87 scoped_ptr<TestingValueStore> value_store(new TestingValueStore()); | 87 scoped_ptr<TestingValueStore> value_store(new TestingValueStore()); |
| 88 value_store_ = value_store.get(); | 88 value_store_ = value_store.get(); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 return extension_service()->shared_module_service()->GetDependentExtensions( | 177 return extension_service()->shared_module_service()->GetDependentExtensions( |
| 178 extension); | 178 extension); |
| 179 } | 179 } |
| 180 | 180 |
| 181 // static | 181 // static |
| 182 KeyedService* TestExtensionSystem::Build(content::BrowserContext* profile) { | 182 KeyedService* TestExtensionSystem::Build(content::BrowserContext* profile) { |
| 183 return new TestExtensionSystem(static_cast<Profile*>(profile)); | 183 return new TestExtensionSystem(static_cast<Profile*>(profile)); |
| 184 } | 184 } |
| 185 | 185 |
| 186 } // namespace extensions | 186 } // namespace extensions |
| OLD | NEW |