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 <algorithm> | 5 #include <algorithm> |
6 #include <set> | 6 #include <set> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 5583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5594 ExtensionErrorReporter::Init(false); // no noisy errors | 5594 ExtensionErrorReporter::Init(false); // no noisy errors |
5595 ExtensionsReadyRecorder recorder; | 5595 ExtensionsReadyRecorder recorder; |
5596 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 5596 scoped_ptr<TestingProfile> profile(new TestingProfile()); |
5597 content::TestBrowserThreadBundle thread_bundle_; | 5597 content::TestBrowserThreadBundle thread_bundle_; |
5598 #if defined OS_CHROMEOS | 5598 #if defined OS_CHROMEOS |
5599 chromeos::ScopedTestDeviceSettingsService device_settings_service; | 5599 chromeos::ScopedTestDeviceSettingsService device_settings_service; |
5600 chromeos::ScopedTestCrosSettings cros_settings; | 5600 chromeos::ScopedTestCrosSettings cros_settings; |
5601 scoped_ptr<chromeos::ScopedTestUserManager> user_manager( | 5601 scoped_ptr<chromeos::ScopedTestUserManager> user_manager( |
5602 new chromeos::ScopedTestUserManager); | 5602 new chromeos::ScopedTestUserManager); |
5603 #endif | 5603 #endif |
5604 scoped_ptr<CommandLine> command_line; | 5604 scoped_ptr<base::CommandLine> command_line; |
5605 base::FilePath install_dir = profile->GetPath() | 5605 base::FilePath install_dir = profile->GetPath() |
5606 .AppendASCII(extensions::kInstallDirectoryName); | 5606 .AppendASCII(extensions::kInstallDirectoryName); |
5607 | 5607 |
5608 // By default, we are enabled. | 5608 // By default, we are enabled. |
5609 command_line.reset(new CommandLine(CommandLine::NO_PROGRAM)); | 5609 command_line.reset(new base::CommandLine(base::CommandLine::NO_PROGRAM)); |
5610 ExtensionService* service = static_cast<extensions::TestExtensionSystem*>( | 5610 ExtensionService* service = static_cast<extensions::TestExtensionSystem*>( |
5611 ExtensionSystem::Get(profile.get()))-> | 5611 ExtensionSystem::Get(profile.get()))-> |
5612 CreateExtensionService( | 5612 CreateExtensionService( |
5613 command_line.get(), | 5613 command_line.get(), |
5614 install_dir, | 5614 install_dir, |
5615 false); | 5615 false); |
5616 EXPECT_TRUE(service->extensions_enabled()); | 5616 EXPECT_TRUE(service->extensions_enabled()); |
5617 service->Init(); | 5617 service->Init(); |
5618 base::RunLoop().RunUntilIdle(); | 5618 base::RunLoop().RunUntilIdle(); |
5619 EXPECT_TRUE(recorder.ready()); | 5619 EXPECT_TRUE(recorder.ready()); |
(...skipping 26 matching lines...) Expand all Loading... |
5646 install_dir, | 5646 install_dir, |
5647 false); | 5647 false); |
5648 EXPECT_FALSE(service->extensions_enabled()); | 5648 EXPECT_FALSE(service->extensions_enabled()); |
5649 service->Init(); | 5649 service->Init(); |
5650 base::RunLoop().RunUntilIdle(); | 5650 base::RunLoop().RunUntilIdle(); |
5651 EXPECT_TRUE(recorder.ready()); | 5651 EXPECT_TRUE(recorder.ready()); |
5652 | 5652 |
5653 recorder.set_ready(false); | 5653 recorder.set_ready(false); |
5654 profile.reset(new TestingProfile()); | 5654 profile.reset(new TestingProfile()); |
5655 profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true); | 5655 profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true); |
5656 command_line.reset(new CommandLine(CommandLine::NO_PROGRAM)); | 5656 command_line.reset(new base::CommandLine(base::CommandLine::NO_PROGRAM)); |
5657 service = static_cast<extensions::TestExtensionSystem*>( | 5657 service = static_cast<extensions::TestExtensionSystem*>( |
5658 ExtensionSystem::Get(profile.get()))-> | 5658 ExtensionSystem::Get(profile.get()))-> |
5659 CreateExtensionService( | 5659 CreateExtensionService( |
5660 command_line.get(), | 5660 command_line.get(), |
5661 install_dir, | 5661 install_dir, |
5662 false); | 5662 false); |
5663 EXPECT_FALSE(service->extensions_enabled()); | 5663 EXPECT_FALSE(service->extensions_enabled()); |
5664 service->Init(); | 5664 service->Init(); |
5665 base::RunLoop().RunUntilIdle(); | 5665 base::RunLoop().RunUntilIdle(); |
5666 EXPECT_TRUE(recorder.ready()); | 5666 EXPECT_TRUE(recorder.ready()); |
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7034 Extension::NO_FLAGS, | 7034 Extension::NO_FLAGS, |
7035 false)); | 7035 false)); |
7036 EXPECT_TRUE((info = pending->GetById(kGoodId))); | 7036 EXPECT_TRUE((info = pending->GetById(kGoodId))); |
7037 EXPECT_FALSE(info->version().IsValid()); | 7037 EXPECT_FALSE(info->version().IsValid()); |
7038 } | 7038 } |
7039 | 7039 |
7040 // This makes sure we can package and install CRX files that use whitelisted | 7040 // This makes sure we can package and install CRX files that use whitelisted |
7041 // permissions. | 7041 // permissions. |
7042 TEST_F(ExtensionServiceTest, InstallWhitelistedExtension) { | 7042 TEST_F(ExtensionServiceTest, InstallWhitelistedExtension) { |
7043 std::string test_id = "hdkklepkcpckhnpgjnmbdfhehckloojk"; | 7043 std::string test_id = "hdkklepkcpckhnpgjnmbdfhehckloojk"; |
7044 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 7044 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
7045 extensions::switches::kWhitelistedExtensionID, test_id); | 7045 extensions::switches::kWhitelistedExtensionID, test_id); |
7046 | 7046 |
7047 InitializeEmptyExtensionService(); | 7047 InitializeEmptyExtensionService(); |
7048 base::FilePath path = data_dir().AppendASCII("permissions"); | 7048 base::FilePath path = data_dir().AppendASCII("permissions"); |
7049 base::FilePath pem_path = path | 7049 base::FilePath pem_path = path |
7050 .AppendASCII("whitelist.pem"); | 7050 .AppendASCII("whitelist.pem"); |
7051 path = path | 7051 path = path |
7052 .AppendASCII("whitelist"); | 7052 .AppendASCII("whitelist"); |
7053 | 7053 |
7054 const Extension* extension = PackAndInstallCRX(path, pem_path, INSTALL_NEW); | 7054 const Extension* extension = PackAndInstallCRX(path, pem_path, INSTALL_NEW); |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7574 | 7574 |
7575 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, | 7575 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, |
7576 content::Source<Profile>(profile()), | 7576 content::Source<Profile>(profile()), |
7577 content::NotificationService::NoDetails()); | 7577 content::NotificationService::NoDetails()); |
7578 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); | 7578 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); |
7579 EXPECT_EQ(0u, registry()->enabled_extensions().size()); | 7579 EXPECT_EQ(0u, registry()->enabled_extensions().size()); |
7580 EXPECT_EQ(0u, registry()->disabled_extensions().size()); | 7580 EXPECT_EQ(0u, registry()->disabled_extensions().size()); |
7581 EXPECT_EQ(0u, registry()->terminated_extensions().size()); | 7581 EXPECT_EQ(0u, registry()->terminated_extensions().size()); |
7582 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); | 7582 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); |
7583 } | 7583 } |
OLD | NEW |