| 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_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 3435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3446 extensions::TestBlacklist test_blacklist; | 3446 extensions::TestBlacklist test_blacklist; |
| 3447 | 3447 |
| 3448 InitializeGoodInstalledExtensionService(); | 3448 InitializeGoodInstalledExtensionService(); |
| 3449 test_blacklist.Attach(service_->blacklist_); | 3449 test_blacklist.Attach(service_->blacklist_); |
| 3450 ExtensionPrefs::Get(profile_.get())->SetExtensionBlacklisted(good0, true); | 3450 ExtensionPrefs::Get(profile_.get())->SetExtensionBlacklisted(good0, true); |
| 3451 ExtensionPrefs::Get(profile_.get())->SetExtensionBlacklisted(good1, true); | 3451 ExtensionPrefs::Get(profile_.get())->SetExtensionBlacklisted(good1, true); |
| 3452 | 3452 |
| 3453 test_blacklist.SetBlacklistState( | 3453 test_blacklist.SetBlacklistState( |
| 3454 good1, extensions::BLACKLISTED_MALWARE, false); | 3454 good1, extensions::BLACKLISTED_MALWARE, false); |
| 3455 | 3455 |
| 3456 // Extension service hasn't loaded yet, but IsExtensionEnabled reads out of |
| 3457 // prefs. Ensure it takes into account the blacklist state (crbug.com/373842). |
| 3458 EXPECT_FALSE(service_->IsExtensionEnabled(good0)); |
| 3459 EXPECT_FALSE(service_->IsExtensionEnabled(good1)); |
| 3460 EXPECT_TRUE(service_->IsExtensionEnabled(good2)); |
| 3461 |
| 3456 service_->Init(); | 3462 service_->Init(); |
| 3457 | 3463 |
| 3458 ASSERT_EQ(2u, registry_->blacklisted_extensions().size()); | 3464 EXPECT_EQ(2u, registry_->blacklisted_extensions().size()); |
| 3459 ASSERT_EQ(1u, registry_->enabled_extensions().size()); | 3465 EXPECT_EQ(1u, registry_->enabled_extensions().size()); |
| 3460 | 3466 |
| 3461 ASSERT_TRUE(registry_->blacklisted_extensions().Contains(good0)); | 3467 EXPECT_TRUE(registry_->blacklisted_extensions().Contains(good0)); |
| 3462 ASSERT_TRUE(registry_->blacklisted_extensions().Contains(good1)); | 3468 EXPECT_TRUE(registry_->blacklisted_extensions().Contains(good1)); |
| 3463 ASSERT_TRUE(registry_->enabled_extensions().Contains(good2)); | 3469 EXPECT_TRUE(registry_->enabled_extensions().Contains(good2)); |
| 3464 | 3470 |
| 3465 // Give time for the blacklist to update. | 3471 // Give time for the blacklist to update. |
| 3466 base::RunLoop().RunUntilIdle(); | 3472 base::RunLoop().RunUntilIdle(); |
| 3467 | 3473 |
| 3468 ASSERT_EQ(1u, registry_->blacklisted_extensions().size()); | 3474 EXPECT_EQ(1u, registry_->blacklisted_extensions().size()); |
| 3469 ASSERT_EQ(2u, registry_->enabled_extensions().size()); | 3475 EXPECT_EQ(2u, registry_->enabled_extensions().size()); |
| 3470 | 3476 |
| 3471 ASSERT_TRUE(registry_->enabled_extensions().Contains(good0)); | 3477 EXPECT_TRUE(registry_->enabled_extensions().Contains(good0)); |
| 3472 ASSERT_TRUE(registry_->blacklisted_extensions().Contains(good1)); | 3478 EXPECT_TRUE(registry_->blacklisted_extensions().Contains(good1)); |
| 3473 ASSERT_TRUE(registry_->enabled_extensions().Contains(good2)); | 3479 EXPECT_TRUE(registry_->enabled_extensions().Contains(good2)); |
| 3474 } | 3480 } |
| 3475 #endif // defined(ENABLE_BLACKLIST_TESTS) | 3481 #endif // defined(ENABLE_BLACKLIST_TESTS) |
| 3476 | 3482 |
| 3477 #if defined(ENABLE_BLACKLIST_TESTS) | 3483 #if defined(ENABLE_BLACKLIST_TESTS) |
| 3478 // Extension is added to blacklist with BLACKLISTED_POTENTIALLY_UNWANTED state | 3484 // Extension is added to blacklist with BLACKLISTED_POTENTIALLY_UNWANTED state |
| 3479 // after it is installed. It is then successfully re-enabled by the user. | 3485 // after it is installed. It is then successfully re-enabled by the user. |
| 3480 TEST_F(ExtensionServiceTest, GreylistedExtensionDisabled) { | 3486 TEST_F(ExtensionServiceTest, GreylistedExtensionDisabled) { |
| 3481 extensions::TestBlacklist test_blacklist; | 3487 extensions::TestBlacklist test_blacklist; |
| 3482 // A profile with 3 extensions installed: good0, good1, and good2. | 3488 // A profile with 3 extensions installed: good0, good1, and good2. |
| 3483 InitializeGoodInstalledExtensionService(); | 3489 InitializeGoodInstalledExtensionService(); |
| (...skipping 3493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6977 | 6983 |
| 6978 service_->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, | 6984 service_->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, |
| 6979 content::Source<Profile>(profile_.get()), | 6985 content::Source<Profile>(profile_.get()), |
| 6980 content::NotificationService::NoDetails()); | 6986 content::NotificationService::NoDetails()); |
| 6981 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); | 6987 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); |
| 6982 EXPECT_EQ(0u, registry_->enabled_extensions().size()); | 6988 EXPECT_EQ(0u, registry_->enabled_extensions().size()); |
| 6983 EXPECT_EQ(0u, registry_->disabled_extensions().size()); | 6989 EXPECT_EQ(0u, registry_->disabled_extensions().size()); |
| 6984 EXPECT_EQ(0u, registry_->terminated_extensions().size()); | 6990 EXPECT_EQ(0u, registry_->terminated_extensions().size()); |
| 6985 EXPECT_EQ(0u, registry_->blacklisted_extensions().size()); | 6991 EXPECT_EQ(0u, registry_->blacklisted_extensions().size()); |
| 6986 } | 6992 } |
| OLD | NEW |