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

Side by Side Diff: chrome/browser/plugins/flash_download_interception_unittest.cc

Issue 2340123002: [HBD] Only use Flash Download interception for DETECT content setting. (Closed)
Patch Set: update owners file Created 4 years, 3 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
« no previous file with comments | « chrome/browser/plugins/flash_download_interception.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/plugins/flash_download_interception.h" 5 #include "chrome/browser/plugins/flash_download_interception.h"
6 6
7 #include "base/test/scoped_feature_list.h" 7 #include "base/test/scoped_feature_list.h"
8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
8 #include "chrome/common/chrome_features.h" 9 #include "chrome/common/chrome_features.h"
9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
11 #include "chrome/test/base/testing_profile.h"
12 #include "components/content_settings/core/browser/host_content_settings_map.h"
10 #include "content/public/browser/navigation_handle.h" 13 #include "content/public/browser/navigation_handle.h"
11 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
12 #include "url/gurl.h" 15 #include "url/gurl.h"
13 16
14 using content::NavigationHandle; 17 using content::NavigationHandle;
15 using content::NavigationThrottle; 18 using content::NavigationThrottle;
16 19
17 class FlashDownloadInterceptionTest : public ChromeRenderViewHostTestHarness { 20 class FlashDownloadInterceptionTest : public ChromeRenderViewHostTestHarness {
18 public: 21 public:
19 FlashDownloadInterceptionTest() {} 22 FlashDownloadInterceptionTest() {}
(...skipping 19 matching lines...) Expand all
39 feature_list.InitAndDisableFeature(features::kPreferHtmlOverPlugins); 42 feature_list.InitAndDisableFeature(features::kPreferHtmlOverPlugins);
40 43
41 flash_navigation_handle_->CallWillStartRequestForTesting( 44 flash_navigation_handle_->CallWillStartRequestForTesting(
42 true, content::Referrer(), true, ui::PAGE_TRANSITION_LINK, false); 45 true, content::Referrer(), true, ui::PAGE_TRANSITION_LINK, false);
43 std::unique_ptr<NavigationThrottle> throttle = 46 std::unique_ptr<NavigationThrottle> throttle =
44 FlashDownloadInterception::MaybeCreateThrottleFor( 47 FlashDownloadInterception::MaybeCreateThrottleFor(
45 flash_navigation_handle_.get()); 48 flash_navigation_handle_.get());
46 EXPECT_EQ(nullptr, throttle); 49 EXPECT_EQ(nullptr, throttle);
47 } 50 }
48 51
49 TEST_F(FlashDownloadInterceptionTest, PreferHtmlOverPluginsOn) { 52 TEST_F(FlashDownloadInterceptionTest, DownloadUrlVariations) {
50 std::unique_ptr<NavigationThrottle> throttle; 53 std::unique_ptr<NavigationThrottle> throttle;
51 std::unique_ptr<NavigationHandle> flash_slash_navigation_handle = 54 std::unique_ptr<NavigationHandle> flash_slash_navigation_handle =
52 NavigationHandle::CreateNavigationHandleForTesting( 55 NavigationHandle::CreateNavigationHandleForTesting(
53 GURL("https://get.adobe.com/flashplayer/"), main_rfh()); 56 GURL("https://get.adobe.com/flashplayer/"), main_rfh());
54 std::unique_ptr<NavigationHandle> example_navigation_handle = 57 std::unique_ptr<NavigationHandle> example_navigation_handle =
55 NavigationHandle::CreateNavigationHandleForTesting( 58 NavigationHandle::CreateNavigationHandleForTesting(
56 GURL("https://www.example.com"), main_rfh()); 59 GURL("https://www.example.com"), main_rfh());
57 std::unique_ptr<NavigationHandle> flash_http_navigation_handle = 60 std::unique_ptr<NavigationHandle> flash_http_navigation_handle =
58 NavigationHandle::CreateNavigationHandleForTesting( 61 NavigationHandle::CreateNavigationHandleForTesting(
59 GURL("http://get.adobe.com/flashplayer"), main_rfh()); 62 GURL("http://get.adobe.com/flashplayer"), main_rfh());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 EXPECT_NE(nullptr, throttle); 102 EXPECT_NE(nullptr, throttle);
100 ASSERT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, 103 ASSERT_EQ(NavigationThrottle::CANCEL_AND_IGNORE,
101 throttle->WillStartRequest()); 104 throttle->WillStartRequest());
102 105
103 example_flash_navigation_handle->CallWillStartRequestForTesting( 106 example_flash_navigation_handle->CallWillStartRequestForTesting(
104 true, content::Referrer(), true, ui::PAGE_TRANSITION_LINK, false); 107 true, content::Referrer(), true, ui::PAGE_TRANSITION_LINK, false);
105 throttle = FlashDownloadInterception::MaybeCreateThrottleFor( 108 throttle = FlashDownloadInterception::MaybeCreateThrottleFor(
106 example_flash_navigation_handle.get()); 109 example_flash_navigation_handle.get());
107 EXPECT_EQ(nullptr, throttle); 110 EXPECT_EQ(nullptr, throttle);
108 } 111 }
112
113 TEST_F(FlashDownloadInterceptionTest, OnlyInterceptOnDetectContentSetting) {
114 base::test::ScopedFeatureList feature_list;
115 feature_list.InitAndEnableFeature(features::kPreferHtmlOverPlugins);
116
117 flash_navigation_handle_->CallWillStartRequestForTesting(
118 true, content::Referrer(), true, ui::PAGE_TRANSITION_LINK, false);
119
120 // Default Setting (which is DETECT)
121 std::unique_ptr<NavigationThrottle> throttle =
122 FlashDownloadInterception::MaybeCreateThrottleFor(
123 flash_navigation_handle_.get());
124 EXPECT_NE(nullptr, throttle);
125 ASSERT_EQ(NavigationThrottle::CANCEL_AND_IGNORE,
126 throttle->WillStartRequest());
127
128 // ALLOW and BLOCK Settings
129 HostContentSettingsMap* map =
130 HostContentSettingsMapFactory::GetForProfile(profile());
131 map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS,
132 CONTENT_SETTING_ALLOW);
133 EXPECT_EQ(nullptr, FlashDownloadInterception::MaybeCreateThrottleFor(
134 flash_navigation_handle_.get()));
135 map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS,
136 CONTENT_SETTING_BLOCK);
137 EXPECT_EQ(nullptr, FlashDownloadInterception::MaybeCreateThrottleFor(
138 flash_navigation_handle_.get()));
139
140 // Explicit DETECT
141 map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS,
142 CONTENT_SETTING_DETECT_IMPORTANT_CONTENT);
143 throttle = FlashDownloadInterception::MaybeCreateThrottleFor(
144 flash_navigation_handle_.get());
145 EXPECT_NE(nullptr, throttle);
146 ASSERT_EQ(NavigationThrottle::CANCEL_AND_IGNORE,
147 throttle->WillStartRequest());
148 }
OLDNEW
« no previous file with comments | « chrome/browser/plugins/flash_download_interception.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698