| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 TEST_F(FlashDownloadInterceptionTest, NavigationThrottleCancelsNavigation) { | 82 TEST_F(FlashDownloadInterceptionTest, NavigationThrottleCancelsNavigation) { |
| 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 false /* committed */, net::OK, true /* has_user_gesture */); | |
| 93 | 92 |
| 94 handle->CallWillStartRequestForTesting(true, content::Referrer(), | 93 handle->CallWillStartRequestForTesting(true, content::Referrer(), true, |
| 95 ui::PAGE_TRANSITION_LINK, false); | 94 ui::PAGE_TRANSITION_LINK, false); |
| 96 std::unique_ptr<NavigationThrottle> throttle = | 95 std::unique_ptr<NavigationThrottle> throttle = |
| 97 FlashDownloadInterception::MaybeCreateThrottleFor(handle.get()); | 96 FlashDownloadInterception::MaybeCreateThrottleFor(handle.get()); |
| 98 EXPECT_NE(nullptr, throttle); | 97 EXPECT_NE(nullptr, throttle); |
| 99 ASSERT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, | 98 ASSERT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, |
| 100 throttle->WillStartRequest()); | 99 throttle->WillStartRequest()); |
| 101 } | 100 } |
| 102 | 101 |
| 103 TEST_F(FlashDownloadInterceptionTest, OnlyInterceptOnDetectContentSetting) { | 102 TEST_F(FlashDownloadInterceptionTest, OnlyInterceptOnDetectContentSetting) { |
| 104 base::test::ScopedFeatureList feature_list; | 103 base::test::ScopedFeatureList feature_list; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 119 // Intercept on both explicit DETECT and BLOCK. | 118 // Intercept on both explicit DETECT and BLOCK. |
| 120 map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, | 119 map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, |
| 121 CONTENT_SETTING_BLOCK); | 120 CONTENT_SETTING_BLOCK); |
| 122 EXPECT_TRUE( | 121 EXPECT_TRUE( |
| 123 ShouldStopFlashDownloadAction("https://get.adobe.com/flashplayer/")); | 122 ShouldStopFlashDownloadAction("https://get.adobe.com/flashplayer/")); |
| 124 map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, | 123 map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, |
| 125 CONTENT_SETTING_DETECT_IMPORTANT_CONTENT); | 124 CONTENT_SETTING_DETECT_IMPORTANT_CONTENT); |
| 126 EXPECT_TRUE( | 125 EXPECT_TRUE( |
| 127 ShouldStopFlashDownloadAction("https://get.adobe.com/flashplayer/")); | 126 ShouldStopFlashDownloadAction("https://get.adobe.com/flashplayer/")); |
| 128 } | 127 } |
| OLD | NEW |