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

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

Issue 2379833002: Hookup the window.open flash download interception to the permission prompt (Closed)
Patch Set: Hookup the window.open flash download interception to the permission prompt 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"
(...skipping 13 matching lines...) Expand all
24 using content::BrowserThread; 24 using content::BrowserThread;
25 using content::NavigationHandle; 25 using content::NavigationHandle;
26 using content::NavigationThrottle; 26 using content::NavigationThrottle;
27 27
28 namespace { 28 namespace {
29 29
30 const char kFlashDownloadURL[] = "get.adobe.com/flash"; 30 const char kFlashDownloadURL[] = "get.adobe.com/flash";
31 31
32 void DoNothing(blink::mojom::PermissionStatus result) {} 32 void DoNothing(blink::mojom::PermissionStatus result) {}
33 33
34 bool ShouldInterceptNavigation( 34 bool InterceptNavigation(
Lei Zhang 2016/09/30 01:22:46 Why bother returning true if that's what we always
raymes 2016/09/30 01:53:19 Just to make the code happy - the callback needs t
35 content::WebContents* source, 35 content::WebContents* source,
36 const navigation_interception::NavigationParams& params) { 36 const navigation_interception::NavigationParams& params) {
37 FlashDownloadInterception::InterceptFlashDownloadNavigation(source);
38 return true;
39 }
40
41 } // namespace
42
43 // static
44 void FlashDownloadInterception::InterceptFlashDownloadNavigation(
45 content::WebContents* source) {
37 DCHECK_CURRENTLY_ON(BrowserThread::UI); 46 DCHECK_CURRENTLY_ON(BrowserThread::UI);
38 PermissionManager* manager = PermissionManager::Get( 47 PermissionManager* manager = PermissionManager::Get(
39 Profile::FromBrowserContext(source->GetBrowserContext())); 48 Profile::FromBrowserContext(source->GetBrowserContext()));
40 manager->RequestPermission( 49 manager->RequestPermission(
41 content::PermissionType::FLASH, source->GetMainFrame(), 50 content::PermissionType::FLASH, source->GetMainFrame(),
42 source->GetLastCommittedURL(), true, base::Bind(&DoNothing)); 51 source->GetLastCommittedURL(), true, base::Bind(&DoNothing));
43
44 return true;
45 } 52 }
46 53
47 } // namespace
48
49 // static 54 // static
50 bool FlashDownloadInterception::ShouldStopFlashDownloadAction( 55 bool FlashDownloadInterception::ShouldStopFlashDownloadAction(
51 HostContentSettingsMap* host_content_settings_map, 56 HostContentSettingsMap* host_content_settings_map,
52 const GURL& source_url, 57 const GURL& source_url,
53 const GURL& target_url, 58 const GURL& target_url,
54 bool has_user_gesture) { 59 bool has_user_gesture) {
55 if (!base::FeatureList::IsEnabled(features::kPreferHtmlOverPlugins)) 60 if (!base::FeatureList::IsEnabled(features::kPreferHtmlOverPlugins))
56 return false; 61 return false;
57 62
58 if (!has_user_gesture) 63 if (!has_user_gesture)
(...skipping 26 matching lines...) Expand all
85 HostContentSettingsMap* host_content_settings_map = 90 HostContentSettingsMap* host_content_settings_map =
86 HostContentSettingsMapFactory::GetForProfile(profile); 91 HostContentSettingsMapFactory::GetForProfile(profile);
87 GURL source_url = handle->GetWebContents()->GetLastCommittedURL(); 92 GURL source_url = handle->GetWebContents()->GetLastCommittedURL();
88 if (!ShouldStopFlashDownloadAction(host_content_settings_map, source_url, 93 if (!ShouldStopFlashDownloadAction(host_content_settings_map, source_url,
89 handle->GetURL(), 94 handle->GetURL(),
90 handle->HasUserGesture())) { 95 handle->HasUserGesture())) {
91 return nullptr; 96 return nullptr;
92 } 97 }
93 98
94 return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>( 99 return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>(
95 handle, base::Bind(&ShouldInterceptNavigation), true); 100 handle, base::Bind(&InterceptNavigation), true);
96 } 101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698