OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/plugin_service.h" | 5 #include "content/browser/plugin_service.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
18 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/common/default_plugin.h" | 20 #include "chrome/common/default_plugin.h" |
21 #include "content/browser/browser_thread.h" | 21 #include "content/browser/browser_thread.h" |
22 #include "content/browser/ppapi_plugin_process_host.h" | 22 #include "content/browser/ppapi_plugin_process_host.h" |
23 #include "content/browser/renderer_host/render_process_host.h" | 23 #include "content/browser/renderer_host/render_process_host.h" |
24 #include "content/browser/renderer_host/render_view_host.h" | 24 #include "content/browser/renderer_host/render_view_host.h" |
| 25 #include "content/browser/resource_context.h" |
25 #include "content/common/notification_service.h" | 26 #include "content/common/notification_service.h" |
26 #include "content/common/notification_type.h" | 27 #include "content/common/notification_type.h" |
27 #include "content/common/pepper_plugin_registry.h" | 28 #include "content/common/pepper_plugin_registry.h" |
28 #include "content/common/plugin_messages.h" | 29 #include "content/common/plugin_messages.h" |
29 #include "content/common/view_messages.h" | 30 #include "content/common/view_messages.h" |
30 #include "webkit/plugins/npapi/plugin_constants_win.h" | 31 #include "webkit/plugins/npapi/plugin_constants_win.h" |
31 #include "webkit/plugins/npapi/plugin_list.h" | 32 #include "webkit/plugins/npapi/plugin_list.h" |
32 #include "webkit/plugins/npapi/webplugininfo.h" | 33 #include "webkit/plugins/npapi/webplugininfo.h" |
33 | 34 |
34 #if defined(OS_LINUX) | 35 #if defined(OS_LINUX) |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 // This plugin isn't loaded by any plugin process, so create a new process. | 243 // This plugin isn't loaded by any plugin process, so create a new process. |
243 scoped_ptr<PluginProcessHost> new_host(new PluginProcessHost()); | 244 scoped_ptr<PluginProcessHost> new_host(new PluginProcessHost()); |
244 if (!new_host->Init(info, ui_locale_)) { | 245 if (!new_host->Init(info, ui_locale_)) { |
245 NOTREACHED(); // Init is not expected to fail. | 246 NOTREACHED(); // Init is not expected to fail. |
246 return NULL; | 247 return NULL; |
247 } | 248 } |
248 return new_host.release(); | 249 return new_host.release(); |
249 } | 250 } |
250 | 251 |
251 PpapiPluginProcessHost* PluginService::FindOrStartPpapiPluginProcess( | 252 PpapiPluginProcessHost* PluginService::FindOrStartPpapiPluginProcess( |
252 const FilePath& plugin_path) { | 253 const FilePath& plugin_path, |
| 254 PpapiPluginProcessHost::Client* client) { |
253 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 255 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
254 | 256 |
255 PpapiPluginProcessHost* plugin_host = FindPpapiPluginProcess(plugin_path); | 257 PpapiPluginProcessHost* plugin_host = FindPpapiPluginProcess(plugin_path); |
256 if (plugin_host) | 258 if (plugin_host) |
257 return plugin_host; | 259 return plugin_host; |
258 | 260 |
259 // Validate that the plugin is actually registered. | 261 // Validate that the plugin is actually registered. |
260 PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path); | 262 PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path); |
261 if (!info) | 263 if (!info) |
262 return NULL; | 264 return NULL; |
263 | 265 |
264 // This plugin isn't loaded by any plugin process, so create a new process. | 266 // This plugin isn't loaded by any plugin process, so create a new process. |
265 scoped_ptr<PpapiPluginProcessHost> new_host(new PpapiPluginProcessHost); | 267 scoped_ptr<PpapiPluginProcessHost> new_host(new PpapiPluginProcessHost( |
| 268 client->GetResourceContext()->host_resolver())); |
266 if (!new_host->Init(*info)) { | 269 if (!new_host->Init(*info)) { |
267 NOTREACHED(); // Init is not expected to fail. | 270 NOTREACHED(); // Init is not expected to fail. |
268 return NULL; | 271 return NULL; |
269 } | 272 } |
270 return new_host.release(); | 273 return new_host.release(); |
271 } | 274 } |
272 | 275 |
273 PpapiBrokerProcessHost* PluginService::FindOrStartPpapiBrokerProcess( | 276 PpapiBrokerProcessHost* PluginService::FindOrStartPpapiBrokerProcess( |
274 const FilePath& plugin_path) { | 277 const FilePath& plugin_path) { |
275 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 278 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 BrowserThread::PostTask( | 310 BrowserThread::PostTask( |
308 BrowserThread::FILE, FROM_HERE, | 311 BrowserThread::FILE, FROM_HERE, |
309 NewRunnableMethod( | 312 NewRunnableMethod( |
310 this, &PluginService::GetAllowedPluginForOpenChannelToPlugin, | 313 this, &PluginService::GetAllowedPluginForOpenChannelToPlugin, |
311 render_process_id, render_view_id, url, mime_type, client)); | 314 render_process_id, render_view_id, url, mime_type, client)); |
312 } | 315 } |
313 | 316 |
314 void PluginService::OpenChannelToPpapiPlugin( | 317 void PluginService::OpenChannelToPpapiPlugin( |
315 const FilePath& path, | 318 const FilePath& path, |
316 PpapiPluginProcessHost::Client* client) { | 319 PpapiPluginProcessHost::Client* client) { |
317 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiPluginProcess(path); | 320 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiPluginProcess( |
| 321 path, client); |
318 if (plugin_host) | 322 if (plugin_host) |
319 plugin_host->OpenChannelToPlugin(client); | 323 plugin_host->OpenChannelToPlugin(client); |
320 else // Send error. | 324 else // Send error. |
321 client->OnChannelOpened(base::kNullProcessHandle, IPC::ChannelHandle()); | 325 client->OnChannelOpened(base::kNullProcessHandle, IPC::ChannelHandle()); |
322 } | 326 } |
323 | 327 |
324 void PluginService::OpenChannelToPpapiBroker( | 328 void PluginService::OpenChannelToPpapiBroker( |
325 const FilePath& path, | 329 const FilePath& path, |
326 PpapiBrokerProcessHost::Client* client) { | 330 PpapiBrokerProcessHost::Client* client) { |
327 PpapiBrokerProcessHost* plugin_host = FindOrStartPpapiBrokerProcess(path); | 331 PpapiBrokerProcessHost* plugin_host = FindOrStartPpapiBrokerProcess(path); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 #if defined(OS_LINUX) | 510 #if defined(OS_LINUX) |
507 // static | 511 // static |
508 void PluginService::RegisterFilePathWatcher( | 512 void PluginService::RegisterFilePathWatcher( |
509 FilePathWatcher *watcher, | 513 FilePathWatcher *watcher, |
510 const FilePath& path, | 514 const FilePath& path, |
511 FilePathWatcher::Delegate* delegate) { | 515 FilePathWatcher::Delegate* delegate) { |
512 bool result = watcher->Watch(path, delegate); | 516 bool result = watcher->Watch(path, delegate); |
513 DCHECK(result); | 517 DCHECK(result); |
514 } | 518 } |
515 #endif | 519 #endif |
OLD | NEW |