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

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

Issue 829583002: Validate hash_sha256 checksum on .crx update. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix histogram value. Created 5 years, 10 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
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 <algorithm> 5 #include <algorithm>
6 #include <set> 6 #include <set>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 int previous_enabled_extension_count = 819 int previous_enabled_extension_count =
820 registry()->enabled_extensions().size(); 820 registry()->enabled_extensions().size();
821 int previous_installed_extension_count = 821 int previous_installed_extension_count =
822 previous_enabled_extension_count + 822 previous_enabled_extension_count +
823 registry()->disabled_extensions().size(); 823 registry()->disabled_extensions().size();
824 824
825 extensions::CrxInstaller* installer = NULL; 825 extensions::CrxInstaller* installer = NULL;
826 content::WindowedNotificationObserver observer( 826 content::WindowedNotificationObserver observer(
827 extensions::NOTIFICATION_CRX_INSTALLER_DONE, 827 extensions::NOTIFICATION_CRX_INSTALLER_DONE,
828 base::Bind(&IsCrxInstallerDone, &installer)); 828 base::Bind(&IsCrxInstallerDone, &installer));
829 service()->UpdateExtension(id, path, true, &installer); 829 service()->UpdateExtension(extensions::CRXFileInfo(id, path), true,
830 &installer);
830 831
831 if (installer) 832 if (installer)
832 observer.Wait(); 833 observer.Wait();
833 else 834 else
834 base::RunLoop().RunUntilIdle(); 835 base::RunLoop().RunUntilIdle();
835 836
836 std::vector<base::string16> errors = GetErrors(); 837 std::vector<base::string16> errors = GetErrors();
837 int error_count = errors.size(); 838 int error_count = errors.size();
838 int enabled_extension_count = registry()->enabled_extensions().size(); 839 int enabled_extension_count = registry()->enabled_extensions().size();
839 int installed_extension_count = 840 int installed_extension_count =
(...skipping 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after
2710 // Install an extension. 2711 // Install an extension.
2711 base::FilePath path = data_dir().AppendASCII("good.crx"); 2712 base::FilePath path = data_dir().AppendASCII("good.crx");
2712 const Extension* good = InstallCRX(path, INSTALL_NEW); 2713 const Extension* good = InstallCRX(path, INSTALL_NEW);
2713 ASSERT_EQ(good_crx, good->id()); 2714 ASSERT_EQ(good_crx, good->id());
2714 2715
2715 // Simulate shutdown. 2716 // Simulate shutdown.
2716 service()->set_browser_terminating_for_test(true); 2717 service()->set_browser_terminating_for_test(true);
2717 2718
2718 // Update should fail and extension should not be updated. 2719 // Update should fail and extension should not be updated.
2719 path = data_dir().AppendASCII("good2.crx"); 2720 path = data_dir().AppendASCII("good2.crx");
2720 bool updated = service()->UpdateExtension(good_crx, path, true, NULL); 2721 bool updated = service()->UpdateExtension(
2722 extensions::CRXFileInfo(good_crx, path), true, NULL);
2721 ASSERT_FALSE(updated); 2723 ASSERT_FALSE(updated);
2722 ASSERT_EQ( 2724 ASSERT_EQ(
2723 "1.0.0.0", 2725 "1.0.0.0",
2724 service()->GetExtensionById(good_crx, false)->version()->GetString()); 2726 service()->GetExtensionById(good_crx, false)->version()->GetString());
2725 } 2727 }
2726 2728
2727 // Test updating a not-already-installed extension - this should fail 2729 // Test updating a not-already-installed extension - this should fail
2728 TEST_F(ExtensionServiceTest, UpdateNotInstalledExtension) { 2730 TEST_F(ExtensionServiceTest, UpdateNotInstalledExtension) {
2729 InitializeEmptyExtensionService(); 2731 InitializeEmptyExtensionService();
2730 2732
(...skipping 4025 matching lines...) Expand 10 before | Expand all | Expand 10 after
6756 6758
6757 EXPECT_FALSE(pending->IsIdPending(kGoodId)); 6759 EXPECT_FALSE(pending->IsIdPending(kGoodId));
6758 } 6760 }
6759 6761
6760 TEST_F(ExtensionServiceTest, InstallPriorityExternalLocalFile) { 6762 TEST_F(ExtensionServiceTest, InstallPriorityExternalLocalFile) {
6761 Version older_version("0.1.0.0"); 6763 Version older_version("0.1.0.0");
6762 Version newer_version("2.0.0.0"); 6764 Version newer_version("2.0.0.0");
6763 6765
6764 // We don't want the extension to be installed. A path that doesn't 6766 // We don't want the extension to be installed. A path that doesn't
6765 // point to a valid CRX ensures this. 6767 // point to a valid CRX ensures this.
6766 const base::FilePath kInvalidPathToCrx = base::FilePath(); 6768 const base::FilePath kInvalidPathToCrx = base::FilePath("invalid_path");
6767 6769
6768 const int kCreationFlags = 0; 6770 const int kCreationFlags = 0;
6769 const bool kDontMarkAcknowledged = false; 6771 const bool kDontMarkAcknowledged = false;
6770 6772
6771 InitializeEmptyExtensionService(); 6773 InitializeEmptyExtensionService();
6772 6774
6773 // The test below uses install source constants to test that 6775 // The test below uses install source constants to test that
6774 // priority is enforced. It assumes a specific ranking of install 6776 // priority is enforced. It assumes a specific ranking of install
6775 // sources: Registry (EXTERNAL_REGISTRY) overrides external pref 6777 // sources: Registry (EXTERNAL_REGISTRY) overrides external pref
6776 // (EXTERNAL_PREF), and external pref overrides user install (INTERNAL). 6778 // (EXTERNAL_PREF), and external pref overrides user install (INTERNAL).
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
6960 Manifest::EXTERNAL_PREF, 6962 Manifest::EXTERNAL_PREF,
6961 kCreationFlags, 6963 kCreationFlags,
6962 kDontMarkAcknowledged)); 6964 kDontMarkAcknowledged));
6963 EXPECT_TRUE(pending->IsIdPending(kGoodId)); 6965 EXPECT_TRUE(pending->IsIdPending(kGoodId));
6964 } 6966 }
6965 6967
6966 TEST_F(ExtensionServiceTest, ConcurrentExternalLocalFile) { 6968 TEST_F(ExtensionServiceTest, ConcurrentExternalLocalFile) {
6967 Version kVersion123("1.2.3"); 6969 Version kVersion123("1.2.3");
6968 Version kVersion124("1.2.4"); 6970 Version kVersion124("1.2.4");
6969 Version kVersion125("1.2.5"); 6971 Version kVersion125("1.2.5");
6970 const base::FilePath kInvalidPathToCrx = base::FilePath(); 6972 const base::FilePath kInvalidPathToCrx = base::FilePath("invalid_path");
6971 const int kCreationFlags = 0; 6973 const int kCreationFlags = 0;
6972 const bool kDontMarkAcknowledged = false; 6974 const bool kDontMarkAcknowledged = false;
6973 6975
6974 InitializeEmptyExtensionService(); 6976 InitializeEmptyExtensionService();
6975 6977
6976 extensions::PendingExtensionManager* pending = 6978 extensions::PendingExtensionManager* pending =
6977 service()->pending_extension_manager(); 6979 service()->pending_extension_manager();
6978 EXPECT_FALSE(pending->IsIdPending(kGoodId)); 6980 EXPECT_FALSE(pending->IsIdPending(kGoodId));
6979 6981
6980 // An external provider starts installing from a local crx. 6982 // An external provider starts installing from a local crx.
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
7574 7576
7575 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, 7577 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED,
7576 content::Source<Profile>(profile()), 7578 content::Source<Profile>(profile()),
7577 content::NotificationService::NoDetails()); 7579 content::NotificationService::NoDetails());
7578 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); 7580 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_);
7579 EXPECT_EQ(0u, registry()->enabled_extensions().size()); 7581 EXPECT_EQ(0u, registry()->enabled_extensions().size());
7580 EXPECT_EQ(0u, registry()->disabled_extensions().size()); 7582 EXPECT_EQ(0u, registry()->disabled_extensions().size());
7581 EXPECT_EQ(0u, registry()->terminated_extensions().size()); 7583 EXPECT_EQ(0u, registry()->terminated_extensions().size());
7582 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); 7584 EXPECT_EQ(0u, registry()->blacklisted_extensions().size());
7583 } 7585 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698