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

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

Issue 2378573005: [HBD] Blanket BLOCK on all non-HTTP(s) and non-FILE URLs for Flash. (Closed)
Patch Set: fix formatting Created 4 years, 2 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
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 "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
11 #include "chrome/browser/permissions/permission_manager.h" 11 #include "chrome/browser/permissions/permission_manager.h"
12 #include "chrome/browser/plugins/plugin_utils.h" 12 #include "chrome/browser/plugins/plugin_utils.h"
13 #include "chrome/browser/plugins/plugins_field_trial.h" 13 #include "chrome/browser/plugins/plugins_field_trial.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/common/chrome_features.h" 15 #include "chrome/common/chrome_features.h"
16 #include "components/navigation_interception/intercept_navigation_throttle.h" 16 #include "components/navigation_interception/intercept_navigation_throttle.h"
17 #include "components/navigation_interception/navigation_params.h" 17 #include "components/navigation_interception/navigation_params.h"
18 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/navigation_handle.h" 19 #include "content/public/browser/navigation_handle.h"
20 #include "content/public/browser/permission_type.h" 20 #include "content/public/browser/permission_type.h"
21 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
22 #include "third_party/WebKit/public/platform/modules/permissions/permission_stat us.mojom.h" 22 #include "third_party/WebKit/public/platform/modules/permissions/permission_stat us.mojom.h"
23 #include "url/origin.h"
23 24
24 using content::BrowserThread; 25 using content::BrowserThread;
25 using content::NavigationHandle; 26 using content::NavigationHandle;
26 using content::NavigationThrottle; 27 using content::NavigationThrottle;
27 28
28 namespace { 29 namespace {
29 30
30 const char kFlashDownloadURL[] = "get.adobe.com/flash"; 31 const char kFlashDownloadURL[] = "get.adobe.com/flash";
31 32
32 void DoNothing(blink::mojom::PermissionStatus result) {} 33 void DoNothing(blink::mojom::PermissionStatus result) {}
(...skipping 24 matching lines...) Expand all
57 58
58 if (!has_user_gesture) 59 if (!has_user_gesture)
59 return false; 60 return false;
60 61
61 if (!base::StartsWith(target_url.GetContent(), kFlashDownloadURL, 62 if (!base::StartsWith(target_url.GetContent(), kFlashDownloadURL,
62 base::CompareCase::INSENSITIVE_ASCII)) { 63 base::CompareCase::INSENSITIVE_ASCII)) {
63 return false; 64 return false;
64 } 65 }
65 66
66 ContentSetting flash_setting = PluginUtils::GetFlashPluginContentSetting( 67 ContentSetting flash_setting = PluginUtils::GetFlashPluginContentSetting(
67 host_content_settings_map, source_url, source_url, nullptr); 68 host_content_settings_map, url::Origin(source_url), source_url, nullptr);
nasko 2016/09/30 20:38:48 Just FYI, this is a lossy conversion. For about:bl
tommycli 2016/09/30 21:20:41 Yes, that's perfect! :) We want to BLOCK flash on
68 flash_setting = PluginsFieldTrial::EffectiveContentSetting( 69 flash_setting = PluginsFieldTrial::EffectiveContentSetting(
69 CONTENT_SETTINGS_TYPE_PLUGINS, flash_setting); 70 CONTENT_SETTINGS_TYPE_PLUGINS, flash_setting);
70 71
71 return flash_setting == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT; 72 return flash_setting == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT;
72 } 73 }
73 74
74 // static 75 // static
75 std::unique_ptr<NavigationThrottle> 76 std::unique_ptr<NavigationThrottle>
76 FlashDownloadInterception::MaybeCreateThrottleFor(NavigationHandle* handle) { 77 FlashDownloadInterception::MaybeCreateThrottleFor(NavigationHandle* handle) {
77 DCHECK_CURRENTLY_ON(BrowserThread::UI); 78 DCHECK_CURRENTLY_ON(BrowserThread::UI);
78 79
79 // Never intercept Flash Download navigations in a new window. 80 // Never intercept Flash Download navigations in a new window.
80 if (handle->GetWebContents()->HasOpener()) 81 if (handle->GetWebContents()->HasOpener())
81 return nullptr; 82 return nullptr;
82 83
83 Profile* profile = Profile::FromBrowserContext( 84 Profile* profile = Profile::FromBrowserContext(
84 handle->GetWebContents()->GetBrowserContext()); 85 handle->GetWebContents()->GetBrowserContext());
85 HostContentSettingsMap* host_content_settings_map = 86 HostContentSettingsMap* host_content_settings_map =
86 HostContentSettingsMapFactory::GetForProfile(profile); 87 HostContentSettingsMapFactory::GetForProfile(profile);
87 GURL source_url = handle->GetWebContents()->GetLastCommittedURL(); 88 GURL source_url = handle->GetWebContents()->GetLastCommittedURL();
88 if (!ShouldStopFlashDownloadAction(host_content_settings_map, source_url, 89 if (!ShouldStopFlashDownloadAction(host_content_settings_map, source_url,
89 handle->GetURL(), 90 handle->GetURL(),
90 handle->HasUserGesture())) { 91 handle->HasUserGesture())) {
91 return nullptr; 92 return nullptr;
92 } 93 }
93 94
94 return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>( 95 return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>(
95 handle, base::Bind(&ShouldInterceptNavigation), true); 96 handle, base::Bind(&ShouldInterceptNavigation), true);
96 } 97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698