| 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 13 matching lines...) Expand all Loading... |
| 24 #include "content/common/plugin_messages.h" | 24 #include "content/common/plugin_messages.h" |
| 25 #include "content/common/utility_messages.h" | 25 #include "content/common/utility_messages.h" |
| 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/plugin_service_filter.h" | 29 #include "content/public/browser/plugin_service_filter.h" |
| 30 #include "content/public/browser/resource_context.h" | 30 #include "content/public/browser/resource_context.h" |
| 31 #include "content/public/common/content_switches.h" | 31 #include "content/public/common/content_switches.h" |
| 32 #include "content/public/common/process_type.h" | 32 #include "content/public/common/process_type.h" |
| 33 #include "webkit/plugins/npapi/plugin_constants_win.h" | 33 #include "webkit/plugins/npapi/plugin_constants_win.h" |
| 34 #include "webkit/plugins/npapi/plugin_group.h" | |
| 35 #include "webkit/plugins/npapi/plugin_list.h" | 34 #include "webkit/plugins/npapi/plugin_list.h" |
| 36 #include "webkit/plugins/webplugininfo.h" | 35 #include "webkit/plugins/webplugininfo.h" |
| 37 | 36 |
| 38 #if defined(OS_POSIX) && !defined(OS_OPENBSD) | 37 #if defined(OS_POSIX) && !defined(OS_OPENBSD) |
| 39 using ::base::files::FilePathWatcher; | 38 using ::base::files::FilePathWatcher; |
| 40 #endif | 39 #endif |
| 41 | 40 |
| 42 using content::BrowserThread; | 41 using content::BrowserThread; |
| 43 using content::PluginService; | 42 using content::PluginService; |
| 44 using content::PluginServiceFilter; | 43 using content::PluginServiceFilter; |
| 45 | 44 |
| 46 namespace { | 45 namespace { |
| 47 | 46 |
| 48 // A callback for GetPlugins() that then gets the freshly loaded plugin groups | |
| 49 // and runs the callback for GetPluginGroups(). | |
| 50 static void GetPluginsForGroupsCallback( | |
| 51 const PluginService::GetPluginGroupsCallback& callback, | |
| 52 const std::vector<webkit::WebPluginInfo>& plugins) { | |
| 53 std::vector<webkit::npapi::PluginGroup> groups; | |
| 54 webkit::npapi::PluginList::Singleton()->GetPluginGroups(false, &groups); | |
| 55 callback.Run(groups); | |
| 56 } | |
| 57 | |
| 58 // Callback set on the PluginList to assert that plugin loading happens on the | 47 // Callback set on the PluginList to assert that plugin loading happens on the |
| 59 // correct thread. | 48 // correct thread. |
| 60 #if defined(OS_WIN) | 49 #if defined(OS_WIN) |
| 61 void WillLoadPluginsCallbackWin( | 50 void WillLoadPluginsCallbackWin( |
| 62 base::SequencedWorkerPool::SequenceToken token) { | 51 base::SequencedWorkerPool::SequenceToken token) { |
| 63 CHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( | 52 CHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( |
| 64 token)); | 53 token)); |
| 65 } | 54 } |
| 66 #else | 55 #else |
| 67 void WillLoadPluginsCallbackPosix() { | 56 void WillLoadPluginsCallbackPosix() { |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 plugin_loader_ = new PluginLoaderPosix; | 520 plugin_loader_ = new PluginLoaderPosix; |
| 532 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 521 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 533 base::Bind(&PluginLoaderPosix::LoadPlugins, plugin_loader_, | 522 base::Bind(&PluginLoaderPosix::LoadPlugins, plugin_loader_, |
| 534 target_loop, callback)); | 523 target_loop, callback)); |
| 535 } | 524 } |
| 536 #else | 525 #else |
| 537 #error Not implemented | 526 #error Not implemented |
| 538 #endif | 527 #endif |
| 539 } | 528 } |
| 540 | 529 |
| 541 void PluginServiceImpl::GetPluginGroups( | |
| 542 const GetPluginGroupsCallback& callback) { | |
| 543 GetPlugins(base::Bind(&GetPluginsForGroupsCallback, callback)); | |
| 544 } | |
| 545 | |
| 546 #if defined(OS_WIN) | 530 #if defined(OS_WIN) |
| 547 void PluginServiceImpl::GetPluginsInternal( | 531 void PluginServiceImpl::GetPluginsInternal( |
| 548 base::MessageLoopProxy* target_loop, | 532 base::MessageLoopProxy* target_loop, |
| 549 const PluginService::GetPluginsCallback& callback) { | 533 const PluginService::GetPluginsCallback& callback) { |
| 550 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( | 534 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( |
| 551 plugin_list_token_)); | 535 plugin_list_token_)); |
| 552 | 536 |
| 553 std::vector<webkit::WebPluginInfo> plugins; | 537 std::vector<webkit::WebPluginInfo> plugins; |
| 554 plugin_list_->GetPlugins(&plugins); | 538 plugin_list_->GetPlugins(&plugins); |
| 555 | 539 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 base::Bind(&NotifyPluginsOfActivation)); | 693 base::Bind(&NotifyPluginsOfActivation)); |
| 710 } | 694 } |
| 711 #endif | 695 #endif |
| 712 | 696 |
| 713 void PluginServiceImpl::RegisterInternalPlugin( | 697 void PluginServiceImpl::RegisterInternalPlugin( |
| 714 const webkit::WebPluginInfo& info, | 698 const webkit::WebPluginInfo& info, |
| 715 bool add_at_beginning) { | 699 bool add_at_beginning) { |
| 716 plugin_list_->RegisterInternalPlugin(info, add_at_beginning); | 700 plugin_list_->RegisterInternalPlugin(info, add_at_beginning); |
| 717 } | 701 } |
| 718 | 702 |
| 719 string16 PluginServiceImpl::GetPluginGroupName(const std::string& plugin_name) { | |
| 720 return plugin_list_->GetPluginGroupName(plugin_name); | |
| 721 } | |
| 722 | |
| 723 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() { | 703 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() { |
| 724 return plugin_list_; | 704 return plugin_list_; |
| 725 } | 705 } |
| OLD | NEW |