| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 } | 34 } |
| 35 | 35 |
| 36 // static | 36 // static |
| 37 ChromePluginServiceFilter* ChromePluginServiceFilter::GetInstance() { | 37 ChromePluginServiceFilter* ChromePluginServiceFilter::GetInstance() { |
| 38 return Singleton<ChromePluginServiceFilter>::get(); | 38 return Singleton<ChromePluginServiceFilter>::get(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void ChromePluginServiceFilter::RegisterResourceContext( | 41 void ChromePluginServiceFilter::RegisterResourceContext( |
| 42 PluginPrefs* plugin_prefs, | 42 PluginPrefs* plugin_prefs, |
| 43 const void* context) { | 43 const void* context) { |
| 44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 44 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 45 base::AutoLock lock(lock_); | 45 base::AutoLock lock(lock_); |
| 46 resource_context_map_[context] = plugin_prefs; | 46 resource_context_map_[context] = plugin_prefs; |
| 47 } | 47 } |
| 48 | 48 |
| 49 void ChromePluginServiceFilter::UnregisterResourceContext( | 49 void ChromePluginServiceFilter::UnregisterResourceContext( |
| 50 const void* context) { | 50 const void* context) { |
| 51 base::AutoLock lock(lock_); | 51 base::AutoLock lock(lock_); |
| 52 resource_context_map_.erase(context); | 52 resource_context_map_.erase(context); |
| 53 } | 53 } |
| 54 | 54 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 const base::FilePath& plugin_path) { | 159 const base::FilePath& plugin_path) { |
| 160 base::AutoLock auto_lock(lock_); | 160 base::AutoLock auto_lock(lock_); |
| 161 ProcessDetails* details = GetOrRegisterProcess(render_process_id); | 161 ProcessDetails* details = GetOrRegisterProcess(render_process_id); |
| 162 details->authorized_plugins.insert(plugin_path); | 162 details->authorized_plugins.insert(plugin_path); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void ChromePluginServiceFilter::AuthorizeAllPlugins( | 165 void ChromePluginServiceFilter::AuthorizeAllPlugins( |
| 166 content::WebContents* web_contents, | 166 content::WebContents* web_contents, |
| 167 bool load_blocked, | 167 bool load_blocked, |
| 168 const std::string& identifier) { | 168 const std::string& identifier) { |
| 169 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 169 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 170 web_contents->ForEachFrame(base::Bind(&AuthorizeRenderer)); | 170 web_contents->ForEachFrame(base::Bind(&AuthorizeRenderer)); |
| 171 if (load_blocked) { | 171 if (load_blocked) { |
| 172 web_contents->SendToAllFrames(new ChromeViewMsg_LoadBlockedPlugins( | 172 web_contents->SendToAllFrames(new ChromeViewMsg_LoadBlockedPlugins( |
| 173 MSG_ROUTING_NONE, identifier)); | 173 MSG_ROUTING_NONE, identifier)); |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 | 176 |
| 177 ChromePluginServiceFilter::ChromePluginServiceFilter() { | 177 ChromePluginServiceFilter::ChromePluginServiceFilter() { |
| 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 178 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 179 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 179 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 180 content::NotificationService::AllSources()); | 180 content::NotificationService::AllSources()); |
| 181 registrar_.Add(this, chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, | 181 registrar_.Add(this, chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, |
| 182 content::NotificationService::AllSources()); | 182 content::NotificationService::AllSources()); |
| 183 } | 183 } |
| 184 | 184 |
| 185 ChromePluginServiceFilter::~ChromePluginServiceFilter() { | 185 ChromePluginServiceFilter::~ChromePluginServiceFilter() { |
| 186 } | 186 } |
| 187 | 187 |
| 188 void ChromePluginServiceFilter::Observe( | 188 void ChromePluginServiceFilter::Observe( |
| 189 int type, | 189 int type, |
| 190 const content::NotificationSource& source, | 190 const content::NotificationSource& source, |
| 191 const content::NotificationDetails& details) { | 191 const content::NotificationDetails& details) { |
| 192 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 192 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 193 switch (type) { | 193 switch (type) { |
| 194 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { | 194 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { |
| 195 int render_process_id = | 195 int render_process_id = |
| 196 content::Source<content::RenderProcessHost>(source).ptr()->GetID(); | 196 content::Source<content::RenderProcessHost>(source).ptr()->GetID(); |
| 197 | 197 |
| 198 base::AutoLock auto_lock(lock_); | 198 base::AutoLock auto_lock(lock_); |
| 199 plugin_details_.erase(render_process_id); | 199 plugin_details_.erase(render_process_id); |
| 200 break; | 200 break; |
| 201 } | 201 } |
| 202 case chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED: { | 202 case chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED: { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 236 |
| 237 ChromePluginServiceFilter::OverriddenPlugin::~OverriddenPlugin() { | 237 ChromePluginServiceFilter::OverriddenPlugin::~OverriddenPlugin() { |
| 238 } | 238 } |
| 239 | 239 |
| 240 ChromePluginServiceFilter::ProcessDetails::ProcessDetails() { | 240 ChromePluginServiceFilter::ProcessDetails::ProcessDetails() { |
| 241 } | 241 } |
| 242 | 242 |
| 243 ChromePluginServiceFilter::ProcessDetails::~ProcessDetails() { | 243 ChromePluginServiceFilter::ProcessDetails::~ProcessDetails() { |
| 244 } | 244 } |
| 245 | 245 |
| OLD | NEW |