Chromium Code Reviews| 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/bind.h" | |
| 7 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 8 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 9 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/message_loop.h" | |
| 12 #include "base/message_loop_proxy.h" | |
| 10 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 11 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 12 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
| 13 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
| 14 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 15 #include "base/values.h" | 18 #include "base/values.h" |
| 16 #include "content/browser/browser_thread.h" | 19 #include "content/browser/browser_thread.h" |
| 17 #include "content/browser/content_browser_client.h" | 20 #include "content/browser/content_browser_client.h" |
| 18 #include "content/browser/plugin_service_filter.h" | 21 #include "content/browser/plugin_service_filter.h" |
| 19 #include "content/browser/ppapi_plugin_process_host.h" | 22 #include "content/browser/ppapi_plugin_process_host.h" |
| 20 #include "content/browser/renderer_host/render_process_host.h" | 23 #include "content/browser/renderer_host/render_process_host.h" |
| 21 #include "content/browser/renderer_host/render_view_host.h" | 24 #include "content/browser/renderer_host/render_view_host.h" |
| 22 #include "content/browser/resource_context.h" | 25 #include "content/browser/resource_context.h" |
| 23 #include "content/common/content_notification_types.h" | 26 #include "content/common/content_notification_types.h" |
| 24 #include "content/common/content_switches.h" | 27 #include "content/common/content_switches.h" |
| 25 #include "content/common/notification_service.h" | 28 #include "content/common/notification_service.h" |
| 26 #include "content/common/pepper_plugin_registry.h" | 29 #include "content/common/pepper_plugin_registry.h" |
| 27 #include "content/common/plugin_messages.h" | 30 #include "content/common/plugin_messages.h" |
| 28 #include "content/common/view_messages.h" | 31 #include "content/common/view_messages.h" |
| 29 #include "webkit/plugins/npapi/plugin_constants_win.h" | 32 #include "webkit/plugins/npapi/plugin_constants_win.h" |
| 33 #include "webkit/plugins/npapi/plugin_group.h" | |
| 30 #include "webkit/plugins/npapi/plugin_list.h" | 34 #include "webkit/plugins/npapi/plugin_list.h" |
| 31 #include "webkit/plugins/webplugininfo.h" | 35 #include "webkit/plugins/webplugininfo.h" |
| 32 | 36 |
| 33 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 37 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 34 using ::base::files::FilePathWatcher; | 38 using ::base::files::FilePathWatcher; |
| 35 #endif | 39 #endif |
| 36 | 40 |
| 37 using content::PluginServiceFilter; | 41 using content::PluginServiceFilter; |
| 38 | 42 |
| 39 #if defined(OS_MACOSX) | 43 #if defined(OS_MACOSX) |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 410 &plugins[i])) { | 414 &plugins[i])) { |
| 411 *info = plugins[i]; | 415 *info = plugins[i]; |
| 412 if (actual_mime_type) | 416 if (actual_mime_type) |
| 413 *actual_mime_type = mime_types[i]; | 417 *actual_mime_type = mime_types[i]; |
| 414 return true; | 418 return true; |
| 415 } | 419 } |
| 416 } | 420 } |
| 417 return false; | 421 return false; |
| 418 } | 422 } |
| 419 | 423 |
| 420 void PluginService::GetPlugins( | 424 void PluginService::LoadPluginList( |
| 421 const content::ResourceContext& context, | 425 bool refresh, |
| 422 std::vector<webkit::WebPluginInfo>* plugins) { | 426 const base::Closure& completion_callback) { |
| 423 // GetPlugins may need to load the plugins, so we need to be | 427 if (refresh) |
| 424 // on the FILE thread. | 428 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); |
| 429 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | |
| 430 base::Bind(&PluginService::GetPluginsInternal, base::Unretained(this), | |
| 431 MessageLoop::current()->message_loop_proxy(), | |
| 432 completion_callback)); | |
| 433 } | |
| 434 | |
| 435 void PluginService::GetPlugins(std::vector<webkit::WebPluginInfo>* plugins) { | |
| 436 webkit::npapi::PluginList::Singleton()->GetCachedPlugins(plugins); | |
| 437 } | |
| 438 | |
| 439 void PluginService::GetPluginGroups( | |
| 440 std::vector<webkit::npapi::PluginGroup>* groups) { | |
| 441 webkit::npapi::PluginList::Singleton()->GetPluginGroups(false, groups); | |
| 442 } | |
| 443 | |
| 444 void PluginService::GetPluginsInternal( | |
| 445 base::MessageLoopProxy* target_loop, | |
| 446 const base::Closure& completion_callback) { | |
| 425 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 447 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 426 webkit::npapi::PluginList* plugin_list = | |
| 427 webkit::npapi::PluginList::Singleton(); | |
| 428 std::vector<webkit::WebPluginInfo> all_plugins; | |
| 429 plugin_list->GetPlugins(&all_plugins); | |
| 430 | 448 |
| 431 int child_process_id = -1; | 449 std::vector<webkit::WebPluginInfo> plugins; |
| 432 int routing_id = MSG_ROUTING_NONE; | 450 webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins); |
|
Bernhard Bauer
2011/09/21 22:47:05
Would it be bad to make PluginList::LoadPlugins()
| |
| 433 for (size_t i = 0; i < all_plugins.size(); ++i) { | 451 |
| 434 if (!filter_ || filter_->ShouldUsePlugin(child_process_id, | 452 target_loop->PostTask(FROM_HERE, completion_callback); |
| 435 routing_id, | |
| 436 &context, | |
| 437 GURL(), | |
| 438 GURL(), | |
| 439 &all_plugins[i])) { | |
| 440 plugins->push_back(all_plugins[i]); | |
| 441 } | |
| 442 } | |
| 443 } | 453 } |
| 444 | 454 |
| 445 void PluginService::OnWaitableEventSignaled( | 455 void PluginService::OnWaitableEventSignaled( |
| 446 base::WaitableEvent* waitable_event) { | 456 base::WaitableEvent* waitable_event) { |
| 447 #if defined(OS_WIN) | 457 #if defined(OS_WIN) |
| 448 if (waitable_event == hkcu_event_.get()) { | 458 if (waitable_event == hkcu_event_.get()) { |
| 449 hkcu_key_.StartWatching(); | 459 hkcu_key_.StartWatching(); |
| 450 } else { | 460 } else { |
| 451 hklm_key_.StartWatching(); | 461 hklm_key_.StartWatching(); |
| 452 } | 462 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 519 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 529 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 520 // static | 530 // static |
| 521 void PluginService::RegisterFilePathWatcher( | 531 void PluginService::RegisterFilePathWatcher( |
| 522 FilePathWatcher *watcher, | 532 FilePathWatcher *watcher, |
| 523 const FilePath& path, | 533 const FilePath& path, |
| 524 FilePathWatcher::Delegate* delegate) { | 534 FilePathWatcher::Delegate* delegate) { |
| 525 bool result = watcher->Watch(path, delegate); | 535 bool result = watcher->Watch(path, delegate); |
| 526 DCHECK(result); | 536 DCHECK(result); |
| 527 } | 537 } |
| 528 #endif | 538 #endif |
| OLD | NEW |