| 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" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/location.h" |
| 12 #include "base/message_loop/message_loop_proxy.h" | |
| 13 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
| 17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
| 18 #include "content/browser/ppapi_plugin_process_host.h" | 18 #include "content/browser/ppapi_plugin_process_host.h" |
| 19 #include "content/browser/renderer_host/render_process_host_impl.h" | 19 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 20 #include "content/browser/renderer_host/render_view_host_impl.h" | 20 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 21 #include "content/common/content_switches_internal.h" | 21 #include "content/common/content_switches_internal.h" |
| 22 #include "content/common/pepper_plugin_list.h" | 22 #include "content/common/pepper_plugin_list.h" |
| 23 #include "content/common/plugin_list.h" | 23 #include "content/common/plugin_list.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 VLOG(1) << "Watched path changed: " << path.value(); | 118 VLOG(1) << "Watched path changed: " << path.value(); |
| 119 // Make the plugin list update itself | 119 // Make the plugin list update itself |
| 120 PluginList::Singleton()->RefreshPlugins(); | 120 PluginList::Singleton()->RefreshPlugins(); |
| 121 BrowserThread::PostTask( | 121 BrowserThread::PostTask( |
| 122 BrowserThread::UI, FROM_HERE, | 122 BrowserThread::UI, FROM_HERE, |
| 123 base::Bind(&PluginService::PurgePluginListCache, | 123 base::Bind(&PluginService::PurgePluginListCache, |
| 124 static_cast<BrowserContext*>(NULL), false)); | 124 static_cast<BrowserContext*>(NULL), false)); |
| 125 } | 125 } |
| 126 #endif | 126 #endif |
| 127 | 127 |
| 128 void ForwardCallback(base::MessageLoopProxy* target_loop, | 128 void ForwardCallback(base::SingleThreadTaskRunner* target_task_runner, |
| 129 const PluginService::GetPluginsCallback& callback, | 129 const PluginService::GetPluginsCallback& callback, |
| 130 const std::vector<WebPluginInfo>& plugins) { | 130 const std::vector<WebPluginInfo>& plugins) { |
| 131 target_loop->PostTask(FROM_HERE, base::Bind(callback, plugins)); | 131 target_task_runner->PostTask(FROM_HERE, base::Bind(callback, plugins)); |
| 132 } | 132 } |
| 133 | 133 |
| 134 } // namespace | 134 } // namespace |
| 135 | 135 |
| 136 // static | 136 // static |
| 137 PluginService* PluginService::GetInstance() { | 137 PluginService* PluginService::GetInstance() { |
| 138 return PluginServiceImpl::GetInstance(); | 138 return PluginServiceImpl::GetInstance(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void PluginService::PurgePluginListCache(BrowserContext* browser_context, | 141 void PluginService::PurgePluginListCache(BrowserContext* browser_context, |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 // terrible, so look for that and strip it off if present. | 582 // terrible, so look for that and strip it off if present. |
| 583 const std::string kPluginExtension = ".plugin"; | 583 const std::string kPluginExtension = ".plugin"; |
| 584 if (EndsWith(plugin_name, base::ASCIIToUTF16(kPluginExtension), true)) | 584 if (EndsWith(plugin_name, base::ASCIIToUTF16(kPluginExtension), true)) |
| 585 plugin_name.erase(plugin_name.length() - kPluginExtension.length()); | 585 plugin_name.erase(plugin_name.length() - kPluginExtension.length()); |
| 586 #endif // OS_MACOSX | 586 #endif // OS_MACOSX |
| 587 } | 587 } |
| 588 return plugin_name; | 588 return plugin_name; |
| 589 } | 589 } |
| 590 | 590 |
| 591 void PluginServiceImpl::GetPlugins(const GetPluginsCallback& callback) { | 591 void PluginServiceImpl::GetPlugins(const GetPluginsCallback& callback) { |
| 592 scoped_refptr<base::MessageLoopProxy> target_loop( | 592 scoped_refptr<base::SingleThreadTaskRunner> target_task_runner( |
| 593 base::MessageLoop::current()->message_loop_proxy()); | 593 base::ThreadTaskRunnerHandle::Get()); |
| 594 | 594 |
| 595 if (LoadPluginListInProcess()) { | 595 if (LoadPluginListInProcess()) { |
| 596 BrowserThread::GetBlockingPool()-> | 596 BrowserThread::GetBlockingPool() |
| 597 PostSequencedWorkerTaskWithShutdownBehavior( | 597 ->PostSequencedWorkerTaskWithShutdownBehavior( |
| 598 plugin_list_token_, | 598 plugin_list_token_, FROM_HERE, |
| 599 FROM_HERE, | |
| 600 base::Bind(&PluginServiceImpl::GetPluginsInternal, | 599 base::Bind(&PluginServiceImpl::GetPluginsInternal, |
| 601 base::Unretained(this), | 600 base::Unretained(this), target_task_runner, callback), |
| 602 target_loop, callback), | 601 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); |
| 603 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); | |
| 604 return; | 602 return; |
| 605 } | 603 } |
| 606 #if defined(OS_POSIX) | 604 #if defined(OS_POSIX) |
| 607 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 605 BrowserThread::PostTask( |
| 606 BrowserThread::IO, FROM_HERE, |
| 608 base::Bind(&PluginServiceImpl::GetPluginsOnIOThread, | 607 base::Bind(&PluginServiceImpl::GetPluginsOnIOThread, |
| 609 base::Unretained(this), target_loop, callback)); | 608 base::Unretained(this), target_task_runner, callback)); |
| 610 #else | 609 #else |
| 611 NOTREACHED(); | 610 NOTREACHED(); |
| 612 #endif | 611 #endif |
| 613 } | 612 } |
| 614 | 613 |
| 615 void PluginServiceImpl::GetPluginsInternal( | 614 void PluginServiceImpl::GetPluginsInternal( |
| 616 base::MessageLoopProxy* target_loop, | 615 base::SingleThreadTaskRunner* target_task_runner, |
| 617 const PluginService::GetPluginsCallback& callback) { | 616 const PluginService::GetPluginsCallback& callback) { |
| 618 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( | 617 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( |
| 619 plugin_list_token_)); | 618 plugin_list_token_)); |
| 620 | 619 |
| 621 std::vector<WebPluginInfo> plugins; | 620 std::vector<WebPluginInfo> plugins; |
| 622 PluginList::Singleton()->GetPlugins(&plugins, NPAPIPluginsSupported()); | 621 PluginList::Singleton()->GetPlugins(&plugins, NPAPIPluginsSupported()); |
| 623 | 622 |
| 624 target_loop->PostTask(FROM_HERE, | 623 target_task_runner->PostTask(FROM_HERE, base::Bind(callback, plugins)); |
| 625 base::Bind(callback, plugins)); | |
| 626 } | 624 } |
| 627 | 625 |
| 628 #if defined(OS_POSIX) | 626 #if defined(OS_POSIX) |
| 629 void PluginServiceImpl::GetPluginsOnIOThread( | 627 void PluginServiceImpl::GetPluginsOnIOThread( |
| 630 base::MessageLoopProxy* target_loop, | 628 base::SingleThreadTaskRunner* target_task_runner, |
| 631 const GetPluginsCallback& callback) { | 629 const GetPluginsCallback& callback) { |
| 632 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 630 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 633 | 631 |
| 634 // If we switch back to loading plugins in process, then we need to make | 632 // If we switch back to loading plugins in process, then we need to make |
| 635 // sure g_thread_init() gets called since plugins may call glib at load. | 633 // sure g_thread_init() gets called since plugins may call glib at load. |
| 636 | 634 |
| 637 if (!plugin_loader_.get()) | 635 if (!plugin_loader_.get()) |
| 638 plugin_loader_ = new PluginLoaderPosix; | 636 plugin_loader_ = new PluginLoaderPosix; |
| 639 | 637 |
| 640 plugin_loader_->GetPlugins( | 638 plugin_loader_->GetPlugins(base::Bind( |
| 641 base::Bind(&ForwardCallback, make_scoped_refptr(target_loop), callback)); | 639 &ForwardCallback, make_scoped_refptr(target_task_runner), callback)); |
| 642 } | 640 } |
| 643 #endif | 641 #endif |
| 644 | 642 |
| 645 #if defined(OS_WIN) | 643 #if defined(OS_WIN) |
| 646 void PluginServiceImpl::OnKeyChanged(base::win::RegKey* key) { | 644 void PluginServiceImpl::OnKeyChanged(base::win::RegKey* key) { |
| 647 key->StartWatching(base::Bind(&PluginServiceImpl::OnKeyChanged, | 645 key->StartWatching(base::Bind(&PluginServiceImpl::OnKeyChanged, |
| 648 base::Unretained(this), | 646 base::Unretained(this), |
| 649 base::Unretained(key))); | 647 base::Unretained(key))); |
| 650 | 648 |
| 651 PluginList::Singleton()->RefreshPlugins(); | 649 PluginList::Singleton()->RefreshPlugins(); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 #endif | 865 #endif |
| 868 | 866 |
| 869 bool PluginServiceImpl::PpapiDevChannelSupported( | 867 bool PluginServiceImpl::PpapiDevChannelSupported( |
| 870 BrowserContext* browser_context, | 868 BrowserContext* browser_context, |
| 871 const GURL& document_url) { | 869 const GURL& document_url) { |
| 872 return content::GetContentClient()->browser()-> | 870 return content::GetContentClient()->browser()-> |
| 873 IsPluginAllowedToUseDevChannelAPIs(browser_context, document_url); | 871 IsPluginAllowedToUseDevChannelAPIs(browser_context, document_url); |
| 874 } | 872 } |
| 875 | 873 |
| 876 } // namespace content | 874 } // namespace content |
| OLD | NEW |