Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(788)

Unified Diff: chrome/browser/extensions/extensions_service_unittest.cc

Issue 3166023: When extension is blacklisted by admin policy, it should be removed if alread... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extensions_service.cc ('k') | chrome/browser/profile_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extensions_service_unittest.cc
===================================================================
--- chrome/browser/extensions/extensions_service_unittest.cc (revision 56844)
+++ chrome/browser/extensions/extensions_service_unittest.cc (working copy)
@@ -1844,6 +1844,35 @@
EXPECT_EQ(1u, service_->extensions()->size());
}
+// Extension blacklisted by policy get unloaded after installing.
+TEST_F(ExtensionsServiceTest, BlacklistedByPolicyRemovedIfRunning) {
+ InitializeEmptyExtensionsService();
+
+ // Install good_crx.
+ FilePath extensions_path;
+ ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path));
+ extensions_path = extensions_path.AppendASCII("extensions");
+ FilePath path = extensions_path.AppendASCII("good.crx");
+ service_->InstallExtension(path);
+ loop_.RunAllPending();
+ EXPECT_EQ(1u, service_->extensions()->size());
+
+ ListValue* blacklist = prefs_->GetMutableList("extensions.install.denylist");
+ ASSERT_TRUE(blacklist != NULL);
+
+ // Blacklist this extension.
+ blacklist->Append(Value::CreateStringValue(good_crx));
+ prefs_->ScheduleSavePersistentPrefs();
+
+ // Programmatically appending to the prefs doesn't seem to notify the
+ // observers... :/
+ prefs_->pref_notifier()->FireObservers("extensions.install.denylist");
+
+ // Extension should not be running now.
+ loop_.RunAllPending();
+ EXPECT_EQ(0u, service_->extensions()->size());
+}
+
// Tests disabling extensions
TEST_F(ExtensionsServiceTest, DisableExtension) {
InitializeEmptyExtensionsService();
@@ -2365,19 +2394,19 @@
// enabled or not.
TEST(ExtensionsServiceTestSimple, Enabledness) {
ExtensionsReadyRecorder recorder;
- TestingProfile profile;
+ scoped_ptr<TestingProfile> profile(new TestingProfile());
MessageLoop loop;
ChromeThread ui_thread(ChromeThread::UI, &loop);
ChromeThread file_thread(ChromeThread::FILE, &loop);
scoped_ptr<CommandLine> command_line;
scoped_refptr<ExtensionsService> service;
- FilePath install_dir = profile.GetPath()
+ FilePath install_dir = profile->GetPath()
.AppendASCII(ExtensionsService::kInstallDirectoryName);
// By default, we are enabled.
command_line.reset(new CommandLine(CommandLine::ARGUMENTS_ONLY));
- service = new ExtensionsService(&profile, command_line.get(),
- profile.GetPrefs(), install_dir, false);
+ service = new ExtensionsService(profile.get(), command_line.get(),
+ profile->GetPrefs(), install_dir, false);
EXPECT_TRUE(service->extensions_enabled());
service->Init();
loop.RunAllPending();
@@ -2385,27 +2414,31 @@
// If either the command line or pref is set, we are disabled.
recorder.set_ready(false);
+ profile.reset(new TestingProfile());
command_line->AppendSwitch(switches::kDisableExtensions);
- service = new ExtensionsService(&profile, command_line.get(),
- profile.GetPrefs(), install_dir, false);
+ service = new ExtensionsService(profile.get(), command_line.get(),
+ profile->GetPrefs(), install_dir, false);
EXPECT_FALSE(service->extensions_enabled());
service->Init();
loop.RunAllPending();
EXPECT_TRUE(recorder.ready());
recorder.set_ready(false);
- profile.GetPrefs()->SetBoolean(prefs::kDisableExtensions, true);
- service = new ExtensionsService(&profile, command_line.get(),
- profile.GetPrefs(), install_dir, false);
+ profile.reset(new TestingProfile());
+ profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true);
+ service = new ExtensionsService(profile.get(), command_line.get(),
+ profile->GetPrefs(), install_dir, false);
EXPECT_FALSE(service->extensions_enabled());
service->Init();
loop.RunAllPending();
EXPECT_TRUE(recorder.ready());
recorder.set_ready(false);
+ profile.reset(new TestingProfile());
+ profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true);
command_line.reset(new CommandLine(CommandLine::ARGUMENTS_ONLY));
- service = new ExtensionsService(&profile, command_line.get(),
- profile.GetPrefs(), install_dir, false);
+ service = new ExtensionsService(profile.get(), command_line.get(),
+ profile->GetPrefs(), install_dir, false);
EXPECT_FALSE(service->extensions_enabled());
service->Init();
loop.RunAllPending();
« no previous file with comments | « chrome/browser/extensions/extensions_service.cc ('k') | chrome/browser/profile_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698