| 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 24 matching lines...) Expand all Loading... |
| 35 feature_list.InitAndDisableFeature(features::kPreferHtmlOverPlugins); | 35 feature_list.InitAndDisableFeature(features::kPreferHtmlOverPlugins); |
| 36 | 36 |
| 37 EXPECT_FALSE( | 37 EXPECT_FALSE( |
| 38 ShouldStopFlashDownloadAction("https://get.adobe.com/flashplayer/")); | 38 ShouldStopFlashDownloadAction("https://get.adobe.com/flashplayer/")); |
| 39 } | 39 } |
| 40 | 40 |
| 41 TEST_F(FlashDownloadInterceptionTest, DownloadUrlVariations) { | 41 TEST_F(FlashDownloadInterceptionTest, DownloadUrlVariations) { |
| 42 base::test::ScopedFeatureList feature_list; | 42 base::test::ScopedFeatureList feature_list; |
| 43 feature_list.InitAndEnableFeature(features::kPreferHtmlOverPlugins); | 43 feature_list.InitAndEnableFeature(features::kPreferHtmlOverPlugins); |
| 44 | 44 |
| 45 const char* flash_intercept_urls[] = { | 45 const char* const flash_intercept_urls[] = { |
| 46 "https://get.adobe.com/flashplayer/", | 46 "https://get.adobe.com/flashplayer/", |
| 47 "http://get.adobe.com/flash", | 47 "http://get.adobe.com/flash", |
| 48 "http://get.adobe.com/fr/flashplayer/", | 48 "http://get.adobe.com/fr/flashplayer/", |
| 49 "http://get.adobe.com/flashplayer", | 49 "http://get.adobe.com/flashplayer", |
| 50 "http://macromedia.com/go/getflashplayer", | 50 "http://macromedia.com/go/getflashplayer", |
| 51 "http://adobe.com/go/getflashplayer", | 51 "http://adobe.com/go/getflashplayer", |
| 52 "http://adobe.com/go/CA-H-GET-FLASH", | 52 "http://adobe.com/go/CA-H-GET-FLASH", |
| 53 "http://adobe.com/go/DE_CH-H-M-A2", | 53 "http://adobe.com/go/DE_CH-H-M-A2", |
| 54 "http://adobe.com/go/gntray_dl_getflashplayer_jp", | 54 "http://adobe.com/go/gntray_dl_getflashplayer_jp", |
| 55 "http://www.adobe.com/shockwave/download/download.cgi?" |
| 56 "P1_Prod_Version=ShockwaveFlash", |
| 55 }; | 57 }; |
| 56 | 58 |
| 57 for (auto* url : flash_intercept_urls) { | 59 for (auto* url : flash_intercept_urls) { |
| 58 EXPECT_TRUE(ShouldStopFlashDownloadAction(url)) | 60 EXPECT_TRUE(ShouldStopFlashDownloadAction(url)) |
| 59 << "Should have intercepted: " << url; | 61 << "Should have intercepted: " << url; |
| 60 } | 62 } |
| 61 | 63 |
| 62 const char* flash_no_intercept_urls[] = { | 64 const char* const flash_no_intercept_urls[] = { |
| 63 "https://www.example.com", "http://example.com/get.adobe.com/flashplayer", | 65 "https://www.examplefoo.com", |
| 66 "http://examplefoo.com/get.adobe.com/flashplayer", |
| 64 "http://ww.macromedia.com/go/getflashplayer", | 67 "http://ww.macromedia.com/go/getflashplayer", |
| 65 "http://wwwxmacromedia.com/go/getflashplayer", | 68 "http://wwwxmacromedia.com/go/getflashplayer", |
| 66 "http://www.adobe.com/software/flash/about/", | 69 "http://www.adobe.com/software/flash/about/", |
| 67 "http://www.adobe.com/products/flashplayer.html", | 70 "http://www.adobe.com/products/flashplayer.html", |
| 68 "http://www.adobe.com/products/flashruntimes.html", | 71 "http://www.adobe.com/products/flashruntimes.html", |
| 69 "http://www.adobe.com/go/flash", | 72 "http://www.adobe.com/go/flash", |
| 70 // Don't intercept URLs containing just "fp" without a matching prefix. | 73 // Don't intercept URLs containing just "fp" without a matching prefix. |
| 71 "http://www.adobe.com/go/non-matching-prefix-fp", | 74 "http://www.adobe.com/go/non-matching-prefix-fp", |
| 72 // Don't match text within the query or fragment. | 75 // Don't match text within the query or fragment. |
| 73 "http://www.adobe.com/go/non-matching?foo=flashplayer", | 76 "http://www.adobe.com/go/non-matching?foo=flashplayer", |
| 74 "http://www.adobe.com/go/non-matching#!foo=flashplayer", | 77 "http://www.adobe.com/go/non-matching#!foo=flashplayer", |
| 78 "http://www.adobe.com/shockwave/download/download.cgi?" |
| 79 "P1_Prod_Version=SomethingElse", |
| 75 }; | 80 }; |
| 76 | 81 |
| 77 for (auto* url : flash_no_intercept_urls) { | 82 for (auto* url : flash_no_intercept_urls) { |
| 78 EXPECT_FALSE(ShouldStopFlashDownloadAction(url)) | 83 EXPECT_FALSE(ShouldStopFlashDownloadAction(url)) |
| 79 << "Should not have intercepted: " << url; | 84 << "Should not have intercepted: " << url; |
| 80 } | 85 } |
| 81 | 86 |
| 82 // Don't intercept navigations occurring on the flash download page. | 87 // Don't intercept navigations occurring on the flash download page. |
| 83 EXPECT_FALSE(FlashDownloadInterception::ShouldStopFlashDownloadAction( | 88 EXPECT_FALSE(FlashDownloadInterception::ShouldStopFlashDownloadAction( |
| 84 host_content_settings_map(), GURL("https://get.adobe.com/flashplayer/"), | 89 host_content_settings_map(), GURL("https://get.adobe.com/flashplayer/"), |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // Intercept on both explicit DETECT and BLOCK. | 129 // Intercept on both explicit DETECT and BLOCK. |
| 125 map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, | 130 map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, |
| 126 CONTENT_SETTING_BLOCK); | 131 CONTENT_SETTING_BLOCK); |
| 127 EXPECT_TRUE( | 132 EXPECT_TRUE( |
| 128 ShouldStopFlashDownloadAction("https://get.adobe.com/flashplayer/")); | 133 ShouldStopFlashDownloadAction("https://get.adobe.com/flashplayer/")); |
| 129 map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, | 134 map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, |
| 130 CONTENT_SETTING_DETECT_IMPORTANT_CONTENT); | 135 CONTENT_SETTING_DETECT_IMPORTANT_CONTENT); |
| 131 EXPECT_TRUE( | 136 EXPECT_TRUE( |
| 132 ShouldStopFlashDownloadAction("https://get.adobe.com/flashplayer/")); | 137 ShouldStopFlashDownloadAction("https://get.adobe.com/flashplayer/")); |
| 133 } | 138 } |
| OLD | NEW |