| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
| 6 #include "chrome/browser/download/download_crx_util.h" | 6 #include "chrome/browser/download/download_crx_util.h" |
| 7 #include "chrome/browser/extensions/crx_installer.h" | 7 #include "chrome/browser/extensions/crx_installer.h" |
| 8 #include "chrome/browser/extensions/extension_browsertest.h" | 8 #include "chrome/browser/extensions/extension_browsertest.h" |
| 9 #include "chrome/browser/extensions/extension_install_prompt.h" | 9 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/extensions/extension_system.h" | 11 #include "chrome/browser/extensions/extension_system.h" |
| 12 #include "chrome/browser/extensions/fake_safe_browsing_database_manager.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
| 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 16 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
| 17 #include "chrome/common/extensions/extension_file_util.h" | 18 #include "chrome/common/extensions/extension_file_util.h" |
| 18 #include "chrome/common/extensions/feature_switch.h" | 19 #include "chrome/common/extensions/feature_switch.h" |
| 19 #include "chrome/common/extensions/permissions/permission_set.h" | 20 #include "chrome/common/extensions/permissions/permission_set.h" |
| 20 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
| 21 #include "content/public/browser/download_manager.h" | 22 #include "content/public/browser/download_manager.h" |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 | 441 |
| 441 // The version 2 delayed install should be cleaned up, and finishing | 442 // The version 2 delayed install should be cleaned up, and finishing |
| 442 // delayed extension installation shouldn't break anything. | 443 // delayed extension installation shouldn't break anything. |
| 443 ASSERT_EQ(0u, service->delayed_installs()->size()); | 444 ASSERT_EQ(0u, service->delayed_installs()->size()); |
| 444 service->MaybeFinishDelayedInstallations(); | 445 service->MaybeFinishDelayedInstallations(); |
| 445 extension = service->GetExtensionById(extension_id, false); | 446 extension = service->GetExtensionById(extension_id, false); |
| 446 ASSERT_EQ("3.0", extension->version()->GetString()); | 447 ASSERT_EQ("3.0", extension->version()->GetString()); |
| 447 } | 448 } |
| 448 | 449 |
| 449 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, Blacklist) { | 450 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, Blacklist) { |
| 450 extensions::Blacklist* blacklist = | 451 scoped_refptr<FakeSafeBrowsingDatabaseManager> blacklist_db( |
| 451 ExtensionSystem::Get(profile())->blacklist(); | 452 new FakeSafeBrowsingDatabaseManager(true)); |
| 453 Blacklist::ScopedDatabaseManagerForTest scoped_blacklist_db(blacklist_db); |
| 452 | 454 |
| 453 // Fake the blacklisting of the extension we're about to install by | 455 blacklist_db->SetUnsafe("gllekhaobjnhgeagipipnkpmmmpchacm"); |
| 454 // pretending that we get a blacklist update which includes it. | |
| 455 const std::string kId = "gllekhaobjnhgeagipipnkpmmmpchacm"; | |
| 456 blacklist->SetFromUpdater(std::vector<std::string>(1, kId), "some-version"); | |
| 457 | 456 |
| 458 base::FilePath crx_path = test_data_dir_.AppendASCII("theme_hidpi_crx") | 457 base::FilePath crx_path = test_data_dir_.AppendASCII("theme_hidpi_crx") |
| 459 .AppendASCII("theme_hidpi.crx"); | 458 .AppendASCII("theme_hidpi.crx"); |
| 460 EXPECT_FALSE(InstallExtension(crx_path, 0)); | 459 EXPECT_FALSE(InstallExtension(crx_path, 0)); |
| 461 } | 460 } |
| 462 | 461 |
| 463 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, NonStrictManifestCheck) { | 462 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, NonStrictManifestCheck) { |
| 464 scoped_refptr<MockPromptProxy> mock_prompt = | 463 scoped_refptr<MockPromptProxy> mock_prompt = |
| 465 CreateMockPromptProxyForBrowser(browser()); | 464 CreateMockPromptProxyForBrowser(browser()); |
| 466 | 465 |
| 467 // We want to simulate the case where the webstore sends a more recent | 466 // We want to simulate the case where the webstore sends a more recent |
| 468 // version of the manifest, but the downloaded .crx file is old since | 467 // version of the manifest, but the downloaded .crx file is old since |
| 469 // the newly published version hasn't fully propagated to all the download | 468 // the newly published version hasn't fully propagated to all the download |
| 470 // servers yet. So load the v2 manifest, but then install the v1 crx file. | 469 // servers yet. So load the v2 manifest, but then install the v1 crx file. |
| 471 std::string id = "lhnaeclnpobnlbjbgogdanmhadigfnjp"; | 470 std::string id = "lhnaeclnpobnlbjbgogdanmhadigfnjp"; |
| 472 scoped_ptr<WebstoreInstaller::Approval> approval = | 471 scoped_ptr<WebstoreInstaller::Approval> approval = |
| 473 GetApproval("crx_installer/v2_no_permission_change/", id, false); | 472 GetApproval("crx_installer/v2_no_permission_change/", id, false); |
| 474 | 473 |
| 475 RunCrxInstaller(approval.get(), mock_prompt->CreatePrompt(), | 474 RunCrxInstaller(approval.get(), mock_prompt->CreatePrompt(), |
| 476 test_data_dir_.AppendASCII("crx_installer/v1.crx")); | 475 test_data_dir_.AppendASCII("crx_installer/v1.crx")); |
| 477 | 476 |
| 478 EXPECT_TRUE(mock_prompt->did_succeed()); | 477 EXPECT_TRUE(mock_prompt->did_succeed()); |
| 479 } | 478 } |
| 480 | 479 |
| 481 } // namespace extensions | 480 } // namespace extensions |
| OLD | NEW |