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

Side by Side Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 291603002: Don't try to reload blacklisted extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: real rebase Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_unittest.h" 5 #include "chrome/browser/extensions/extension_service_unittest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 3000 matching lines...) Expand 10 before | Expand all | Expand 10 after
3011 EXPECT_EQ(0u, registry_->disabled_extensions().size()); 3011 EXPECT_EQ(0u, registry_->disabled_extensions().size());
3012 } 3012 }
3013 #endif // !defined(OS_POSIX) || defined(OS_MACOSX) 3013 #endif // !defined(OS_POSIX) || defined(OS_MACOSX)
3014 3014
3015 namespace { 3015 namespace {
3016 3016
3017 bool IsExtension(const Extension* extension) { 3017 bool IsExtension(const Extension* extension) {
3018 return extension->GetType() == Manifest::TYPE_EXTENSION; 3018 return extension->GetType() == Manifest::TYPE_EXTENSION;
3019 } 3019 }
3020 3020
3021 #if defined(ENABLE_BLACKLIST_TESTS)
3022 std::set<std::string> StringSet(const std::string& s) {
3023 std::set<std::string> set;
3024 set.insert(s);
3025 return set;
3026 }
3027 std::set<std::string> StringSet(const std::string& s1, const std::string& s2) {
3028 std::set<std::string> set = StringSet(s1);
3029 set.insert(s2);
3030 return set;
3031 }
3032 #endif // defined(ENABLE_BLACKLIST_TESTS)
3033
3021 } // namespace 3034 } // namespace
3022 3035
3023 // Test adding a pending extension. 3036 // Test adding a pending extension.
3024 TEST_F(ExtensionServiceTest, AddPendingExtensionFromSync) { 3037 TEST_F(ExtensionServiceTest, AddPendingExtensionFromSync) {
3025 InitializeEmptyExtensionService(); 3038 InitializeEmptyExtensionService();
3026 3039
3027 const std::string kFakeId(all_zero); 3040 const std::string kFakeId(all_zero);
3028 const GURL kFakeUpdateURL("http:://fake.update/url"); 3041 const GURL kFakeUpdateURL("http:://fake.update/url");
3029 const bool kFakeInstallSilently(true); 3042 const bool kFakeInstallSilently(true);
3030 const bool kFakeRemoteInstall(false); 3043 const bool kFakeRemoteInstall(false);
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
3638 base::RunLoop().RunUntilIdle(); 3651 base::RunLoop().RunUntilIdle();
3639 3652
3640 // good0 re-enabled, other remain as they were. 3653 // good0 re-enabled, other remain as they were.
3641 EXPECT_TRUE(enabled_extensions.Contains(good0)); 3654 EXPECT_TRUE(enabled_extensions.Contains(good0));
3642 EXPECT_FALSE(disabled_extensions.Contains(good0)); 3655 EXPECT_FALSE(disabled_extensions.Contains(good0));
3643 EXPECT_FALSE(enabled_extensions.Contains(good1)); 3656 EXPECT_FALSE(enabled_extensions.Contains(good1));
3644 EXPECT_TRUE(disabled_extensions.Contains(good1)); 3657 EXPECT_TRUE(disabled_extensions.Contains(good1));
3645 EXPECT_TRUE(enabled_extensions.Contains(good2)); 3658 EXPECT_TRUE(enabled_extensions.Contains(good2));
3646 EXPECT_FALSE(disabled_extensions.Contains(good2)); 3659 EXPECT_FALSE(disabled_extensions.Contains(good2));
3647 } 3660 }
3661
3662 // Tests that blacklisted extensions cannot be reloaded, both those loaded
3663 // before and after extension service startup.
3664 TEST_F(ExtensionServiceTest, ReloadBlacklistedExtension) {
3665 extensions::TestBlacklist test_blacklist;
3666
3667 InitializeGoodInstalledExtensionService();
3668 test_blacklist.Attach(service_->blacklist_);
3669
3670 test_blacklist.SetBlacklistState(
3671 good1, extensions::BLACKLISTED_MALWARE, false);
3672 service_->Init();
3673 test_blacklist.SetBlacklistState(
3674 good2, extensions::BLACKLISTED_MALWARE, false);
3675 base::RunLoop().RunUntilIdle();
3676
3677 EXPECT_EQ(StringSet(good0), registry_->enabled_extensions().GetIDs());
3678 EXPECT_EQ(StringSet(good1, good2),
3679 registry_->blacklisted_extensions().GetIDs());
3680
3681 service_->ReloadExtension(good1);
3682 service_->ReloadExtension(good2);
3683 base::RunLoop().RunUntilIdle();
3684
3685 EXPECT_EQ(StringSet(good0), registry_->enabled_extensions().GetIDs());
3686 EXPECT_EQ(StringSet(good1, good2),
3687 registry_->blacklisted_extensions().GetIDs());
3688 }
3689
3648 #endif // defined(ENABLE_BLACKLIST_TESTS) 3690 #endif // defined(ENABLE_BLACKLIST_TESTS)
3649 3691
3650 // Will not install extension blacklisted by policy. 3692 // Will not install extension blacklisted by policy.
3651 TEST_F(ExtensionServiceTest, BlacklistedByPolicyWillNotInstall) { 3693 TEST_F(ExtensionServiceTest, BlacklistedByPolicyWillNotInstall) {
3652 InitializeEmptyExtensionService(); 3694 InitializeEmptyExtensionService();
3653 3695
3654 // Blacklist everything. 3696 // Blacklist everything.
3655 { 3697 {
3656 ListPrefUpdate update(profile_->GetPrefs(), 3698 ListPrefUpdate update(profile_->GetPrefs(),
3657 extensions::pref_names::kInstallDenyList); 3699 extensions::pref_names::kInstallDenyList);
(...skipping 3319 matching lines...) Expand 10 before | Expand all | Expand 10 after
6977 7019
6978 service_->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, 7020 service_->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED,
6979 content::Source<Profile>(profile_.get()), 7021 content::Source<Profile>(profile_.get()),
6980 content::NotificationService::NoDetails()); 7022 content::NotificationService::NoDetails());
6981 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); 7023 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_);
6982 EXPECT_EQ(0u, registry_->enabled_extensions().size()); 7024 EXPECT_EQ(0u, registry_->enabled_extensions().size());
6983 EXPECT_EQ(0u, registry_->disabled_extensions().size()); 7025 EXPECT_EQ(0u, registry_->disabled_extensions().size());
6984 EXPECT_EQ(0u, registry_->terminated_extensions().size()); 7026 EXPECT_EQ(0u, registry_->terminated_extensions().size());
6985 EXPECT_EQ(0u, registry_->blacklisted_extensions().size()); 7027 EXPECT_EQ(0u, registry_->blacklisted_extensions().size());
6986 } 7028 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698