| 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/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/content_settings/core/common/content_settings_types.h" |
| 16 #include "components/navigation_interception/intercept_navigation_throttle.h" | 17 #include "components/navigation_interception/intercept_navigation_throttle.h" |
| 17 #include "components/navigation_interception/navigation_params.h" | 18 #include "components/navigation_interception/navigation_params.h" |
| 18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/navigation_handle.h" | 20 #include "content/public/browser/navigation_handle.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 "third_party/re2/src/re2/re2.h" | 23 #include "third_party/re2/src/re2/re2.h" |
| 24 #include "url/origin.h" | 24 #include "url/origin.h" |
| 25 | 25 |
| 26 using content::BrowserThread; | 26 using content::BrowserThread; |
| 27 using content::NavigationHandle; | 27 using content::NavigationHandle; |
| 28 using content::NavigationThrottle; | 28 using content::NavigationThrottle; |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 60 HostContentSettingsMap* host_content_settings_map = | 60 HostContentSettingsMap* host_content_settings_map = |
| 61 HostContentSettingsMapFactory::GetForProfile(profile); | 61 HostContentSettingsMapFactory::GetForProfile(profile); |
| 62 ContentSetting flash_setting = PluginUtils::GetFlashPluginContentSetting( | 62 ContentSetting flash_setting = PluginUtils::GetFlashPluginContentSetting( |
| 63 host_content_settings_map, url::Origin(source_url), source_url, nullptr); | 63 host_content_settings_map, url::Origin(source_url), source_url, nullptr); |
| 64 flash_setting = PluginsFieldTrial::EffectiveContentSetting( | 64 flash_setting = PluginsFieldTrial::EffectiveContentSetting( |
| 65 host_content_settings_map, CONTENT_SETTINGS_TYPE_PLUGINS, flash_setting); | 65 host_content_settings_map, CONTENT_SETTINGS_TYPE_PLUGINS, flash_setting); |
| 66 | 66 |
| 67 if (flash_setting == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT) { | 67 if (flash_setting == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT) { |
| 68 PermissionManager* manager = PermissionManager::Get(profile); | 68 PermissionManager* manager = PermissionManager::Get(profile); |
| 69 manager->RequestPermission( | 69 manager->RequestPermission( |
| 70 content::PermissionType::FLASH, web_contents->GetMainFrame(), | 70 CONTENT_SETTINGS_TYPE_PLUGINS, web_contents->GetMainFrame(), |
| 71 web_contents->GetLastCommittedURL(), true, base::Bind(&DoNothing)); | 71 web_contents->GetLastCommittedURL(), true, base::Bind(&DoNothing)); |
| 72 } else if (flash_setting == CONTENT_SETTING_BLOCK) { | 72 } else if (flash_setting == CONTENT_SETTING_BLOCK) { |
| 73 TabSpecificContentSettings::FromWebContents(web_contents) | 73 TabSpecificContentSettings::FromWebContents(web_contents) |
| 74 ->FlashDownloadBlocked(); | 74 ->FlashDownloadBlocked(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 // If the content setting has been already changed, do nothing. | 77 // If the content setting has been already changed, do nothing. |
| 78 } | 78 } |
| 79 | 79 |
| 80 // static | 80 // static |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 HostContentSettingsMap* host_content_settings_map = | 137 HostContentSettingsMap* host_content_settings_map = |
| 138 HostContentSettingsMapFactory::GetForProfile(profile); | 138 HostContentSettingsMapFactory::GetForProfile(profile); |
| 139 if (!ShouldStopFlashDownloadAction(host_content_settings_map, source_url, | 139 if (!ShouldStopFlashDownloadAction(host_content_settings_map, source_url, |
| 140 handle->GetURL(), has_user_gesture)) { | 140 handle->GetURL(), has_user_gesture)) { |
| 141 return nullptr; | 141 return nullptr; |
| 142 } | 142 } |
| 143 | 143 |
| 144 return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>( | 144 return base::MakeUnique<navigation_interception::InterceptNavigationThrottle>( |
| 145 handle, base::Bind(&InterceptNavigation, source_url), true); | 145 handle, base::Bind(&InterceptNavigation, source_url), true); |
| 146 } | 146 } |
| OLD | NEW |