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/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/common/render_messages.h" | 21 #include "chrome/common/render_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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 web_contents->SendToAllFrames(new ChromeViewMsg_LoadBlockedPlugins( | 167 web_contents->SendToAllFrames(new ChromeViewMsg_LoadBlockedPlugins( |
169 MSG_ROUTING_NONE, identifier)); | 168 MSG_ROUTING_NONE, identifier)); |
170 } | 169 } |
171 } | 170 } |
172 | 171 |
173 bool ChromePluginServiceFilter::IsPluginAvailable( | 172 bool ChromePluginServiceFilter::IsPluginAvailable( |
174 int render_process_id, | 173 int render_process_id, |
175 int render_frame_id, | 174 int render_frame_id, |
176 const void* context, | 175 const void* context, |
177 const GURL& plugin_content_url, | 176 const GURL& plugin_content_url, |
178 const GURL& main_url, | 177 const url::Origin& main_frame_origin, |
179 content::WebPluginInfo* plugin) { | 178 content::WebPluginInfo* plugin) { |
180 base::AutoLock auto_lock(lock_); | 179 base::AutoLock auto_lock(lock_); |
181 const ProcessDetails* details = GetProcess(render_process_id); | 180 const ProcessDetails* details = GetProcess(render_process_id); |
182 | 181 |
183 // Check whether the plugin is overridden. | 182 // Check whether the plugin is overridden. |
184 if (details) { | 183 if (details) { |
185 for (const auto& plugin_override : details->overridden_plugins) { | 184 for (const auto& plugin_override : details->overridden_plugins) { |
186 if (plugin_override.render_frame_id == render_frame_id && | 185 if (plugin_override.render_frame_id == render_frame_id && |
187 (plugin_override.url.is_empty() || | 186 (plugin_override.url.is_empty() || |
188 plugin_override.url == plugin_content_url)) { | 187 plugin_override.url == plugin_content_url)) { |
(...skipping 16 matching lines...) Expand all Loading... |
205 const ContextInfo* context_info = context_info_it->second.get(); | 204 const ContextInfo* context_info = context_info_it->second.get(); |
206 if (!context_info->plugin_prefs.get()->IsPluginEnabled(*plugin)) | 205 if (!context_info->plugin_prefs.get()->IsPluginEnabled(*plugin)) |
207 return false; | 206 return false; |
208 | 207 |
209 // If PreferHtmlOverPlugins is enabled and the plugin is Flash, we do | 208 // If PreferHtmlOverPlugins is enabled and the plugin is Flash, we do |
210 // additional checks. | 209 // additional checks. |
211 if (plugin->name == base::ASCIIToUTF16(content::kFlashPluginName) && | 210 if (plugin->name == base::ASCIIToUTF16(content::kFlashPluginName) && |
212 base::FeatureList::IsEnabled(features::kPreferHtmlOverPlugins)) { | 211 base::FeatureList::IsEnabled(features::kPreferHtmlOverPlugins)) { |
213 // Check the content setting first, and always respect the ALLOW or BLOCK | 212 // Check the content setting first, and always respect the ALLOW or BLOCK |
214 // state. When IsPluginAvailable() is called to check whether a plugin | 213 // state. When IsPluginAvailable() is called to check whether a plugin |
215 // should be advertised, |plugin_content_url| has the same value of | 214 // should be advertised, |url| has the same origin as |main_frame_origin|. |
216 // |main_url| (i.e. the main frame origin). The intended behavior is that | 215 // The intended behavior is that Flash is advertised only if a Flash embed |
217 // Flash is advertised only if a Flash embed hosted on the same origin as | 216 // hosted on the same origin as the main frame origin is allowed to run. |
218 // the main frame origin is allowed to run. | |
219 bool is_managed = false; | 217 bool is_managed = false; |
220 HostContentSettingsMap* settings_map = | 218 HostContentSettingsMap* settings_map = |
221 context_info_it->second->host_content_settings_map.get(); | 219 context_info_it->second->host_content_settings_map.get(); |
222 ContentSetting flash_setting = PluginUtils::GetFlashPluginContentSetting( | 220 ContentSetting flash_setting = PluginUtils::GetFlashPluginContentSetting( |
223 settings_map, main_url, plugin_content_url, &is_managed); | 221 settings_map, main_frame_origin, plugin_content_url, &is_managed); |
224 flash_setting = PluginsFieldTrial::EffectiveContentSetting( | 222 flash_setting = PluginsFieldTrial::EffectiveContentSetting( |
225 CONTENT_SETTINGS_TYPE_PLUGINS, flash_setting); | 223 CONTENT_SETTINGS_TYPE_PLUGINS, flash_setting); |
226 double engagement = | 224 double engagement = SiteEngagementService::GetScoreFromSettings( |
227 SiteEngagementService::GetScoreFromSettings(settings_map, main_url); | 225 settings_map, main_frame_origin.GetURL()); |
228 | 226 |
229 if (flash_setting == CONTENT_SETTING_ALLOW) { | 227 if (flash_setting == CONTENT_SETTING_ALLOW) { |
230 UMA_HISTOGRAM_COUNTS_100(kEngagementSettingAllowedHistogram, engagement); | 228 UMA_HISTOGRAM_COUNTS_100(kEngagementSettingAllowedHistogram, engagement); |
231 return true; | 229 return true; |
232 } | 230 } |
233 | 231 |
234 if (flash_setting == CONTENT_SETTING_BLOCK) { | 232 if (flash_setting == CONTENT_SETTING_BLOCK) { |
235 UMA_HISTOGRAM_COUNTS_100(kEngagementSettingBlockedHistogram, engagement); | 233 UMA_HISTOGRAM_COUNTS_100(kEngagementSettingBlockedHistogram, engagement); |
236 return false; | 234 return false; |
237 } | 235 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 | 312 |
315 const ChromePluginServiceFilter::ProcessDetails* | 313 const ChromePluginServiceFilter::ProcessDetails* |
316 ChromePluginServiceFilter::GetProcess( | 314 ChromePluginServiceFilter::GetProcess( |
317 int render_process_id) const { | 315 int render_process_id) const { |
318 std::map<int, ProcessDetails>::const_iterator it = | 316 std::map<int, ProcessDetails>::const_iterator it = |
319 plugin_details_.find(render_process_id); | 317 plugin_details_.find(render_process_id); |
320 if (it == plugin_details_.end()) | 318 if (it == plugin_details_.end()) |
321 return NULL; | 319 return NULL; |
322 return &it->second; | 320 return &it->second; |
323 } | 321 } |
OLD | NEW |