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