| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 if (!has_user_gesture) | 58 if (!has_user_gesture) |
| 59 return false; | 59 return false; |
| 60 | 60 |
| 61 if (!base::StartsWith(target_url.GetContent(), kFlashDownloadURL, | 61 if (!base::StartsWith(target_url.GetContent(), kFlashDownloadURL, |
| 62 base::CompareCase::INSENSITIVE_ASCII)) { | 62 base::CompareCase::INSENSITIVE_ASCII)) { |
| 63 return false; | 63 return false; |
| 64 } | 64 } |
| 65 | 65 |
| 66 ContentSetting flash_setting = PluginUtils::GetFlashPluginContentSetting( | 66 ContentSetting flash_setting = PluginUtils::GetFlashPluginContentSetting( |
| 67 host_content_settings_map, source_url, source_url); | 67 host_content_settings_map, source_url, source_url, nullptr); |
| 68 flash_setting = PluginsFieldTrial::EffectiveContentSetting( | 68 flash_setting = PluginsFieldTrial::EffectiveContentSetting( |
| 69 CONTENT_SETTINGS_TYPE_PLUGINS, flash_setting); | 69 CONTENT_SETTINGS_TYPE_PLUGINS, flash_setting); |
| 70 | 70 |
| 71 return flash_setting == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT; | 71 return flash_setting == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT; |
| 72 } | 72 } |
| 73 | 73 |
| 74 // static | 74 // static |
| 75 std::unique_ptr<NavigationThrottle> | 75 std::unique_ptr<NavigationThrottle> |
| 76 FlashDownloadInterception::MaybeCreateThrottleFor(NavigationHandle* handle) { | 76 FlashDownloadInterception::MaybeCreateThrottleFor(NavigationHandle* handle) { |
| 77 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 77 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 78 | 78 |
| 79 // Never intercept Flash Download navigations in a new window. | 79 // Never intercept Flash Download navigations in a new window. |
| 80 if (handle->GetWebContents()->HasOpener()) | 80 if (handle->GetWebContents()->HasOpener()) |
| 81 return nullptr; | 81 return nullptr; |
| 82 | 82 |
| 83 Profile* profile = Profile::FromBrowserContext( | 83 Profile* profile = Profile::FromBrowserContext( |
| 84 handle->GetWebContents()->GetBrowserContext()); | 84 handle->GetWebContents()->GetBrowserContext()); |
| 85 HostContentSettingsMap* host_content_settings_map = | 85 HostContentSettingsMap* host_content_settings_map = |
| 86 HostContentSettingsMapFactory::GetForProfile(profile); | 86 HostContentSettingsMapFactory::GetForProfile(profile); |
| 87 GURL source_url = handle->GetWebContents()->GetLastCommittedURL(); | 87 GURL source_url = handle->GetWebContents()->GetLastCommittedURL(); |
| 88 if (!ShouldStopFlashDownloadAction(host_content_settings_map, source_url, | 88 if (!ShouldStopFlashDownloadAction(host_content_settings_map, source_url, |
| 89 handle->GetURL(), | 89 handle->GetURL(), |
| 90 handle->HasUserGesture())) { | 90 handle->HasUserGesture())) { |
| 91 return nullptr; | 91 return nullptr; |
| 92 } | 92 } |
| 93 | 93 |
| 94 return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>( | 94 return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>( |
| 95 handle, base::Bind(&ShouldInterceptNavigation), true); | 95 handle, base::Bind(&ShouldInterceptNavigation), true); |
| 96 } | 96 } |
| OLD | NEW |