| 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/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 16 matching lines...) Expand all Loading... |
| 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 InterceptNavigation( | 34 bool InterceptNavigation( |
| 35 content::WebContents* source, | 35 content::WebContents* source, |
| 36 const navigation_interception::NavigationParams& params) { | 36 const navigation_interception::NavigationParams& params) { |
| 37 FlashDownloadInterception::InterceptFlashDownloadNavigation(source); | 37 FlashDownloadInterception::ShowRunFlashPrompt(source); |
| 38 return true; | 38 return true; |
| 39 } | 39 } |
| 40 | 40 |
| 41 } // namespace | 41 } // namespace |
| 42 | 42 |
| 43 // static | 43 // static |
| 44 void FlashDownloadInterception::InterceptFlashDownloadNavigation( | 44 void FlashDownloadInterception::ShowRunFlashPrompt( |
| 45 content::WebContents* source) { | 45 content::WebContents* web_contents) { |
| 46 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 46 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 47 PermissionManager* manager = PermissionManager::Get( | 47 PermissionManager* manager = PermissionManager::Get( |
| 48 Profile::FromBrowserContext(source->GetBrowserContext())); | 48 Profile::FromBrowserContext(web_contents->GetBrowserContext())); |
| 49 manager->RequestPermission( | 49 manager->RequestPermission( |
| 50 content::PermissionType::FLASH, source->GetMainFrame(), | 50 content::PermissionType::FLASH, web_contents->GetMainFrame(), |
| 51 source->GetLastCommittedURL(), true, base::Bind(&DoNothing)); | 51 web_contents->GetLastCommittedURL(), true, base::Bind(&DoNothing)); |
| 52 } | 52 } |
| 53 | 53 |
| 54 // static | 54 // static |
| 55 bool FlashDownloadInterception::ShouldStopFlashDownloadAction( | 55 bool FlashDownloadInterception::ShouldStopFlashDownloadAction( |
| 56 HostContentSettingsMap* host_content_settings_map, | 56 HostContentSettingsMap* host_content_settings_map, |
| 57 const GURL& source_url, | 57 const GURL& source_url, |
| 58 const GURL& target_url, | 58 const GURL& target_url, |
| 59 bool has_user_gesture) { | 59 bool has_user_gesture) { |
| 60 if (!base::FeatureList::IsEnabled(features::kPreferHtmlOverPlugins)) | 60 if (!base::FeatureList::IsEnabled(features::kPreferHtmlOverPlugins)) |
| 61 return false; | 61 return false; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 92 GURL source_url = handle->GetWebContents()->GetLastCommittedURL(); | 92 GURL source_url = handle->GetWebContents()->GetLastCommittedURL(); |
| 93 if (!ShouldStopFlashDownloadAction(host_content_settings_map, source_url, | 93 if (!ShouldStopFlashDownloadAction(host_content_settings_map, source_url, |
| 94 handle->GetURL(), | 94 handle->GetURL(), |
| 95 handle->HasUserGesture())) { | 95 handle->HasUserGesture())) { |
| 96 return nullptr; | 96 return nullptr; |
| 97 } | 97 } |
| 98 | 98 |
| 99 return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>( | 99 return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>( |
| 100 handle, base::Bind(&InterceptNavigation), true); | 100 handle, base::Bind(&InterceptNavigation), true); |
| 101 } | 101 } |
| OLD | NEW |