| 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_url, |
| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 if (flash_setting == CONTENT_SETTING_ALLOW) | 217 if (flash_setting == CONTENT_SETTING_ALLOW) |
| 219 return true; | 218 return true; |
| 220 else if (flash_setting == CONTENT_SETTING_BLOCK) | 219 else if (flash_setting == CONTENT_SETTING_BLOCK) |
| 221 return false; | 220 return false; |
| 222 | 221 |
| 223 // The content setting is neither ALLOW or BLOCK. Check whether the site | 222 // The content setting is neither ALLOW or BLOCK. Check whether the site |
| 224 // meets the engagement cutoff for making Flash available without a prompt. | 223 // 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 | 224 // This should only happen if the setting isn't being enforced by an |
| 226 // enterprise policy. | 225 // enterprise policy. |
| 227 if (is_managed || | 226 if (is_managed || |
| 228 SiteEngagementService::GetScoreFromSettings(settings_map, main_url) < | 227 SiteEngagementService::GetScoreFromSettings( |
| 228 settings_map, GURL(main_url.Serialize())) < |
| 229 PluginsFieldTrial::GetSiteEngagementThresholdForFlash()) { | 229 PluginsFieldTrial::GetSiteEngagementThresholdForFlash()) { |
| 230 return false; | 230 return false; |
| 231 } | 231 } |
| 232 } | 232 } |
| 233 | 233 |
| 234 return true; | 234 return true; |
| 235 } | 235 } |
| 236 | 236 |
| 237 bool ChromePluginServiceFilter::CanLoadPlugin(int render_process_id, | 237 bool ChromePluginServiceFilter::CanLoadPlugin(int render_process_id, |
| 238 const base::FilePath& path) { | 238 const base::FilePath& path) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 | 297 |
| 298 const ChromePluginServiceFilter::ProcessDetails* | 298 const ChromePluginServiceFilter::ProcessDetails* |
| 299 ChromePluginServiceFilter::GetProcess( | 299 ChromePluginServiceFilter::GetProcess( |
| 300 int render_process_id) const { | 300 int render_process_id) const { |
| 301 std::map<int, ProcessDetails>::const_iterator it = | 301 std::map<int, ProcessDetails>::const_iterator it = |
| 302 plugin_details_.find(render_process_id); | 302 plugin_details_.find(render_process_id); |
| 303 if (it == plugin_details_.end()) | 303 if (it == plugin_details_.end()) |
| 304 return NULL; | 304 return NULL; |
| 305 return &it->second; | 305 return &it->second; |
| 306 } | 306 } |
| OLD | NEW |