| 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/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 VLOG(1) << "Watched path changed: " << path.value(); | 108 VLOG(1) << "Watched path changed: " << path.value(); |
| 109 // Make the plugin list update itself | 109 // Make the plugin list update itself |
| 110 PluginList::Singleton()->RefreshPlugins(); | 110 PluginList::Singleton()->RefreshPlugins(); |
| 111 BrowserThread::PostTask( | 111 BrowserThread::PostTask( |
| 112 BrowserThread::UI, FROM_HERE, | 112 BrowserThread::UI, FROM_HERE, |
| 113 base::Bind(&PluginService::PurgePluginListCache, | 113 base::Bind(&PluginService::PurgePluginListCache, |
| 114 static_cast<BrowserContext*>(NULL), false)); | 114 static_cast<BrowserContext*>(NULL), false)); |
| 115 } | 115 } |
| 116 #endif | 116 #endif |
| 117 | 117 |
| 118 void ForwardCallback(base::MessageLoopProxy* target_loop, |
| 119 const PluginService::GetPluginsCallback& callback, |
| 120 const std::vector<WebPluginInfo>& plugins) { |
| 121 target_loop->PostTask(FROM_HERE, base::Bind(callback, plugins)); |
| 122 } |
| 123 |
| 118 } // namespace | 124 } // namespace |
| 119 | 125 |
| 120 // static | 126 // static |
| 121 PluginService* PluginService::GetInstance() { | 127 PluginService* PluginService::GetInstance() { |
| 122 return PluginServiceImpl::GetInstance(); | 128 return PluginServiceImpl::GetInstance(); |
| 123 } | 129 } |
| 124 | 130 |
| 125 void PluginService::PurgePluginListCache(BrowserContext* browser_context, | 131 void PluginService::PurgePluginListCache(BrowserContext* browser_context, |
| 126 bool reload_pages) { | 132 bool reload_pages) { |
| 127 for (RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator(); | 133 for (RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator(); |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 PostSequencedWorkerTaskWithShutdownBehavior( | 596 PostSequencedWorkerTaskWithShutdownBehavior( |
| 591 plugin_list_token_, | 597 plugin_list_token_, |
| 592 FROM_HERE, | 598 FROM_HERE, |
| 593 base::Bind(&PluginServiceImpl::GetPluginsInternal, | 599 base::Bind(&PluginServiceImpl::GetPluginsInternal, |
| 594 base::Unretained(this), | 600 base::Unretained(this), |
| 595 target_loop, callback), | 601 target_loop, callback), |
| 596 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); | 602 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); |
| 597 return; | 603 return; |
| 598 } | 604 } |
| 599 #if defined(OS_POSIX) | 605 #if defined(OS_POSIX) |
| 600 std::vector<WebPluginInfo> cached_plugins; | 606 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 601 if (PluginList::Singleton()->GetPluginsNoRefresh(&cached_plugins)) { | 607 base::Bind(&PluginServiceImpl::GetPluginsOnIOThread, |
| 602 // Can't assume the caller is reentrant. | 608 base::Unretained(this), target_loop, callback)); |
| 603 target_loop->PostTask(FROM_HERE, | |
| 604 base::Bind(callback, cached_plugins)); | |
| 605 } else { | |
| 606 // If we switch back to loading plugins in process, then we need to make | |
| 607 // sure g_thread_init() gets called since plugins may call glib at load. | |
| 608 if (!plugin_loader_.get()) | |
| 609 plugin_loader_ = new PluginLoaderPosix; | |
| 610 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | |
| 611 base::Bind(&PluginLoaderPosix::LoadPlugins, plugin_loader_, | |
| 612 target_loop, callback)); | |
| 613 } | |
| 614 #else | 609 #else |
| 615 NOTREACHED(); | 610 NOTREACHED(); |
| 616 #endif | 611 #endif |
| 617 } | 612 } |
| 618 | 613 |
| 619 void PluginServiceImpl::GetPluginsInternal( | 614 void PluginServiceImpl::GetPluginsInternal( |
| 620 base::MessageLoopProxy* target_loop, | 615 base::MessageLoopProxy* target_loop, |
| 621 const PluginService::GetPluginsCallback& callback) { | 616 const PluginService::GetPluginsCallback& callback) { |
| 622 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( | 617 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( |
| 623 plugin_list_token_)); | 618 plugin_list_token_)); |
| 624 | 619 |
| 625 std::vector<WebPluginInfo> plugins; | 620 std::vector<WebPluginInfo> plugins; |
| 626 PluginList::Singleton()->GetPlugins(&plugins, NPAPIPluginsSupported()); | 621 PluginList::Singleton()->GetPlugins(&plugins, NPAPIPluginsSupported()); |
| 627 | 622 |
| 628 target_loop->PostTask(FROM_HERE, | 623 target_loop->PostTask(FROM_HERE, |
| 629 base::Bind(callback, plugins)); | 624 base::Bind(callback, plugins)); |
| 630 } | 625 } |
| 631 | 626 |
| 627 #if defined(OS_POSIX) |
| 628 void PluginServiceImpl::GetPluginsOnIOThread( |
| 629 base::MessageLoopProxy* target_loop, |
| 630 const GetPluginsCallback& callback) { |
| 631 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 632 |
| 633 // If we switch back to loading plugins in process, then we need to make |
| 634 // sure g_thread_init() gets called since plugins may call glib at load. |
| 635 |
| 636 if (!plugin_loader_) |
| 637 plugin_loader_ = new PluginLoaderPosix; |
| 638 |
| 639 plugin_loader_->GetPlugins( |
| 640 base::Bind(&ForwardCallback, make_scoped_refptr(target_loop), callback)); |
| 641 } |
| 642 #endif |
| 643 |
| 632 void PluginServiceImpl::OnWaitableEventSignaled( | 644 void PluginServiceImpl::OnWaitableEventSignaled( |
| 633 base::WaitableEvent* waitable_event) { | 645 base::WaitableEvent* waitable_event) { |
| 634 #if defined(OS_WIN) | 646 #if defined(OS_WIN) |
| 635 if (waitable_event == hkcu_event_) { | 647 if (waitable_event == hkcu_event_) { |
| 636 hkcu_key_.StartWatching(); | 648 hkcu_key_.StartWatching(); |
| 637 } else { | 649 } else { |
| 638 hklm_key_.StartWatching(); | 650 hklm_key_.StartWatching(); |
| 639 } | 651 } |
| 640 | 652 |
| 641 PluginList::Singleton()->RefreshPlugins(); | 653 PluginList::Singleton()->RefreshPlugins(); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 return gfx::GetClassName(window) == base::string16(kNativeWindowClassName); | 852 return gfx::GetClassName(window) == base::string16(kNativeWindowClassName); |
| 841 } | 853 } |
| 842 #endif | 854 #endif |
| 843 | 855 |
| 844 bool PluginServiceImpl::PpapiDevChannelSupported() { | 856 bool PluginServiceImpl::PpapiDevChannelSupported() { |
| 845 return content::GetContentClient()->browser()-> | 857 return content::GetContentClient()->browser()-> |
| 846 IsPluginAllowedToUseDevChannelAPIs(); | 858 IsPluginAllowedToUseDevChannelAPIs(); |
| 847 } | 859 } |
| 848 | 860 |
| 849 } // namespace content | 861 } // namespace content |
| OLD | NEW |