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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 UMA_HISTOGRAM_ENUMERATION("Plugin.FlashUsage", TOTAL_BROWSER_PROCESSES, | 145 UMA_HISTOGRAM_ENUMERATION("Plugin.FlashUsage", TOTAL_BROWSER_PROCESSES, |
146 FLASH_USAGE_ENUM_COUNT); | 146 FLASH_USAGE_ENUM_COUNT); |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 PluginServiceImpl::~PluginServiceImpl() { | 150 PluginServiceImpl::~PluginServiceImpl() { |
151 #if defined(OS_WIN) | 151 #if defined(OS_WIN) |
152 // Release the events since they're owned by RegKey, not WaitableEvent. | 152 // Release the events since they're owned by RegKey, not WaitableEvent. |
153 hkcu_watcher_.StopWatching(); | 153 hkcu_watcher_.StopWatching(); |
154 hklm_watcher_.StopWatching(); | 154 hklm_watcher_.StopWatching(); |
155 if (hkcu_event_.get()) | 155 if (hkcu_event_) |
156 hkcu_event_->Release(); | 156 hkcu_event_->Release(); |
157 if (hklm_event_.get()) | 157 if (hklm_event_) |
158 hklm_event_->Release(); | 158 hklm_event_->Release(); |
159 #endif | 159 #endif |
160 // Make sure no plugin channel requests have been leaked. | 160 // Make sure no plugin channel requests have been leaked. |
161 DCHECK(pending_plugin_clients_.empty()); | 161 DCHECK(pending_plugin_clients_.empty()); |
162 } | 162 } |
163 | 163 |
164 void PluginServiceImpl::Init() { | 164 void PluginServiceImpl::Init() { |
165 if (!plugin_list_) | 165 if (!plugin_list_) |
166 plugin_list_ = webkit::npapi::PluginList::Singleton(); | 166 plugin_list_ = webkit::npapi::PluginList::Singleton(); |
167 | 167 |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 } | 599 } |
600 #if defined(OS_POSIX) | 600 #if defined(OS_POSIX) |
601 std::vector<webkit::WebPluginInfo> cached_plugins; | 601 std::vector<webkit::WebPluginInfo> cached_plugins; |
602 if (plugin_list_->GetPluginsNoRefresh(&cached_plugins)) { | 602 if (plugin_list_->GetPluginsNoRefresh(&cached_plugins)) { |
603 // Can't assume the caller is reentrant. | 603 // Can't assume the caller is reentrant. |
604 target_loop->PostTask(FROM_HERE, | 604 target_loop->PostTask(FROM_HERE, |
605 base::Bind(callback, cached_plugins)); | 605 base::Bind(callback, cached_plugins)); |
606 } else { | 606 } else { |
607 // If we switch back to loading plugins in process, then we need to make | 607 // If we switch back to loading plugins in process, then we need to make |
608 // sure g_thread_init() gets called since plugins may call glib at load. | 608 // sure g_thread_init() gets called since plugins may call glib at load. |
609 if (!plugin_loader_.get()) | 609 if (!plugin_loader_) |
610 plugin_loader_ = new PluginLoaderPosix; | 610 plugin_loader_ = new PluginLoaderPosix; |
611 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 611 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
612 base::Bind(&PluginLoaderPosix::LoadPlugins, plugin_loader_, | 612 base::Bind(&PluginLoaderPosix::LoadPlugins, plugin_loader_, |
613 target_loop, callback)); | 613 target_loop, callback)); |
614 } | 614 } |
615 #else | 615 #else |
616 NOTREACHED(); | 616 NOTREACHED(); |
617 #endif | 617 #endif |
618 } | 618 } |
619 | 619 |
620 void PluginServiceImpl::GetPluginsInternal( | 620 void PluginServiceImpl::GetPluginsInternal( |
621 base::MessageLoopProxy* target_loop, | 621 base::MessageLoopProxy* target_loop, |
622 const PluginService::GetPluginsCallback& callback) { | 622 const PluginService::GetPluginsCallback& callback) { |
623 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( | 623 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( |
624 plugin_list_token_)); | 624 plugin_list_token_)); |
625 | 625 |
626 std::vector<webkit::WebPluginInfo> plugins; | 626 std::vector<webkit::WebPluginInfo> plugins; |
627 plugin_list_->GetPlugins(&plugins); | 627 plugin_list_->GetPlugins(&plugins); |
628 | 628 |
629 target_loop->PostTask(FROM_HERE, | 629 target_loop->PostTask(FROM_HERE, |
630 base::Bind(callback, plugins)); | 630 base::Bind(callback, plugins)); |
631 } | 631 } |
632 | 632 |
633 void PluginServiceImpl::OnWaitableEventSignaled( | 633 void PluginServiceImpl::OnWaitableEventSignaled( |
634 base::WaitableEvent* waitable_event) { | 634 base::WaitableEvent* waitable_event) { |
635 #if defined(OS_WIN) | 635 #if defined(OS_WIN) |
636 if (waitable_event == hkcu_event_.get()) { | 636 if (waitable_event == hkcu_event_) { |
637 hkcu_key_.StartWatching(); | 637 hkcu_key_.StartWatching(); |
638 } else { | 638 } else { |
639 hklm_key_.StartWatching(); | 639 hklm_key_.StartWatching(); |
640 } | 640 } |
641 | 641 |
642 plugin_list_->RefreshPlugins(); | 642 plugin_list_->RefreshPlugins(); |
643 PurgePluginListCache(NULL, false); | 643 PurgePluginListCache(NULL, false); |
644 #else | 644 #else |
645 // This event should only get signaled on a Windows machine. | 645 // This event should only get signaled on a Windows machine. |
646 NOTREACHED(); | 646 NOTREACHED(); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 void PluginServiceImpl::GetInternalPlugins( | 790 void PluginServiceImpl::GetInternalPlugins( |
791 std::vector<webkit::WebPluginInfo>* plugins) { | 791 std::vector<webkit::WebPluginInfo>* plugins) { |
792 plugin_list_->GetInternalPlugins(plugins); | 792 plugin_list_->GetInternalPlugins(plugins); |
793 } | 793 } |
794 | 794 |
795 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() { | 795 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() { |
796 return plugin_list_; | 796 return plugin_list_; |
797 } | 797 } |
798 | 798 |
799 } // namespace content | 799 } // namespace content |
OLD | NEW |