| 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 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 installed_(NULL), | 671 installed_(NULL), |
| 672 was_update_(false), | 672 was_update_(false), |
| 673 override_external_install_prompt_( | 673 override_external_install_prompt_( |
| 674 FeatureSwitch::prompt_for_external_extensions(), | 674 FeatureSwitch::prompt_for_external_extensions(), |
| 675 false) { | 675 false) { |
| 676 registrar_.Add(this, | 676 registrar_.Add(this, |
| 677 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, | 677 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 678 content::NotificationService::AllSources()); | 678 content::NotificationService::AllSources()); |
| 679 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 679 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
| 680 content::NotificationService::AllSources()); | 680 content::NotificationService::AllSources()); |
| 681 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, | 681 registrar_.Add(this, |
| 682 chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED, |
| 682 content::NotificationService::AllSources()); | 683 content::NotificationService::AllSources()); |
| 683 } | 684 } |
| 684 | 685 |
| 685 virtual void Observe(int type, | 686 virtual void Observe(int type, |
| 686 const content::NotificationSource& source, | 687 const content::NotificationSource& source, |
| 687 const content::NotificationDetails& details) OVERRIDE { | 688 const content::NotificationDetails& details) OVERRIDE { |
| 688 switch (type) { | 689 switch (type) { |
| 689 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: { | 690 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: { |
| 690 const Extension* extension = | 691 const Extension* extension = |
| 691 content::Details<const Extension>(details).ptr(); | 692 content::Details<const Extension>(details).ptr(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 704 unloaded_reason_ = unloaded_info->reason; | 705 unloaded_reason_ = unloaded_info->reason; |
| 705 extensions::ExtensionList::iterator i = | 706 extensions::ExtensionList::iterator i = |
| 706 std::find(loaded_.begin(), loaded_.end(), e); | 707 std::find(loaded_.begin(), loaded_.end(), e); |
| 707 // TODO(erikkay) fix so this can be an assert. Right now the tests | 708 // TODO(erikkay) fix so this can be an assert. Right now the tests |
| 708 // are manually calling clear() on loaded_, so this isn't doable. | 709 // are manually calling clear() on loaded_, so this isn't doable. |
| 709 if (i == loaded_.end()) | 710 if (i == loaded_.end()) |
| 710 return; | 711 return; |
| 711 loaded_.erase(i); | 712 loaded_.erase(i); |
| 712 break; | 713 break; |
| 713 } | 714 } |
| 714 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { | 715 case chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED: { |
| 715 const extensions::InstalledExtensionInfo* installed_info = | 716 const extensions::InstalledExtensionInfo* installed_info = |
| 716 content::Details<const extensions::InstalledExtensionInfo>(details) | 717 content::Details<const extensions::InstalledExtensionInfo>(details) |
| 717 .ptr(); | 718 .ptr(); |
| 718 installed_ = installed_info->extension; | 719 installed_ = installed_info->extension; |
| 719 was_update_ = installed_info->is_update; | 720 was_update_ = installed_info->is_update; |
| 720 old_name_ = installed_info->old_name; | 721 old_name_ = installed_info->old_name; |
| 721 break; | 722 break; |
| 722 } | 723 } |
| 723 | 724 |
| 724 default: | 725 default: |
| (...skipping 6158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6883 extension.get(), | 6884 extension.get(), |
| 6884 syncer::StringOrdinal(), | 6885 syncer::StringOrdinal(), |
| 6885 false /* has requirement errors */, | 6886 false /* has requirement errors */, |
| 6886 extensions::BLACKLISTED_MALWARE, | 6887 extensions::BLACKLISTED_MALWARE, |
| 6887 false /* is ephemeral */, | 6888 false /* is ephemeral */, |
| 6888 false /* wait for idle */); | 6889 false /* wait for idle */); |
| 6889 base::RunLoop().RunUntilIdle(); | 6890 base::RunLoop().RunUntilIdle(); |
| 6890 | 6891 |
| 6891 // Extension was installed but not loaded. | 6892 // Extension was installed but not loaded. |
| 6892 EXPECT_TRUE(notifications.CheckNotifications( | 6893 EXPECT_TRUE(notifications.CheckNotifications( |
| 6893 chrome::NOTIFICATION_EXTENSION_INSTALLED)); | 6894 chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED)); |
| 6894 EXPECT_TRUE(service_->GetInstalledExtension(id)); | 6895 EXPECT_TRUE(service_->GetInstalledExtension(id)); |
| 6895 | 6896 |
| 6896 EXPECT_FALSE(registry_->enabled_extensions().Contains(id)); | 6897 EXPECT_FALSE(registry_->enabled_extensions().Contains(id)); |
| 6897 EXPECT_TRUE(registry_->blacklisted_extensions().Contains(id)); | 6898 EXPECT_TRUE(registry_->blacklisted_extensions().Contains(id)); |
| 6898 | 6899 |
| 6899 EXPECT_TRUE(ExtensionPrefs::Get(profile_.get())->IsExtensionBlacklisted(id)); | 6900 EXPECT_TRUE(ExtensionPrefs::Get(profile_.get())->IsExtensionBlacklisted(id)); |
| 6900 EXPECT_TRUE(ExtensionPrefs::Get(profile_.get()) | 6901 EXPECT_TRUE(ExtensionPrefs::Get(profile_.get()) |
| 6901 ->IsBlacklistedExtensionAcknowledged(id)); | 6902 ->IsBlacklistedExtensionAcknowledged(id)); |
| 6902 } | 6903 } |
| 6903 | 6904 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6977 | 6978 |
| 6978 service_->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, | 6979 service_->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, |
| 6979 content::Source<Profile>(profile_.get()), | 6980 content::Source<Profile>(profile_.get()), |
| 6980 content::NotificationService::NoDetails()); | 6981 content::NotificationService::NoDetails()); |
| 6981 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); | 6982 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); |
| 6982 EXPECT_EQ(0u, registry_->enabled_extensions().size()); | 6983 EXPECT_EQ(0u, registry_->enabled_extensions().size()); |
| 6983 EXPECT_EQ(0u, registry_->disabled_extensions().size()); | 6984 EXPECT_EQ(0u, registry_->disabled_extensions().size()); |
| 6984 EXPECT_EQ(0u, registry_->terminated_extensions().size()); | 6985 EXPECT_EQ(0u, registry_->terminated_extensions().size()); |
| 6985 EXPECT_EQ(0u, registry_->blacklisted_extensions().size()); | 6986 EXPECT_EQ(0u, registry_->blacklisted_extensions().size()); |
| 6986 } | 6987 } |
| OLD | NEW |