| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 [](const ExternalInstallError* error) { | 246 [](const ExternalInstallError* error) { |
| 247 return error->alert_type() == ExternalInstallError::BUBBLE_ALERT; | 247 return error->alert_type() == ExternalInstallError::BUBBLE_ALERT; |
| 248 }); | 248 }); |
| 249 return found != errors.end(); | 249 return found != errors.end(); |
| 250 } | 250 } |
| 251 | 251 |
| 252 size_t GetExternalInstallBubbleCount(ExtensionService* service) { | 252 size_t GetExternalInstallBubbleCount(ExtensionService* service) { |
| 253 size_t bubble_count = 0u; | 253 size_t bubble_count = 0u; |
| 254 std::vector<ExternalInstallError*> errors = | 254 std::vector<ExternalInstallError*> errors = |
| 255 service->external_install_manager()->GetErrorsForTesting(); | 255 service->external_install_manager()->GetErrorsForTesting(); |
| 256 for (const auto& error : errors) | 256 for (auto* error : errors) |
| 257 bubble_count += error->alert_type() == ExternalInstallError::BUBBLE_ALERT; | 257 bubble_count += error->alert_type() == ExternalInstallError::BUBBLE_ALERT; |
| 258 return bubble_count; | 258 return bubble_count; |
| 259 } | 259 } |
| 260 | 260 |
| 261 } // namespace | 261 } // namespace |
| 262 | 262 |
| 263 class MockExtensionProvider : public extensions::ExternalProviderInterface { | 263 class MockExtensionProvider : public extensions::ExternalProviderInterface { |
| 264 public: | 264 public: |
| 265 MockExtensionProvider( | 265 MockExtensionProvider( |
| 266 VisitorInterface* visitor, | 266 VisitorInterface* visitor, |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 if (!new_prefs) | 529 if (!new_prefs) |
| 530 return; | 530 return; |
| 531 provider_->UpdatePrefs(new_prefs.release()); | 531 provider_->UpdatePrefs(new_prefs.release()); |
| 532 } | 532 } |
| 533 | 533 |
| 534 void OnExternalProviderUpdateComplete( | 534 void OnExternalProviderUpdateComplete( |
| 535 const ExternalProviderInterface* provider, | 535 const ExternalProviderInterface* provider, |
| 536 const ScopedVector<ExternalInstallInfoUpdateUrl>& update_url_extensions, | 536 const ScopedVector<ExternalInstallInfoUpdateUrl>& update_url_extensions, |
| 537 const ScopedVector<ExternalInstallInfoFile>& file_extensions, | 537 const ScopedVector<ExternalInstallInfoFile>& file_extensions, |
| 538 const std::set<std::string>& removed_extensions) override { | 538 const std::set<std::string>& removed_extensions) override { |
| 539 for (const auto& extension_info : update_url_extensions) | 539 for (auto* extension_info : update_url_extensions) |
| 540 update_url_extension_ids_.insert(extension_info->extension_id); | 540 update_url_extension_ids_.insert(extension_info->extension_id); |
| 541 EXPECT_EQ(update_url_extension_ids_.size(), update_url_extensions.size()); | 541 EXPECT_EQ(update_url_extension_ids_.size(), update_url_extensions.size()); |
| 542 | 542 |
| 543 for (const auto& extension_info : file_extensions) | 543 for (auto* extension_info : file_extensions) |
| 544 file_extension_ids_.insert(extension_info->extension_id); | 544 file_extension_ids_.insert(extension_info->extension_id); |
| 545 EXPECT_EQ(file_extension_ids_.size(), file_extensions.size()); | 545 EXPECT_EQ(file_extension_ids_.size(), file_extensions.size()); |
| 546 | 546 |
| 547 for (const auto& extension_id : removed_extensions) | 547 for (const auto& extension_id : removed_extensions) |
| 548 removed_extension_ids_.insert(extension_id); | 548 removed_extension_ids_.insert(extension_id); |
| 549 } | 549 } |
| 550 | 550 |
| 551 size_t GetUpdateURLExtensionCount() { | 551 size_t GetUpdateURLExtensionCount() { |
| 552 return update_url_extension_ids_.size(); | 552 return update_url_extension_ids_.size(); |
| 553 } | 553 } |
| (...skipping 2582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3136 extensions::TestExtensionRegistryObserver observer( | 3136 extensions::TestExtensionRegistryObserver observer( |
| 3137 extensions::ExtensionRegistry::Get(profile()), good0); | 3137 extensions::ExtensionRegistry::Get(profile()), good0); |
| 3138 | 3138 |
| 3139 // Add the extension to the blacklist. | 3139 // Add the extension to the blacklist. |
| 3140 test_blacklist.SetBlacklistState(good0, extensions::BLACKLISTED_MALWARE, | 3140 test_blacklist.SetBlacklistState(good0, extensions::BLACKLISTED_MALWARE, |
| 3141 true); | 3141 true); |
| 3142 observer.WaitForExtensionUnloaded(); | 3142 observer.WaitForExtensionUnloaded(); |
| 3143 | 3143 |
| 3144 // The extension should be disabled, both "blacklist" and "blacklist_state" | 3144 // The extension should be disabled, both "blacklist" and "blacklist_state" |
| 3145 // prefs should be set. | 3145 // prefs should be set. |
| 3146 const auto prefs = ExtensionPrefs::Get(profile()); | 3146 auto* prefs = ExtensionPrefs::Get(profile()); |
| 3147 EXPECT_FALSE(registry()->enabled_extensions().Contains(good0)); | 3147 EXPECT_FALSE(registry()->enabled_extensions().Contains(good0)); |
| 3148 EXPECT_TRUE(prefs->IsExtensionBlacklisted(good0)); | 3148 EXPECT_TRUE(prefs->IsExtensionBlacklisted(good0)); |
| 3149 EXPECT_EQ(extensions::BLACKLISTED_MALWARE, | 3149 EXPECT_EQ(extensions::BLACKLISTED_MALWARE, |
| 3150 prefs->GetExtensionBlacklistState(good0)); | 3150 prefs->GetExtensionBlacklistState(good0)); |
| 3151 | 3151 |
| 3152 // Remove the extension from the blacklist. | 3152 // Remove the extension from the blacklist. |
| 3153 test_blacklist.SetBlacklistState(good0, extensions::NOT_BLACKLISTED, true); | 3153 test_blacklist.SetBlacklistState(good0, extensions::NOT_BLACKLISTED, true); |
| 3154 observer.WaitForExtensionLoaded()->id(); | 3154 observer.WaitForExtensionLoaded()->id(); |
| 3155 | 3155 |
| 3156 // The extension should be enabled, both "blacklist" and "blacklist_state" | 3156 // The extension should be enabled, both "blacklist" and "blacklist_state" |
| (...skipping 3753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6910 | 6910 |
| 6911 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, | 6911 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, |
| 6912 content::Source<Profile>(profile()), | 6912 content::Source<Profile>(profile()), |
| 6913 content::NotificationService::NoDetails()); | 6913 content::NotificationService::NoDetails()); |
| 6914 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); | 6914 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); |
| 6915 EXPECT_EQ(0u, registry()->enabled_extensions().size()); | 6915 EXPECT_EQ(0u, registry()->enabled_extensions().size()); |
| 6916 EXPECT_EQ(0u, registry()->disabled_extensions().size()); | 6916 EXPECT_EQ(0u, registry()->disabled_extensions().size()); |
| 6917 EXPECT_EQ(0u, registry()->terminated_extensions().size()); | 6917 EXPECT_EQ(0u, registry()->terminated_extensions().size()); |
| 6918 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); | 6918 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); |
| 6919 } | 6919 } |
| OLD | NEW |