| 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 "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" |
| 11 #include "chrome/browser/permissions/permission_manager.h" | 11 #include "chrome/browser/permissions/permission_manager.h" |
| 12 #include "chrome/browser/permissions/permission_result.h" |
| 12 #include "chrome/browser/plugins/plugin_utils.h" | 13 #include "chrome/browser/plugins/plugin_utils.h" |
| 13 #include "chrome/browser/plugins/plugins_field_trial.h" | 14 #include "chrome/browser/plugins/plugins_field_trial.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/common/chrome_features.h" | 16 #include "chrome/common/chrome_features.h" |
| 16 #include "components/content_settings/core/common/content_settings_types.h" | 17 #include "components/content_settings/core/common/content_settings_types.h" |
| 17 #include "components/navigation_interception/intercept_navigation_throttle.h" | 18 #include "components/navigation_interception/intercept_navigation_throttle.h" |
| 18 #include "components/navigation_interception/navigation_params.h" | 19 #include "components/navigation_interception/navigation_params.h" |
| 19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/navigation_handle.h" | 21 #include "content/public/browser/navigation_handle.h" |
| 21 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // static | 59 // static |
| 59 void FlashDownloadInterception::InterceptFlashDownloadNavigation( | 60 void FlashDownloadInterception::InterceptFlashDownloadNavigation( |
| 60 content::WebContents* web_contents, | 61 content::WebContents* web_contents, |
| 61 const GURL& source_url) { | 62 const GURL& source_url) { |
| 62 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 63 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 63 | 64 |
| 64 Profile* profile = | 65 Profile* profile = |
| 65 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 66 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 66 HostContentSettingsMap* host_content_settings_map = | 67 HostContentSettingsMap* host_content_settings_map = |
| 67 HostContentSettingsMapFactory::GetForProfile(profile); | 68 HostContentSettingsMapFactory::GetForProfile(profile); |
| 68 ContentSetting flash_setting = PluginUtils::GetFlashPluginContentSetting( | 69 ContentSetting flash_setting = |
| 69 host_content_settings_map, url::Origin(source_url), source_url, nullptr); | 70 PluginUtils::GetFlashPluginContentSetting(host_content_settings_map, |
| 71 url::Origin(source_url), |
| 72 source_url, nullptr) |
| 73 .content_setting; |
| 70 flash_setting = PluginsFieldTrial::EffectiveContentSetting( | 74 flash_setting = PluginsFieldTrial::EffectiveContentSetting( |
| 71 host_content_settings_map, CONTENT_SETTINGS_TYPE_PLUGINS, flash_setting); | 75 host_content_settings_map, CONTENT_SETTINGS_TYPE_PLUGINS, flash_setting); |
| 72 | 76 |
| 73 if (flash_setting == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT) { | 77 if (flash_setting == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT) { |
| 74 PermissionManager* manager = PermissionManager::Get(profile); | 78 PermissionManager* manager = PermissionManager::Get(profile); |
| 75 manager->RequestPermission( | 79 manager->RequestPermission( |
| 76 CONTENT_SETTINGS_TYPE_PLUGINS, web_contents->GetMainFrame(), | 80 CONTENT_SETTINGS_TYPE_PLUGINS, web_contents->GetMainFrame(), |
| 77 web_contents->GetLastCommittedURL(), true, base::Bind(&DoNothing)); | 81 web_contents->GetLastCommittedURL(), true, base::Bind(&DoNothing)); |
| 78 } else if (flash_setting == CONTENT_SETTING_BLOCK) { | 82 } else if (flash_setting == CONTENT_SETTING_BLOCK) { |
| 79 TabSpecificContentSettings::FromWebContents(web_contents) | 83 TabSpecificContentSettings::FromWebContents(web_contents) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 107 source_url.ReplaceComponents(replacements).GetContent(); | 111 source_url.ReplaceComponents(replacements).GetContent(); |
| 108 if (RE2::PartialMatch(source_url_str, kGetFlashURLCanonicalRegex)) | 112 if (RE2::PartialMatch(source_url_str, kGetFlashURLCanonicalRegex)) |
| 109 return false; | 113 return false; |
| 110 | 114 |
| 111 std::string target_url_str = | 115 std::string target_url_str = |
| 112 target_url.ReplaceComponents(replacements).GetContent(); | 116 target_url.ReplaceComponents(replacements).GetContent(); |
| 113 if (RE2::FullMatch(target_url_str, kGetFlashURLCanonicalRegex) || | 117 if (RE2::FullMatch(target_url_str, kGetFlashURLCanonicalRegex) || |
| 114 RE2::FullMatch(target_url_str, kGetFlashURLSecondaryGoRegex) || | 118 RE2::FullMatch(target_url_str, kGetFlashURLSecondaryGoRegex) || |
| 115 (RE2::FullMatch(target_url_str, kGetFlashURLSecondaryDownloadRegex) && | 119 (RE2::FullMatch(target_url_str, kGetFlashURLSecondaryDownloadRegex) && |
| 116 target_url.query() == kGetFlashURLSecondaryDownloadQuery)) { | 120 target_url.query() == kGetFlashURLSecondaryDownloadQuery)) { |
| 117 ContentSetting flash_setting = PluginUtils::GetFlashPluginContentSetting( | 121 ContentSetting flash_setting = |
| 118 host_content_settings_map, url::Origin(source_url), source_url, | 122 PluginUtils::GetFlashPluginContentSetting(host_content_settings_map, |
| 119 nullptr); | 123 url::Origin(source_url), |
| 124 source_url, nullptr) |
| 125 .content_setting; |
| 120 flash_setting = PluginsFieldTrial::EffectiveContentSetting( | 126 flash_setting = PluginsFieldTrial::EffectiveContentSetting( |
| 121 host_content_settings_map, CONTENT_SETTINGS_TYPE_PLUGINS, | 127 host_content_settings_map, CONTENT_SETTINGS_TYPE_PLUGINS, |
| 122 flash_setting); | 128 flash_setting); |
| 123 | 129 |
| 124 return flash_setting == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT || | 130 return flash_setting == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT || |
| 125 flash_setting == CONTENT_SETTING_BLOCK; | 131 flash_setting == CONTENT_SETTING_BLOCK; |
| 126 } | 132 } |
| 127 | 133 |
| 128 return false; | 134 return false; |
| 129 } | 135 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 154 HostContentSettingsMap* host_content_settings_map = | 160 HostContentSettingsMap* host_content_settings_map = |
| 155 HostContentSettingsMapFactory::GetForProfile(profile); | 161 HostContentSettingsMapFactory::GetForProfile(profile); |
| 156 if (!ShouldStopFlashDownloadAction(host_content_settings_map, source_url, | 162 if (!ShouldStopFlashDownloadAction(host_content_settings_map, source_url, |
| 157 handle->GetURL(), has_user_gesture)) { | 163 handle->GetURL(), has_user_gesture)) { |
| 158 return nullptr; | 164 return nullptr; |
| 159 } | 165 } |
| 160 | 166 |
| 161 return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>( | 167 return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>( |
| 162 handle, base::Bind(&InterceptNavigation, source_url)); | 168 handle, base::Bind(&InterceptNavigation, source_url)); |
| 163 } | 169 } |
| OLD | NEW |