| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/extension_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 #include "ppapi/features/features.h" | 139 #include "ppapi/features/features.h" |
| 140 #include "storage/browser/database/database_tracker.h" | 140 #include "storage/browser/database/database_tracker.h" |
| 141 #include "storage/browser/quota/quota_manager.h" | 141 #include "storage/browser/quota/quota_manager.h" |
| 142 #include "storage/common/database/database_identifier.h" | 142 #include "storage/common/database/database_identifier.h" |
| 143 #include "testing/gmock/include/gmock/gmock.h" | 143 #include "testing/gmock/include/gmock/gmock.h" |
| 144 #include "testing/gtest/include/gtest/gtest.h" | 144 #include "testing/gtest/include/gtest/gtest.h" |
| 145 #include "testing/platform_test.h" | 145 #include "testing/platform_test.h" |
| 146 #include "ui/base/l10n/l10n_util.h" | 146 #include "ui/base/l10n/l10n_util.h" |
| 147 #include "url/gurl.h" | 147 #include "url/gurl.h" |
| 148 | 148 |
| 149 #if defined(OS_CHROMEOS) | |
| 150 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" | |
| 151 #include "chrome/browser/chromeos/settings/cros_settings.h" | |
| 152 #include "chrome/browser/chromeos/settings/device_settings_service.h" | |
| 153 #endif | |
| 154 | |
| 155 // The blacklist tests rely on the safe-browsing database. | 149 // The blacklist tests rely on the safe-browsing database. |
| 156 #if defined(SAFE_BROWSING_DB_LOCAL) | 150 #if defined(SAFE_BROWSING_DB_LOCAL) |
| 157 #define ENABLE_BLACKLIST_TESTS | 151 #define ENABLE_BLACKLIST_TESTS |
| 158 #endif | 152 #endif |
| 159 | 153 |
| 160 using content::BrowserContext; | 154 using content::BrowserContext; |
| 161 using content::BrowserThread; | 155 using content::BrowserThread; |
| 162 using content::DOMStorageContext; | 156 using content::DOMStorageContext; |
| 163 using content::IndexedDBContext; | 157 using content::IndexedDBContext; |
| 164 using content::PluginService; | 158 using content::PluginService; |
| (...skipping 5392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5557 TEST_F(ExtensionServiceTestSimple, Enabledness) { | 5551 TEST_F(ExtensionServiceTestSimple, Enabledness) { |
| 5558 // Make sure the PluginService singleton is destroyed at the end of the test. | 5552 // Make sure the PluginService singleton is destroyed at the end of the test. |
| 5559 base::ShadowingAtExitManager at_exit_manager; | 5553 base::ShadowingAtExitManager at_exit_manager; |
| 5560 #if BUILDFLAG(ENABLE_PLUGINS) | 5554 #if BUILDFLAG(ENABLE_PLUGINS) |
| 5561 content::PluginService::GetInstance()->Init(); | 5555 content::PluginService::GetInstance()->Init(); |
| 5562 #endif | 5556 #endif |
| 5563 | 5557 |
| 5564 ExtensionErrorReporter::Init(false); // no noisy errors | 5558 ExtensionErrorReporter::Init(false); // no noisy errors |
| 5565 ExtensionsReadyRecorder recorder; | 5559 ExtensionsReadyRecorder recorder; |
| 5566 std::unique_ptr<TestingProfile> profile(new TestingProfile()); | 5560 std::unique_ptr<TestingProfile> profile(new TestingProfile()); |
| 5567 #if defined OS_CHROMEOS | |
| 5568 chromeos::ScopedTestDeviceSettingsService device_settings_service; | |
| 5569 chromeos::ScopedTestCrosSettings cros_settings; | |
| 5570 std::unique_ptr<chromeos::ScopedTestUserManager> user_manager( | |
| 5571 new chromeos::ScopedTestUserManager); | |
| 5572 #endif | |
| 5573 std::unique_ptr<base::CommandLine> command_line; | 5561 std::unique_ptr<base::CommandLine> command_line; |
| 5574 base::FilePath install_dir = profile->GetPath() | 5562 base::FilePath install_dir = profile->GetPath() |
| 5575 .AppendASCII(extensions::kInstallDirectoryName); | 5563 .AppendASCII(extensions::kInstallDirectoryName); |
| 5576 | 5564 |
| 5577 // By default, we are enabled. | 5565 // By default, we are enabled. |
| 5578 command_line.reset(new base::CommandLine(base::CommandLine::NO_PROGRAM)); | 5566 command_line.reset(new base::CommandLine(base::CommandLine::NO_PROGRAM)); |
| 5579 ExtensionService* service = static_cast<extensions::TestExtensionSystem*>( | 5567 ExtensionService* service = static_cast<extensions::TestExtensionSystem*>( |
| 5580 ExtensionSystem::Get(profile.get()))-> | 5568 ExtensionSystem::Get(profile.get()))-> |
| 5581 CreateExtensionService( | 5569 CreateExtensionService( |
| 5582 command_line.get(), | 5570 command_line.get(), |
| 5583 install_dir, | 5571 install_dir, |
| 5584 false); | 5572 false); |
| 5585 EXPECT_TRUE(service->extensions_enabled()); | 5573 EXPECT_TRUE(service->extensions_enabled()); |
| 5586 service->Init(); | 5574 service->Init(); |
| 5587 content::RunAllBlockingPoolTasksUntilIdle(); | 5575 content::RunAllBlockingPoolTasksUntilIdle(); |
| 5588 EXPECT_TRUE(recorder.ready()); | 5576 EXPECT_TRUE(recorder.ready()); |
| 5589 #if defined OS_CHROMEOS | |
| 5590 user_manager.reset(); | |
| 5591 #endif | |
| 5592 | 5577 |
| 5593 // If either the command line or pref is set, we are disabled. | 5578 // If either the command line or pref is set, we are disabled. |
| 5594 recorder.set_ready(false); | 5579 recorder.set_ready(false); |
| 5595 profile.reset(new TestingProfile()); | 5580 profile.reset(new TestingProfile()); |
| 5596 command_line->AppendSwitch(switches::kDisableExtensions); | 5581 command_line->AppendSwitch(switches::kDisableExtensions); |
| 5597 service = static_cast<extensions::TestExtensionSystem*>( | 5582 service = static_cast<extensions::TestExtensionSystem*>( |
| 5598 ExtensionSystem::Get(profile.get()))-> | 5583 ExtensionSystem::Get(profile.get()))-> |
| 5599 CreateExtensionService( | 5584 CreateExtensionService( |
| 5600 command_line.get(), | 5585 command_line.get(), |
| 5601 install_dir, | 5586 install_dir, |
| (...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6959 shared_module->manifest()->type()); | 6944 shared_module->manifest()->type()); |
| 6960 EXPECT_TRUE(registry()->enabled_extensions().Contains(kExtensionId)); | 6945 EXPECT_TRUE(registry()->enabled_extensions().Contains(kExtensionId)); |
| 6961 | 6946 |
| 6962 // Reload the extension and wait for it to complete. This previously crashed | 6947 // Reload the extension and wait for it to complete. This previously crashed |
| 6963 // (see crbug.com/676815). | 6948 // (see crbug.com/676815). |
| 6964 service()->ReloadExtension(kExtensionId); | 6949 service()->ReloadExtension(kExtensionId); |
| 6965 content::RunAllBlockingPoolTasksUntilIdle(); | 6950 content::RunAllBlockingPoolTasksUntilIdle(); |
| 6966 // The shared module should be enabled. | 6951 // The shared module should be enabled. |
| 6967 EXPECT_TRUE(registry()->enabled_extensions().Contains(kExtensionId)); | 6952 EXPECT_TRUE(registry()->enabled_extensions().Contains(kExtensionId)); |
| 6968 } | 6953 } |
| OLD | NEW |