OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chrome_plugin_service_filter.h" | 5 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 #include "components/content_settings/content/common/content_settings_messages.h " | 21 #include "components/content_settings/content/common/content_settings_messages.h " |
22 #include "components/content_settings/core/browser/host_content_settings_map.h" | 22 #include "components/content_settings/core/browser/host_content_settings_map.h" |
23 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
25 #include "content/public/browser/plugin_service.h" | 25 #include "content/public/browser/plugin_service.h" |
26 #include "content/public/browser/render_frame_host.h" | 26 #include "content/public/browser/render_frame_host.h" |
27 #include "content/public/browser/render_process_host.h" | 27 #include "content/public/browser/render_process_host.h" |
28 #include "content/public/browser/resource_context.h" | 28 #include "content/public/browser/resource_context.h" |
29 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
30 #include "content/public/common/content_constants.h" | 30 #include "content/public/common/content_constants.h" |
31 #include "url/gurl.h" | |
32 | 31 |
33 using content::BrowserThread; | 32 using content::BrowserThread; |
34 using content::PluginService; | 33 using content::PluginService; |
35 | 34 |
36 namespace { | 35 namespace { |
37 | 36 |
38 class ProfileContentSettingObserver : public content_settings::Observer { | 37 class ProfileContentSettingObserver : public content_settings::Observer { |
39 public: | 38 public: |
40 explicit ProfileContentSettingObserver(Profile* profile) | 39 explicit ProfileContentSettingObserver(Profile* profile) |
41 : profile_(profile) {} | 40 : profile_(profile) {} |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 web_contents->SendToAllFrames(new ChromeViewMsg_LoadBlockedPlugins( | 159 web_contents->SendToAllFrames(new ChromeViewMsg_LoadBlockedPlugins( |
161 MSG_ROUTING_NONE, identifier)); | 160 MSG_ROUTING_NONE, identifier)); |
162 } | 161 } |
163 } | 162 } |
164 | 163 |
165 bool ChromePluginServiceFilter::IsPluginAvailable( | 164 bool ChromePluginServiceFilter::IsPluginAvailable( |
166 int render_process_id, | 165 int render_process_id, |
167 int render_frame_id, | 166 int render_frame_id, |
168 const void* context, | 167 const void* context, |
169 const GURL& plugin_content_url, | 168 const GURL& plugin_content_url, |
170 const GURL& main_url, | 169 const url::Origin& main_frame_origin, |
171 content::WebPluginInfo* plugin) { | 170 content::WebPluginInfo* plugin) { |
172 base::AutoLock auto_lock(lock_); | 171 base::AutoLock auto_lock(lock_); |
173 const ProcessDetails* details = GetProcess(render_process_id); | 172 const ProcessDetails* details = GetProcess(render_process_id); |
174 | 173 |
175 // Check whether the plugin is overridden. | 174 // Check whether the plugin is overridden. |
176 if (details) { | 175 if (details) { |
177 for (const auto& plugin_override : details->overridden_plugins) { | 176 for (const auto& plugin_override : details->overridden_plugins) { |
178 if (plugin_override.render_frame_id == render_frame_id && | 177 if (plugin_override.render_frame_id == render_frame_id && |
179 (plugin_override.url.is_empty() || | 178 (plugin_override.url.is_empty() || |
180 plugin_override.url == plugin_content_url)) { | 179 plugin_override.url == plugin_content_url)) { |
(...skipping 16 matching lines...) Expand all Loading... | |
197 const ContextInfo* context_info = context_info_it->second.get(); | 196 const ContextInfo* context_info = context_info_it->second.get(); |
198 if (!context_info->plugin_prefs.get()->IsPluginEnabled(*plugin)) | 197 if (!context_info->plugin_prefs.get()->IsPluginEnabled(*plugin)) |
199 return false; | 198 return false; |
200 | 199 |
201 // If PreferHtmlOverPlugins is enabled and the plugin is Flash, we do | 200 // If PreferHtmlOverPlugins is enabled and the plugin is Flash, we do |
202 // additional checks. | 201 // additional checks. |
203 if (plugin->name == base::ASCIIToUTF16(content::kFlashPluginName) && | 202 if (plugin->name == base::ASCIIToUTF16(content::kFlashPluginName) && |
204 base::FeatureList::IsEnabled(features::kPreferHtmlOverPlugins)) { | 203 base::FeatureList::IsEnabled(features::kPreferHtmlOverPlugins)) { |
205 // Check the content setting first, and always respect the ALLOW or BLOCK | 204 // Check the content setting first, and always respect the ALLOW or BLOCK |
206 // state. When IsPluginAvailable() is called to check whether a plugin | 205 // state. When IsPluginAvailable() is called to check whether a plugin |
207 // should be advertised, |url| has the same value of |policy_url| (i.e. the | 206 // should be advertised, |url| has the same origin as |main_frame_origin|. |
208 // main frame origin). The intended behavior is that Flash is advertised | 207 // The intended behavior is that Flash is advertised only if a Flash embed |
209 // only if a Flash embed hosted on the same origin as the main frame origin | 208 // hosted on the same origin as the main frame origin is allowed to run. |
210 // is allowed to run. | |
211 bool is_managed = false; | 209 bool is_managed = false; |
212 HostContentSettingsMap* settings_map = | 210 HostContentSettingsMap* settings_map = |
213 context_info_it->second->host_content_settings_map.get(); | 211 context_info_it->second->host_content_settings_map.get(); |
214 ContentSetting flash_setting = PluginUtils::GetFlashPluginContentSetting( | 212 ContentSetting flash_setting = PluginUtils::GetFlashPluginContentSetting( |
215 settings_map, main_url, plugin_content_url, &is_managed); | 213 settings_map, main_frame_origin, plugin_content_url, &is_managed); |
216 flash_setting = PluginsFieldTrial::EffectiveContentSetting( | 214 flash_setting = PluginsFieldTrial::EffectiveContentSetting( |
217 CONTENT_SETTINGS_TYPE_PLUGINS, flash_setting); | 215 CONTENT_SETTINGS_TYPE_PLUGINS, flash_setting); |
218 if (flash_setting == CONTENT_SETTING_ALLOW) | 216 if (flash_setting == CONTENT_SETTING_ALLOW) |
219 return true; | 217 return true; |
220 else if (flash_setting == CONTENT_SETTING_BLOCK) | 218 else if (flash_setting == CONTENT_SETTING_BLOCK) |
221 return false; | 219 return false; |
222 | 220 |
223 // The content setting is neither ALLOW or BLOCK. Check whether the site | 221 // The content setting is neither ALLOW or BLOCK. Check whether the site |
224 // meets the engagement cutoff for making Flash available without a prompt. | 222 // meets the engagement cutoff for making Flash available without a prompt. |
225 // This should only happen if the setting isn't being enforced by an | 223 // This should only happen if the setting isn't being enforced by an |
226 // enterprise policy. | 224 // enterprise policy. |
227 if (is_managed || | 225 if (is_managed || |
228 SiteEngagementService::GetScoreFromSettings(settings_map, main_url) < | 226 SiteEngagementService::GetScoreFromSettings( |
227 settings_map, GURL(main_frame_origin.Serialize())) < | |
nasko
2016/10/05 21:14:31
main_frame_origin.GetURL()
tommycli
2016/10/05 21:41:22
Done. I was wondering how I missed that method, bu
| |
229 PluginsFieldTrial::GetSiteEngagementThresholdForFlash()) { | 228 PluginsFieldTrial::GetSiteEngagementThresholdForFlash()) { |
230 return false; | 229 return false; |
231 } | 230 } |
232 } | 231 } |
233 | 232 |
234 return true; | 233 return true; |
235 } | 234 } |
236 | 235 |
237 bool ChromePluginServiceFilter::CanLoadPlugin(int render_process_id, | 236 bool ChromePluginServiceFilter::CanLoadPlugin(int render_process_id, |
238 const base::FilePath& path) { | 237 const base::FilePath& path) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 | 296 |
298 const ChromePluginServiceFilter::ProcessDetails* | 297 const ChromePluginServiceFilter::ProcessDetails* |
299 ChromePluginServiceFilter::GetProcess( | 298 ChromePluginServiceFilter::GetProcess( |
300 int render_process_id) const { | 299 int render_process_id) const { |
301 std::map<int, ProcessDetails>::const_iterator it = | 300 std::map<int, ProcessDetails>::const_iterator it = |
302 plugin_details_.find(render_process_id); | 301 plugin_details_.find(render_process_id); |
303 if (it == plugin_details_.end()) | 302 if (it == plugin_details_.end()) |
304 return NULL; | 303 return NULL; |
305 return &it->second; | 304 return &it->second; |
306 } | 305 } |
OLD | NEW |