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

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

Issue 2811903002: [HBD] Tighten-up which adobe.com/go links are intercepted as Flash URLs (Closed)
Patch Set: fix Created 3 years, 8 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 | « no previous file | chrome/browser/plugins/flash_download_interception_unittest.cc » ('j') | 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/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
(...skipping 14 matching lines...) Expand all
25 25
26 using content::BrowserThread; 26 using content::BrowserThread;
27 using content::NavigationHandle; 27 using content::NavigationHandle;
28 using content::NavigationThrottle; 28 using content::NavigationThrottle;
29 29
30 namespace { 30 namespace {
31 31
32 // Regexes matching 32 // Regexes matching
33 const char kGetFlashURLCanonicalRegex[] = "(?i)get\\.adobe\\.com/.*flash.*"; 33 const char kGetFlashURLCanonicalRegex[] = "(?i)get\\.adobe\\.com/.*flash.*";
34 const char kGetFlashURLSecondaryRegex[] = 34 const char kGetFlashURLSecondaryRegex[] =
35 "(?i)(www\\.)?(adobe|macromedia)\\.com/go.*" 35 "(?i)(www\\.)?(adobe|macromedia)\\.com/go/"
36 "(get[-_]?flash|fl(ash)?.?pl(ayer)?|flash_completion|flashpm|flashdownload|" 36 "((?i).*get[-_]?flash|getfp10android|.*fl(ash)player|.*flashpl|"
37 "fp|h-m-a-?2|chrome|download_player|gnav_fl|pdcredirect).*"; 37 ".*flash_player|flash_completion|flashpm|.*flashdownload|d65_flplayer|"
38 "fp_jp|runtimes_fp|[a-z_-]{3,6}h-m-a-?2|chrome|download_player|"
39 "gnav_fl|pdcredirect).*";
38 40
39 void DoNothing(ContentSetting result) {} 41 void DoNothing(ContentSetting result) {}
40 42
41 bool InterceptNavigation( 43 bool InterceptNavigation(
42 const GURL& source_url, 44 const GURL& source_url,
43 content::WebContents* source, 45 content::WebContents* source,
44 const navigation_interception::NavigationParams& params) { 46 const navigation_interception::NavigationParams& params) {
45 FlashDownloadInterception::InterceptFlashDownloadNavigation(source, 47 FlashDownloadInterception::InterceptFlashDownloadNavigation(source,
46 source_url); 48 source_url);
47 return true; 49 return true;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 HostContentSettingsMap* host_content_settings_map, 84 HostContentSettingsMap* host_content_settings_map,
83 const GURL& source_url, 85 const GURL& source_url,
84 const GURL& target_url, 86 const GURL& target_url,
85 bool has_user_gesture) { 87 bool has_user_gesture) {
86 if (!PluginUtils::ShouldPreferHtmlOverPlugins(host_content_settings_map)) 88 if (!PluginUtils::ShouldPreferHtmlOverPlugins(host_content_settings_map))
87 return false; 89 return false;
88 90
89 if (!has_user_gesture) 91 if (!has_user_gesture)
90 return false; 92 return false;
91 93
94 url::Replacements<char> replacements;
95 replacements.ClearQuery();
96 replacements.ClearRef();
97 replacements.ClearUsername();
98 replacements.ClearPassword();
99
92 // If the navigation source is already the Flash download page, don't 100 // If the navigation source is already the Flash download page, don't
93 // intercept the download. The user may be trying to download Flash. 101 // intercept the download. The user may be trying to download Flash.
94 if (RE2::PartialMatch(source_url.GetContent(), kGetFlashURLCanonicalRegex)) 102 std::string source_url_str =
103 source_url.ReplaceComponents(replacements).GetContent();
104 if (RE2::PartialMatch(source_url_str, kGetFlashURLCanonicalRegex))
95 return false; 105 return false;
96 106
97 std::string target_url_str = target_url.GetContent(); 107 std::string target_url_str =
108 target_url.ReplaceComponents(replacements).GetContent();
98 if (RE2::FullMatch(target_url_str, kGetFlashURLCanonicalRegex) || 109 if (RE2::FullMatch(target_url_str, kGetFlashURLCanonicalRegex) ||
99 RE2::FullMatch(target_url_str, kGetFlashURLSecondaryRegex)) { 110 RE2::FullMatch(target_url_str, kGetFlashURLSecondaryRegex)) {
100 ContentSetting flash_setting = PluginUtils::GetFlashPluginContentSetting( 111 ContentSetting flash_setting = PluginUtils::GetFlashPluginContentSetting(
101 host_content_settings_map, url::Origin(source_url), source_url, 112 host_content_settings_map, url::Origin(source_url), source_url,
102 nullptr); 113 nullptr);
103 flash_setting = PluginsFieldTrial::EffectiveContentSetting( 114 flash_setting = PluginsFieldTrial::EffectiveContentSetting(
104 host_content_settings_map, CONTENT_SETTINGS_TYPE_PLUGINS, 115 host_content_settings_map, CONTENT_SETTINGS_TYPE_PLUGINS,
105 flash_setting); 116 flash_setting);
106 117
107 return flash_setting == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT || 118 return flash_setting == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT ||
(...skipping 29 matching lines...) Expand all
137 HostContentSettingsMap* host_content_settings_map = 148 HostContentSettingsMap* host_content_settings_map =
138 HostContentSettingsMapFactory::GetForProfile(profile); 149 HostContentSettingsMapFactory::GetForProfile(profile);
139 if (!ShouldStopFlashDownloadAction(host_content_settings_map, source_url, 150 if (!ShouldStopFlashDownloadAction(host_content_settings_map, source_url,
140 handle->GetURL(), has_user_gesture)) { 151 handle->GetURL(), has_user_gesture)) {
141 return nullptr; 152 return nullptr;
142 } 153 }
143 154
144 return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>( 155 return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>(
145 handle, base::Bind(&InterceptNavigation, source_url), true); 156 handle, base::Bind(&InterceptNavigation, source_url), true);
146 } 157 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/plugins/flash_download_interception_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698