OLD | NEW |
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/browser/content_settings/host_content_settings_map_factory.h" |
9 #include "chrome/common/chrome_features.h" | 9 #include "chrome/common/chrome_features.h" |
10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 base::test::ScopedFeatureList feature_list; | 83 base::test::ScopedFeatureList feature_list; |
84 feature_list.InitAndEnableFeature(features::kPreferHtmlOverPlugins); | 84 feature_list.InitAndEnableFeature(features::kPreferHtmlOverPlugins); |
85 | 85 |
86 // Set the source URL to an HTTP source. | 86 // Set the source URL to an HTTP source. |
87 NavigateAndCommit(GURL("http://example.com")); | 87 NavigateAndCommit(GURL("http://example.com")); |
88 | 88 |
89 std::unique_ptr<NavigationHandle> handle = | 89 std::unique_ptr<NavigationHandle> handle = |
90 NavigationHandle::CreateNavigationHandleForTesting( | 90 NavigationHandle::CreateNavigationHandleForTesting( |
91 GURL("https://get.adobe.com/flashplayer"), main_rfh()); | 91 GURL("https://get.adobe.com/flashplayer"), main_rfh()); |
92 | 92 |
93 handle->CallWillStartRequestForTesting(true, content::Referrer(), true, | 93 handle->CallWillStartRequestForTesting( |
94 ui::PAGE_TRANSITION_LINK, false); | 94 true, content::Referrer(), true, ui::PAGE_TRANSITION_LINK, false, |
| 95 content::NavigationHandle::ThrottleChecksFinishedCallback()); |
95 std::unique_ptr<NavigationThrottle> throttle = | 96 std::unique_ptr<NavigationThrottle> throttle = |
96 FlashDownloadInterception::MaybeCreateThrottleFor(handle.get()); | 97 FlashDownloadInterception::MaybeCreateThrottleFor(handle.get()); |
97 EXPECT_NE(nullptr, throttle); | 98 EXPECT_NE(nullptr, throttle); |
98 ASSERT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, | 99 ASSERT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, |
99 throttle->WillStartRequest()); | 100 throttle->WillStartRequest()); |
100 } | 101 } |
101 | 102 |
102 TEST_F(FlashDownloadInterceptionTest, OnlyInterceptOnDetectContentSetting) { | 103 TEST_F(FlashDownloadInterceptionTest, OnlyInterceptOnDetectContentSetting) { |
103 base::test::ScopedFeatureList feature_list; | 104 base::test::ScopedFeatureList feature_list; |
104 feature_list.InitAndEnableFeature(features::kPreferHtmlOverPlugins); | 105 feature_list.InitAndEnableFeature(features::kPreferHtmlOverPlugins); |
(...skipping 13 matching lines...) Expand all Loading... |
118 // Intercept on both explicit DETECT and BLOCK. | 119 // Intercept on both explicit DETECT and BLOCK. |
119 map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, | 120 map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, |
120 CONTENT_SETTING_BLOCK); | 121 CONTENT_SETTING_BLOCK); |
121 EXPECT_TRUE( | 122 EXPECT_TRUE( |
122 ShouldStopFlashDownloadAction("https://get.adobe.com/flashplayer/")); | 123 ShouldStopFlashDownloadAction("https://get.adobe.com/flashplayer/")); |
123 map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, | 124 map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, |
124 CONTENT_SETTING_DETECT_IMPORTANT_CONTENT); | 125 CONTENT_SETTING_DETECT_IMPORTANT_CONTENT); |
125 EXPECT_TRUE( | 126 EXPECT_TRUE( |
126 ShouldStopFlashDownloadAction("https://get.adobe.com/flashplayer/")); | 127 ShouldStopFlashDownloadAction("https://get.adobe.com/flashplayer/")); |
127 } | 128 } |
OLD | NEW |