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

Side by Side Diff: chrome/browser/download/download_browsertest.cc

Issue 2668863002: [Extensions] Remove FeatureSwitch::easy_off_store_install (Closed)
Patch Set: Add TODO for histograms Created 3 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) 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 "chrome/browser/download/download_browsertest.h" 5 #include "chrome/browser/download/download_browsertest.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <sstream> 8 #include <sstream>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 #include "content/public/common/content_features.h" 91 #include "content/public/common/content_features.h"
92 #include "content/public/common/content_switches.h" 92 #include "content/public/common/content_switches.h"
93 #include "content/public/common/context_menu_params.h" 93 #include "content/public/common/context_menu_params.h"
94 #include "content/public/common/quarantine.h" 94 #include "content/public/common/quarantine.h"
95 #include "content/public/test/browser_test_utils.h" 95 #include "content/public/test/browser_test_utils.h"
96 #include "content/public/test/download_test_observer.h" 96 #include "content/public/test/download_test_observer.h"
97 #include "content/public/test/test_file_error_injector.h" 97 #include "content/public/test/test_file_error_injector.h"
98 #include "content/public/test/test_navigation_observer.h" 98 #include "content/public/test/test_navigation_observer.h"
99 #include "extensions/browser/extension_dialog_auto_confirm.h" 99 #include "extensions/browser/extension_dialog_auto_confirm.h"
100 #include "extensions/browser/extension_system.h" 100 #include "extensions/browser/extension_system.h"
101 #include "extensions/common/feature_switch.h"
102 #include "net/base/filename_util.h" 101 #include "net/base/filename_util.h"
103 #include "net/dns/mock_host_resolver.h" 102 #include "net/dns/mock_host_resolver.h"
104 #include "net/test/embedded_test_server/embedded_test_server.h" 103 #include "net/test/embedded_test_server/embedded_test_server.h"
105 #include "net/test/embedded_test_server/http_request.h" 104 #include "net/test/embedded_test_server/http_request.h"
106 #include "net/test/embedded_test_server/http_response.h" 105 #include "net/test/embedded_test_server/http_response.h"
107 #include "net/test/url_request/url_request_mock_http_job.h" 106 #include "net/test/url_request/url_request_mock_http_job.h"
108 #include "net/test/url_request/url_request_slow_download_job.h" 107 #include "net/test/url_request/url_request_slow_download_job.h"
109 #include "testing/gtest/include/gtest/gtest.h" 108 #include "testing/gtest/include/gtest/gtest.h"
110 #include "ui/base/l10n/l10n_util.h" 109 #include "ui/base/l10n/l10n_util.h"
111 #include "ui/base/page_transition_types.h" 110 #include "ui/base/page_transition_types.h"
112 111
113 #if defined(FULL_SAFE_BROWSING) 112 #if defined(FULL_SAFE_BROWSING)
114 #include "chrome/browser/safe_browsing/download_feedback_service.h" 113 #include "chrome/browser/safe_browsing/download_feedback_service.h"
115 #include "chrome/browser/safe_browsing/download_protection_service.h" 114 #include "chrome/browser/safe_browsing/download_protection_service.h"
116 #include "chrome/browser/safe_browsing/test_safe_browsing_service.h" 115 #include "chrome/browser/safe_browsing/test_safe_browsing_service.h"
117 #endif 116 #endif
118 117
119 using content::BrowserContext; 118 using content::BrowserContext;
120 using content::BrowserThread; 119 using content::BrowserThread;
121 using content::DownloadItem; 120 using content::DownloadItem;
122 using content::DownloadManager; 121 using content::DownloadManager;
123 using content::DownloadUrlParameters; 122 using content::DownloadUrlParameters;
124 using content::WebContents; 123 using content::WebContents;
125 using extensions::Extension; 124 using extensions::Extension;
126 using extensions::FeatureSwitch;
127 using net::URLRequestMockHTTPJob; 125 using net::URLRequestMockHTTPJob;
128 126
129 namespace { 127 namespace {
130 128
131 const char kDownloadTest1Path[] = "download-test1.lib"; 129 const char kDownloadTest1Path[] = "download-test1.lib";
132 130
133 class CreatedObserver : public content::DownloadManager::Observer { 131 class CreatedObserver : public content::DownloadManager::Observer {
134 public: 132 public:
135 explicit CreatedObserver(content::DownloadManager* manager) 133 explicit CreatedObserver(content::DownloadManager* manager)
136 : manager_(manager), 134 : manager_(manager),
(...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 EXPECT_TRUE(downloads[0]->GetOpened()); // Confirm it anyway. 2000 EXPECT_TRUE(downloads[0]->GetOpened()); // Confirm it anyway.
2003 2001
2004 // As long as we're here, confirmed everything else is good. 2002 // As long as we're here, confirmed everything else is good.
2005 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 2003 EXPECT_EQ(1, browser()->tab_strip_model()->count());
2006 CheckDownload(browser(), file, file); 2004 CheckDownload(browser(), file, file);
2007 } 2005 }
2008 2006
2009 // Download an extension. Expect a dangerous download warning. 2007 // Download an extension. Expect a dangerous download warning.
2010 // Deny the download. 2008 // Deny the download.
2011 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxDenyInstall) { 2009 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxDenyInstall) {
2012 FeatureSwitch::ScopedOverride enable_easy_off_store_install( 2010 std::unique_ptr<base::AutoReset<bool>> allow_offstore_install =
2013 FeatureSwitch::easy_off_store_install(), true); 2011 download_crx_util::OverrideOffstoreInstallAllowedForTesting(true);
2014 2012
2015 GURL extension_url(URLRequestMockHTTPJob::GetMockUrl(kGoodCrxPath)); 2013 GURL extension_url(URLRequestMockHTTPJob::GetMockUrl(kGoodCrxPath));
2016 2014
2017 std::unique_ptr<content::DownloadTestObserver> observer( 2015 std::unique_ptr<content::DownloadTestObserver> observer(
2018 DangerousDownloadWaiter( 2016 DangerousDownloadWaiter(
2019 browser(), 1, 2017 browser(), 1,
2020 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); 2018 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY));
2021 ui_test_utils::NavigateToURL(browser(), extension_url); 2019 ui_test_utils::NavigateToURL(browser(), extension_url);
2022 2020
2023 observer->WaitForFinished(); 2021 observer->WaitForFinished();
2024 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::CANCELLED)); 2022 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::CANCELLED));
2025 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); 2023 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen());
2026 EXPECT_TRUE(VerifyNoDownloads()); 2024 EXPECT_TRUE(VerifyNoDownloads());
2027 2025
2028 // Check that the CRX is not installed. 2026 // Check that the CRX is not installed.
2029 ExtensionService* extension_service = extensions::ExtensionSystem::Get( 2027 ExtensionService* extension_service = extensions::ExtensionSystem::Get(
2030 browser()->profile())->extension_service(); 2028 browser()->profile())->extension_service();
2031 ASSERT_FALSE(extension_service->GetExtensionById(kGoodCrxId, false)); 2029 ASSERT_FALSE(extension_service->GetExtensionById(kGoodCrxId, false));
2032 } 2030 }
2033 2031
2034 // Download an extension. Expect a dangerous download warning. 2032 // Download an extension. Expect a dangerous download warning.
2035 // Allow the download, deny the install. 2033 // Allow the download, deny the install.
2036 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInstallDenysPermissions) { 2034 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInstallDenysPermissions) {
2037 FeatureSwitch::ScopedOverride enable_easy_off_store_install( 2035 std::unique_ptr<base::AutoReset<bool>> allow_offstore_install =
2038 FeatureSwitch::easy_off_store_install(), true); 2036 download_crx_util::OverrideOffstoreInstallAllowedForTesting(true);
2039 extensions::ScopedTestDialogAutoConfirm auto_confirm_install_prompt( 2037 extensions::ScopedTestDialogAutoConfirm auto_confirm_install_prompt(
2040 extensions::ScopedTestDialogAutoConfirm::CANCEL); 2038 extensions::ScopedTestDialogAutoConfirm::CANCEL);
2041 2039
2042 GURL extension_url(URLRequestMockHTTPJob::GetMockUrl(kGoodCrxPath)); 2040 GURL extension_url(URLRequestMockHTTPJob::GetMockUrl(kGoodCrxPath));
2043 2041
2044 std::unique_ptr<content::DownloadTestObserver> observer( 2042 std::unique_ptr<content::DownloadTestObserver> observer(
2045 DangerousDownloadWaiter( 2043 DangerousDownloadWaiter(
2046 browser(), 1, 2044 browser(), 1,
2047 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT)); 2045 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT));
2048 ui_test_utils::NavigateToURL(browser(), extension_url); 2046 ui_test_utils::NavigateToURL(browser(), extension_url);
(...skipping 11 matching lines...) Expand all
2060 2058
2061 // Check that the extension was not installed. 2059 // Check that the extension was not installed.
2062 ExtensionService* extension_service = extensions::ExtensionSystem::Get( 2060 ExtensionService* extension_service = extensions::ExtensionSystem::Get(
2063 browser()->profile())->extension_service(); 2061 browser()->profile())->extension_service();
2064 ASSERT_FALSE(extension_service->GetExtensionById(kGoodCrxId, false)); 2062 ASSERT_FALSE(extension_service->GetExtensionById(kGoodCrxId, false));
2065 } 2063 }
2066 2064
2067 // Download an extension. Expect a dangerous download warning. 2065 // Download an extension. Expect a dangerous download warning.
2068 // Allow the download, and the install. 2066 // Allow the download, and the install.
2069 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInstallAcceptPermissions) { 2067 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInstallAcceptPermissions) {
2070 FeatureSwitch::ScopedOverride enable_easy_off_store_install( 2068 std::unique_ptr<base::AutoReset<bool>> allow_offstore_install =
2071 FeatureSwitch::easy_off_store_install(), true); 2069 download_crx_util::OverrideOffstoreInstallAllowedForTesting(true);
2072 2070
2073 GURL extension_url(URLRequestMockHTTPJob::GetMockUrl(kGoodCrxPath)); 2071 GURL extension_url(URLRequestMockHTTPJob::GetMockUrl(kGoodCrxPath));
2074 2072
2075 // Simulate the user allowing permission to finish the install. 2073 // Simulate the user allowing permission to finish the install.
2076 extensions::ScopedTestDialogAutoConfirm auto_confirm_install_prompt( 2074 extensions::ScopedTestDialogAutoConfirm auto_confirm_install_prompt(
2077 extensions::ScopedTestDialogAutoConfirm::ACCEPT); 2075 extensions::ScopedTestDialogAutoConfirm::ACCEPT);
2078 2076
2079 std::unique_ptr<content::DownloadTestObserver> observer( 2077 std::unique_ptr<content::DownloadTestObserver> observer(
2080 DangerousDownloadWaiter( 2078 DangerousDownloadWaiter(
2081 browser(), 1, 2079 browser(), 1,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2120 CheckDownloadStates(1, DownloadItem::COMPLETE); 2118 CheckDownloadStates(1, DownloadItem::COMPLETE);
2121 2119
2122 // Check that the extension was not installed. 2120 // Check that the extension was not installed.
2123 ExtensionService* extension_service = extensions::ExtensionSystem::Get( 2121 ExtensionService* extension_service = extensions::ExtensionSystem::Get(
2124 browser()->profile())->extension_service(); 2122 browser()->profile())->extension_service();
2125 ASSERT_FALSE(extension_service->GetExtensionById(kGoodCrxId, false)); 2123 ASSERT_FALSE(extension_service->GetExtensionById(kGoodCrxId, false));
2126 } 2124 }
2127 2125
2128 // Install a large (100kb) theme. 2126 // Install a large (100kb) theme.
2129 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxLargeTheme) { 2127 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxLargeTheme) {
2130 FeatureSwitch::ScopedOverride enable_easy_off_store_install( 2128 std::unique_ptr<base::AutoReset<bool>> allow_offstore_install =
2131 FeatureSwitch::easy_off_store_install(), true); 2129 download_crx_util::OverrideOffstoreInstallAllowedForTesting(true);
2132 2130
2133 GURL extension_url(URLRequestMockHTTPJob::GetMockUrl(kLargeThemePath)); 2131 GURL extension_url(URLRequestMockHTTPJob::GetMockUrl(kLargeThemePath));
2134 2132
2135 // Simulate the user allowing permission to finish the install. 2133 // Simulate the user allowing permission to finish the install.
2136 extensions::ScopedTestDialogAutoConfirm auto_confirm_install_prompt( 2134 extensions::ScopedTestDialogAutoConfirm auto_confirm_install_prompt(
2137 extensions::ScopedTestDialogAutoConfirm::ACCEPT); 2135 extensions::ScopedTestDialogAutoConfirm::ACCEPT);
2138 2136
2139 std::unique_ptr<content::DownloadTestObserver> observer( 2137 std::unique_ptr<content::DownloadTestObserver> observer(
2140 DangerousDownloadWaiter( 2138 DangerousDownloadWaiter(
2141 browser(), 1, 2139 browser(), 1,
(...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after
3783 ASSERT_TRUE( 3781 ASSERT_TRUE(
3784 GetDownloadPrefs(browser())->EnableAutoOpenBasedOnExtension(file)); 3782 GetDownloadPrefs(browser())->EnableAutoOpenBasedOnExtension(file));
3785 3783
3786 DownloadAndWait(browser(), url); 3784 DownloadAndWait(browser(), url);
3787 3785
3788 // Download shelf should close. 3786 // Download shelf should close.
3789 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); 3787 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
3790 } 3788 }
3791 3789
3792 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxDenyInstallClosesShelf) { 3790 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxDenyInstallClosesShelf) {
3793 FeatureSwitch::ScopedOverride enable_easy_off_store_install( 3791 std::unique_ptr<base::AutoReset<bool>> allow_offstore_install =
3794 FeatureSwitch::easy_off_store_install(), true); 3792 download_crx_util::OverrideOffstoreInstallAllowedForTesting(true);
3795 3793
3796 GURL extension_url(URLRequestMockHTTPJob::GetMockUrl(kGoodCrxPath)); 3794 GURL extension_url(URLRequestMockHTTPJob::GetMockUrl(kGoodCrxPath));
3797 3795
3798 std::unique_ptr<content::DownloadTestObserver> observer( 3796 std::unique_ptr<content::DownloadTestObserver> observer(
3799 DangerousDownloadWaiter( 3797 DangerousDownloadWaiter(
3800 browser(), 1, 3798 browser(), 1,
3801 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); 3799 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY));
3802 ui_test_utils::NavigateToURL(browser(), extension_url); 3800 ui_test_utils::NavigateToURL(browser(), extension_url);
3803 3801
3804 observer->WaitForFinished(); 3802 observer->WaitForFinished();
3805 3803
3806 // Download shelf should close. 3804 // Download shelf should close.
3807 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); 3805 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
3808 } 3806 }
3809 #endif // defined(OS_CHROMEOS) 3807 #endif // defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/download/download_crx_util.h » ('j') | chrome/browser/extensions/crx_installer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698