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 5965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5976 const bool kDontInstallImmediately = false; | 5976 const bool kDontInstallImmediately = false; |
5977 | 5977 |
5978 InitializeEmptyExtensionService(); | 5978 InitializeEmptyExtensionService(); |
5979 | 5979 |
5980 extensions::PendingExtensionManager* pending = | 5980 extensions::PendingExtensionManager* pending = |
5981 service()->pending_extension_manager(); | 5981 service()->pending_extension_manager(); |
5982 EXPECT_FALSE(pending->IsIdPending(kGoodId)); | 5982 EXPECT_FALSE(pending->IsIdPending(kGoodId)); |
5983 | 5983 |
5984 // An external provider starts installing from a local crx. | 5984 // An external provider starts installing from a local crx. |
5985 std::unique_ptr<ExternalInstallInfoFile> info(new ExternalInstallInfoFile( | 5985 std::unique_ptr<ExternalInstallInfoFile> info(new ExternalInstallInfoFile( |
5986 kGoodId, base::WrapUnique(new base::Version(kVersion123)), | 5986 kGoodId, base::MakeUnique<base::Version>(kVersion123), |
5987 kInvalidPathToCrx, Manifest::EXTERNAL_PREF, kCreationFlags, | 5987 kInvalidPathToCrx, Manifest::EXTERNAL_PREF, kCreationFlags, |
5988 kDontMarkAcknowledged, kDontInstallImmediately)); | 5988 kDontMarkAcknowledged, kDontInstallImmediately)); |
5989 EXPECT_TRUE(service()->OnExternalExtensionFileFound(*info)); | 5989 EXPECT_TRUE(service()->OnExternalExtensionFileFound(*info)); |
5990 | 5990 |
5991 const extensions::PendingExtensionInfo* pending_info; | 5991 const extensions::PendingExtensionInfo* pending_info; |
5992 EXPECT_TRUE((pending_info = pending->GetById(kGoodId))); | 5992 EXPECT_TRUE((pending_info = pending->GetById(kGoodId))); |
5993 EXPECT_TRUE(pending_info->version().IsValid()); | 5993 EXPECT_TRUE(pending_info->version().IsValid()); |
5994 EXPECT_EQ(pending_info->version(), kVersion123); | 5994 EXPECT_EQ(pending_info->version(), kVersion123); |
5995 | 5995 |
5996 // Adding a newer version overrides the currently pending version. | 5996 // Adding a newer version overrides the currently pending version. |
(...skipping 15 matching lines...) Expand all Loading... |
6012 info->crx_location = Manifest::EXTERNAL_REGISTRY; | 6012 info->crx_location = Manifest::EXTERNAL_REGISTRY; |
6013 EXPECT_FALSE(service()->OnExternalExtensionFileFound(*info)); | 6013 EXPECT_FALSE(service()->OnExternalExtensionFileFound(*info)); |
6014 EXPECT_TRUE((pending_info = pending->GetById(kGoodId))); | 6014 EXPECT_TRUE((pending_info = pending->GetById(kGoodId))); |
6015 EXPECT_TRUE(pending_info->version().IsValid()); | 6015 EXPECT_TRUE(pending_info->version().IsValid()); |
6016 EXPECT_EQ(pending_info->version(), kVersion124); | 6016 EXPECT_EQ(pending_info->version(), kVersion124); |
6017 | 6017 |
6018 // Adding the latest version from the webstore overrides a specific version. | 6018 // Adding the latest version from the webstore overrides a specific version. |
6019 GURL kUpdateUrl("http://example.com/update"); | 6019 GURL kUpdateUrl("http://example.com/update"); |
6020 std::unique_ptr<ExternalInstallInfoUpdateUrl> update_info( | 6020 std::unique_ptr<ExternalInstallInfoUpdateUrl> update_info( |
6021 new ExternalInstallInfoUpdateUrl( | 6021 new ExternalInstallInfoUpdateUrl( |
6022 kGoodId, std::string(), base::WrapUnique(new GURL(kUpdateUrl)), | 6022 kGoodId, std::string(), base::MakeUnique<GURL>(kUpdateUrl), |
6023 Manifest::EXTERNAL_POLICY_DOWNLOAD, Extension::NO_FLAGS, false)); | 6023 Manifest::EXTERNAL_POLICY_DOWNLOAD, Extension::NO_FLAGS, false)); |
6024 EXPECT_TRUE(service()->OnExternalExtensionUpdateUrlFound(*update_info, true)); | 6024 EXPECT_TRUE(service()->OnExternalExtensionUpdateUrlFound(*update_info, true)); |
6025 EXPECT_TRUE((pending_info = pending->GetById(kGoodId))); | 6025 EXPECT_TRUE((pending_info = pending->GetById(kGoodId))); |
6026 EXPECT_FALSE(pending_info->version().IsValid()); | 6026 EXPECT_FALSE(pending_info->version().IsValid()); |
6027 } | 6027 } |
6028 | 6028 |
6029 // This makes sure we can package and install CRX files that use whitelisted | 6029 // This makes sure we can package and install CRX files that use whitelisted |
6030 // permissions. | 6030 // permissions. |
6031 TEST_F(ExtensionServiceTest, InstallWhitelistedExtension) { | 6031 TEST_F(ExtensionServiceTest, InstallWhitelistedExtension) { |
6032 std::string test_id = "hdkklepkcpckhnpgjnmbdfhehckloojk"; | 6032 std::string test_id = "hdkklepkcpckhnpgjnmbdfhehckloojk"; |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6912 | 6912 |
6913 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, | 6913 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, |
6914 content::Source<Profile>(profile()), | 6914 content::Source<Profile>(profile()), |
6915 content::NotificationService::NoDetails()); | 6915 content::NotificationService::NoDetails()); |
6916 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); | 6916 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); |
6917 EXPECT_EQ(0u, registry()->enabled_extensions().size()); | 6917 EXPECT_EQ(0u, registry()->enabled_extensions().size()); |
6918 EXPECT_EQ(0u, registry()->disabled_extensions().size()); | 6918 EXPECT_EQ(0u, registry()->disabled_extensions().size()); |
6919 EXPECT_EQ(0u, registry()->terminated_extensions().size()); | 6919 EXPECT_EQ(0u, registry()->terminated_extensions().size()); |
6920 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); | 6920 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); |
6921 } | 6921 } |
OLD | NEW |