Chromium Code Reviews| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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* 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", | |
|
mihai.balan
2017/04/11 06:18:12
The code as it is now would still intercept https:
tommycli
2017/04/11 17:40:04
Done. I added an explicit check to avoid intercept
| |
| 52 "http://adobe.com/go/gntray_dl_getflashplayer_jp", | 53 "http://adobe.com/go/gntray_dl_getflashplayer_jp", |
|
raymes
2017/04/10 23:54:13
I feel like we could add a few more URLs here to m
tommycli
2017/04/11 17:40:05
Done. I added the h-m-a case, but we specifically
| |
| 53 }; | 54 }; |
| 54 | 55 |
| 55 for (auto* url : flash_intercept_urls) { | 56 for (auto* url : flash_intercept_urls) { |
| 56 EXPECT_TRUE(ShouldStopFlashDownloadAction(url)) | 57 EXPECT_TRUE(ShouldStopFlashDownloadAction(url)) |
| 57 << "Should have intercepted: " << url; | 58 << "Should have intercepted: " << url; |
| 58 } | 59 } |
| 59 | 60 |
| 60 const char* flash_no_intercept_urls[] = { | 61 const char* flash_no_intercept_urls[] = { |
| 61 "https://www.example.com", | 62 "https://www.example.com", "http://example.com/get.adobe.com/flashplayer", |
|
tommycli
2017/04/10 23:05:53
git cl format wanted to collaspe these lines...
| |
| 62 "http://example.com/get.adobe.com/flashplayer", | |
| 63 "http://ww.macromedia.com/go/getflashplayer", | 63 "http://ww.macromedia.com/go/getflashplayer", |
| 64 "http://wwwxmacromedia.com/go/getflashplayer", | 64 "http://wwwxmacromedia.com/go/getflashplayer", |
| 65 "http://www.adobe.com/software/flash/about/", | 65 "http://www.adobe.com/software/flash/about/", |
| 66 "http://www.adobe.com/products/flashplayer.html", | 66 "http://www.adobe.com/products/flashplayer.html", |
| 67 "http://www.adobe.com/products/flashruntimes.html", | 67 "http://www.adobe.com/products/flashruntimes.html", |
| 68 "http://www.adobe.com/go/flash", | 68 "http://www.adobe.com/go/flash", |
| 69 // Don't intercept URLs containing just "fp" without a matching prefix. | |
| 70 "http://www.adobe.com/go/non-matching-prefix-fp", | |
| 69 }; | 71 }; |
| 70 | 72 |
| 71 for (auto* url : flash_no_intercept_urls) { | 73 for (auto* url : flash_no_intercept_urls) { |
| 72 EXPECT_FALSE(ShouldStopFlashDownloadAction(url)) | 74 EXPECT_FALSE(ShouldStopFlashDownloadAction(url)) |
| 73 << "Should not have intercepted: " << url; | 75 << "Should not have intercepted: " << url; |
| 74 } | 76 } |
| 75 | 77 |
| 76 // Don't intercept navigations occurring on the flash download page. | 78 // Don't intercept navigations occurring on the flash download page. |
| 77 EXPECT_FALSE(FlashDownloadInterception::ShouldStopFlashDownloadAction( | 79 EXPECT_FALSE(FlashDownloadInterception::ShouldStopFlashDownloadAction( |
| 78 host_content_settings_map(), GURL("https://get.adobe.com/flashplayer/"), | 80 host_content_settings_map(), GURL("https://get.adobe.com/flashplayer/"), |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 // Intercept on both explicit DETECT and BLOCK. | 120 // Intercept on both explicit DETECT and BLOCK. |
| 119 map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, | 121 map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, |
| 120 CONTENT_SETTING_BLOCK); | 122 CONTENT_SETTING_BLOCK); |
| 121 EXPECT_TRUE( | 123 EXPECT_TRUE( |
| 122 ShouldStopFlashDownloadAction("https://get.adobe.com/flashplayer/")); | 124 ShouldStopFlashDownloadAction("https://get.adobe.com/flashplayer/")); |
| 123 map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, | 125 map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, |
| 124 CONTENT_SETTING_DETECT_IMPORTANT_CONTENT); | 126 CONTENT_SETTING_DETECT_IMPORTANT_CONTENT); |
| 125 EXPECT_TRUE( | 127 EXPECT_TRUE( |
| 126 ShouldStopFlashDownloadAction("https://get.adobe.com/flashplayer/")); | 128 ShouldStopFlashDownloadAction("https://get.adobe.com/flashplayer/")); |
| 127 } | 129 } |
| OLD | NEW |