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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 PpapiPluginProcessHost* PluginService::FindOrStartPpapiPluginProcess( | 233 PpapiPluginProcessHost* PluginService::FindOrStartPpapiPluginProcess( |
234 const FilePath& plugin_path, | 234 const FilePath& plugin_path, |
235 PpapiPluginProcessHost::Client* client) { | 235 PpapiPluginProcessHost::Client* client) { |
236 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 236 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
237 | 237 |
238 PpapiPluginProcessHost* plugin_host = FindPpapiPluginProcess(plugin_path); | 238 PpapiPluginProcessHost* plugin_host = FindPpapiPluginProcess(plugin_path); |
239 if (plugin_host) | 239 if (plugin_host) |
240 return plugin_host; | 240 return plugin_host; |
241 | 241 |
242 // Validate that the plugin is actually registered. | 242 // Validate that the plugin is actually registered. |
243 PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path); | 243 const webkit::ppapi::PluginInfo* info = |
| 244 GetRegisteredPpapiPluginInfo(plugin_path); |
244 if (!info) | 245 if (!info) |
245 return NULL; | 246 return NULL; |
246 | 247 |
247 // This plugin isn't loaded by any plugin process, so create a new process. | 248 // This plugin isn't loaded by any plugin process, so create a new process. |
248 scoped_ptr<PpapiPluginProcessHost> new_host(new PpapiPluginProcessHost( | 249 scoped_ptr<PpapiPluginProcessHost> new_host(new PpapiPluginProcessHost( |
249 client->GetResourceContext()->host_resolver())); | 250 client->GetResourceContext()->host_resolver())); |
250 if (!new_host->Init(*info)) { | 251 if (!new_host->Init(*info)) { |
251 NOTREACHED(); // Init is not expected to fail. | 252 NOTREACHED(); // Init is not expected to fail. |
252 return NULL; | 253 return NULL; |
253 } | 254 } |
254 return new_host.release(); | 255 return new_host.release(); |
255 } | 256 } |
256 | 257 |
257 PpapiBrokerProcessHost* PluginService::FindOrStartPpapiBrokerProcess( | 258 PpapiBrokerProcessHost* PluginService::FindOrStartPpapiBrokerProcess( |
258 const FilePath& plugin_path) { | 259 const FilePath& plugin_path) { |
259 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 260 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
260 | 261 |
261 PpapiBrokerProcessHost* plugin_host = FindPpapiBrokerProcess(plugin_path); | 262 PpapiBrokerProcessHost* plugin_host = FindPpapiBrokerProcess(plugin_path); |
262 if (plugin_host) | 263 if (plugin_host) |
263 return plugin_host; | 264 return plugin_host; |
264 | 265 |
265 // Validate that the plugin is actually registered. | 266 // Validate that the plugin is actually registered. |
266 PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path); | 267 const webkit::ppapi::PluginInfo* info = |
| 268 GetRegisteredPpapiPluginInfo(plugin_path); |
267 if (!info) | 269 if (!info) |
268 return NULL; | 270 return NULL; |
269 | 271 |
270 // TODO(ddorwin): Uncomment once out of process is supported. | 272 // TODO(ddorwin): Uncomment once out of process is supported. |
271 // DCHECK(info->is_out_of_process); | 273 // DCHECK(info->is_out_of_process); |
272 | 274 |
273 // This broker isn't loaded by any broker process, so create a new process. | 275 // This broker isn't loaded by any broker process, so create a new process. |
274 scoped_ptr<PpapiBrokerProcessHost> new_host( | 276 scoped_ptr<PpapiBrokerProcessHost> new_host( |
275 new PpapiBrokerProcessHost); | 277 new PpapiBrokerProcessHost); |
276 if (!new_host->Init(*info)) { | 278 if (!new_host->Init(*info)) { |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 } | 475 } |
474 | 476 |
475 void PluginService::PurgePluginListCache(bool reload_pages) { | 477 void PluginService::PurgePluginListCache(bool reload_pages) { |
476 for (RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator(); | 478 for (RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator(); |
477 !it.IsAtEnd(); it.Advance()) { | 479 !it.IsAtEnd(); it.Advance()) { |
478 it.GetCurrentValue()->Send(new ViewMsg_PurgePluginListCache(reload_pages)); | 480 it.GetCurrentValue()->Send(new ViewMsg_PurgePluginListCache(reload_pages)); |
479 } | 481 } |
480 } | 482 } |
481 | 483 |
482 void PluginService::RegisterPepperPlugins() { | 484 void PluginService::RegisterPepperPlugins() { |
483 // TODO(abarth): It seems like the PepperPluginRegistry should do this work. | |
484 PepperPluginRegistry::ComputeList(&ppapi_plugins_); | 485 PepperPluginRegistry::ComputeList(&ppapi_plugins_); |
| 486 ppapi_plugins_.RegisterAll(); |
| 487 /*webkit::ppapi::PluginRegistry::ComputeList(&ppapi_plugins_); |
485 for (size_t i = 0; i < ppapi_plugins_.size(); ++i) { | 488 for (size_t i = 0; i < ppapi_plugins_.size(); ++i) { |
486 webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin( | 489 webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin( |
487 ppapi_plugins_[i].ToWebPluginInfo()); | 490 ppapi_plugins_[i].ToWebPluginInfo()); |
488 } | 491 }*/ |
489 } | 492 } |
490 | 493 |
491 // There should generally be very few plugins so a brute-force search is fine. | 494 // There should generally be very few plugins so a brute-force search is fine. |
492 PepperPluginInfo* PluginService::GetRegisteredPpapiPluginInfo( | 495 const webkit::ppapi::PluginInfo* PluginService::GetRegisteredPpapiPluginInfo( |
493 const FilePath& plugin_path) { | 496 const FilePath& plugin_path) { |
494 PepperPluginInfo* info = NULL; | 497 return ppapi_plugins_.GetInfoForPlugin(plugin_path); |
495 for (size_t i = 0; i < ppapi_plugins_.size(); i++) { | |
496 if (ppapi_plugins_[i].path == plugin_path) { | |
497 info = &ppapi_plugins_[i]; | |
498 break; | |
499 } | |
500 } | |
501 if (info) | |
502 return info; | |
503 // We did not find the plugin in our list. But wait! the plugin can also | |
504 // be a latecomer, as it happens with pepper flash. This information | |
505 // can be obtained from the PluginList singleton and we can use it to | |
506 // construct it and add it to the list. This same deal needs to be done | |
507 // in the renderer side in PepperPluginRegistry. | |
508 webkit::WebPluginInfo webplugin_info; | |
509 if (!webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( | |
510 plugin_path, &webplugin_info)) | |
511 return NULL; | |
512 PepperPluginInfo new_pepper_info; | |
513 if (!MakePepperPluginInfo(webplugin_info, &new_pepper_info)) | |
514 return NULL; | |
515 ppapi_plugins_.push_back(new_pepper_info); | |
516 return &ppapi_plugins_[ppapi_plugins_.size() - 1]; | |
517 } | 498 } |
518 | 499 |
519 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 500 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
520 // static | 501 // static |
521 void PluginService::RegisterFilePathWatcher( | 502 void PluginService::RegisterFilePathWatcher( |
522 FilePathWatcher *watcher, | 503 FilePathWatcher *watcher, |
523 const FilePath& path, | 504 const FilePath& path, |
524 FilePathWatcher::Delegate* delegate) { | 505 FilePathWatcher::Delegate* delegate) { |
525 bool result = watcher->Watch(path, delegate); | 506 bool result = watcher->Watch(path, delegate); |
526 DCHECK(result); | 507 DCHECK(result); |
527 } | 508 } |
528 #endif | 509 #endif |
OLD | NEW |