| 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 "content/browser/plugin_service_impl.h" | 5 #include "content/browser/plugin_service_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "content/common/view_messages.h" | 26 #include "content/common/view_messages.h" |
| 27 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 28 #include "content/public/browser/content_browser_client.h" | 28 #include "content/public/browser/content_browser_client.h" |
| 29 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
| 30 #include "content/public/browser/notification_types.h" | 30 #include "content/public/browser/notification_types.h" |
| 31 #include "content/public/browser/plugin_service_filter.h" | 31 #include "content/public/browser/plugin_service_filter.h" |
| 32 #include "content/public/browser/resource_context.h" | 32 #include "content/public/browser/resource_context.h" |
| 33 #include "content/public/common/content_switches.h" | 33 #include "content/public/common/content_switches.h" |
| 34 #include "content/public/common/process_type.h" | 34 #include "content/public/common/process_type.h" |
| 35 #include "webkit/plugins/npapi/plugin_constants_win.h" | 35 #include "webkit/plugins/npapi/plugin_constants_win.h" |
| 36 #include "webkit/plugins/npapi/plugin_group.h" | |
| 37 #include "webkit/plugins/npapi/plugin_list.h" | 36 #include "webkit/plugins/npapi/plugin_list.h" |
| 38 #include "webkit/plugins/webplugininfo.h" | 37 #include "webkit/plugins/webplugininfo.h" |
| 39 | 38 |
| 40 #if defined(OS_POSIX) && !defined(OS_OPENBSD) | 39 #if defined(OS_POSIX) && !defined(OS_OPENBSD) |
| 41 using ::base::files::FilePathWatcher; | 40 using ::base::files::FilePathWatcher; |
| 42 #endif | 41 #endif |
| 43 | 42 |
| 44 using content::BrowserThread; | 43 using content::BrowserThread; |
| 45 using content::PluginService; | 44 using content::PluginService; |
| 46 using content::PluginServiceFilter; | 45 using content::PluginServiceFilter; |
| 47 | 46 |
| 48 namespace { | 47 namespace { |
| 49 | 48 |
| 50 // A callback for GetPlugins() that then gets the freshly loaded plugin groups | |
| 51 // and runs the callback for GetPluginGroups(). | |
| 52 static void GetPluginsForGroupsCallback( | |
| 53 const PluginService::GetPluginGroupsCallback& callback, | |
| 54 const std::vector<webkit::WebPluginInfo>& plugins) { | |
| 55 std::vector<webkit::npapi::PluginGroup> groups; | |
| 56 webkit::npapi::PluginList::Singleton()->GetPluginGroups(false, &groups); | |
| 57 callback.Run(groups); | |
| 58 } | |
| 59 | |
| 60 // Callback set on the PluginList to assert that plugin loading happens on the | 49 // Callback set on the PluginList to assert that plugin loading happens on the |
| 61 // correct thread. | 50 // correct thread. |
| 62 #if defined(OS_WIN) | 51 #if defined(OS_WIN) |
| 63 void WillLoadPluginsCallbackWin( | 52 void WillLoadPluginsCallbackWin( |
| 64 base::SequencedWorkerPool::SequenceToken token) { | 53 base::SequencedWorkerPool::SequenceToken token) { |
| 65 CHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( | 54 CHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( |
| 66 token)); | 55 token)); |
| 67 } | 56 } |
| 68 #else | 57 #else |
| 69 void WillLoadPluginsCallbackPosix() { | 58 void WillLoadPluginsCallbackPosix() { |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 plugin_loader_ = new PluginLoaderPosix; | 530 plugin_loader_ = new PluginLoaderPosix; |
| 542 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 531 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 543 base::Bind(&PluginLoaderPosix::LoadPlugins, plugin_loader_, | 532 base::Bind(&PluginLoaderPosix::LoadPlugins, plugin_loader_, |
| 544 target_loop, callback)); | 533 target_loop, callback)); |
| 545 } | 534 } |
| 546 #else | 535 #else |
| 547 #error Not implemented | 536 #error Not implemented |
| 548 #endif | 537 #endif |
| 549 } | 538 } |
| 550 | 539 |
| 551 void PluginServiceImpl::GetPluginGroups( | |
| 552 const GetPluginGroupsCallback& callback) { | |
| 553 GetPlugins(base::Bind(&GetPluginsForGroupsCallback, callback)); | |
| 554 } | |
| 555 | |
| 556 #if defined(OS_WIN) | 540 #if defined(OS_WIN) |
| 557 void PluginServiceImpl::GetPluginsInternal( | 541 void PluginServiceImpl::GetPluginsInternal( |
| 558 base::MessageLoopProxy* target_loop, | 542 base::MessageLoopProxy* target_loop, |
| 559 const PluginService::GetPluginsCallback& callback) { | 543 const PluginService::GetPluginsCallback& callback) { |
| 560 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( | 544 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( |
| 561 plugin_list_token_)); | 545 plugin_list_token_)); |
| 562 | 546 |
| 563 std::vector<webkit::WebPluginInfo> plugins; | 547 std::vector<webkit::WebPluginInfo> plugins; |
| 564 plugin_list_->GetPlugins(&plugins); | 548 plugin_list_->GetPlugins(&plugins); |
| 565 | 549 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 webkit::npapi::PluginList* plugin_list) { | 709 webkit::npapi::PluginList* plugin_list) { |
| 726 plugin_list_ = plugin_list; | 710 plugin_list_ = plugin_list; |
| 727 } | 711 } |
| 728 | 712 |
| 729 void PluginServiceImpl::RegisterInternalPlugin( | 713 void PluginServiceImpl::RegisterInternalPlugin( |
| 730 const webkit::WebPluginInfo& info, | 714 const webkit::WebPluginInfo& info, |
| 731 bool add_at_beginning) { | 715 bool add_at_beginning) { |
| 732 plugin_list_->RegisterInternalPlugin(info, add_at_beginning); | 716 plugin_list_->RegisterInternalPlugin(info, add_at_beginning); |
| 733 } | 717 } |
| 734 | 718 |
| 735 string16 PluginServiceImpl::GetPluginGroupName(const std::string& plugin_name) { | |
| 736 return plugin_list_->GetPluginGroupName(plugin_name); | |
| 737 } | |
| 738 | |
| 739 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() { | 719 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() { |
| 740 return plugin_list_; | 720 return plugin_list_; |
| 741 } | 721 } |
| OLD | NEW |