| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> |
| 10 |
| 9 #include "base/bind.h" | 11 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 11 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 12 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 13 #include "base/location.h" | 15 #include "base/location.h" |
| 14 #include "base/logging.h" | 16 #include "base/logging.h" |
| 15 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
| 16 #include "base/single_thread_task_runner.h" | |
| 17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/synchronization/waitable_event.h" | 20 #include "base/synchronization/waitable_event.h" |
| 21 #include "base/task_runner_util.h" |
| 20 #include "base/task_scheduler/post_task.h" | 22 #include "base/task_scheduler/post_task.h" |
| 21 #include "base/threading/thread.h" | 23 #include "base/threading/thread.h" |
| 22 #include "base/threading/thread_task_runner_handle.h" | |
| 23 #include "build/build_config.h" | 24 #include "build/build_config.h" |
| 24 #include "content/browser/ppapi_plugin_process_host.h" | 25 #include "content/browser/ppapi_plugin_process_host.h" |
| 25 #include "content/browser/renderer_host/render_process_host_impl.h" | 26 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 26 #include "content/browser/renderer_host/render_view_host_impl.h" | 27 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 27 #include "content/common/content_switches_internal.h" | 28 #include "content/common/content_switches_internal.h" |
| 28 #include "content/common/pepper_plugin_list.h" | 29 #include "content/common/pepper_plugin_list.h" |
| 29 #include "content/common/plugin_list.h" | 30 #include "content/common/plugin_list.h" |
| 30 #include "content/common/view_messages.h" | 31 #include "content/common/view_messages.h" |
| 31 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
| 32 #include "content/public/browser/content_browser_client.h" | 33 #include "content/public/browser/content_browser_client.h" |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 // terrible, so look for that and strip it off if present. | 297 // terrible, so look for that and strip it off if present. |
| 297 const std::string kPluginExtension = ".plugin"; | 298 const std::string kPluginExtension = ".plugin"; |
| 298 if (base::EndsWith(plugin_name, base::ASCIIToUTF16(kPluginExtension), | 299 if (base::EndsWith(plugin_name, base::ASCIIToUTF16(kPluginExtension), |
| 299 base::CompareCase::SENSITIVE)) | 300 base::CompareCase::SENSITIVE)) |
| 300 plugin_name.erase(plugin_name.length() - kPluginExtension.length()); | 301 plugin_name.erase(plugin_name.length() - kPluginExtension.length()); |
| 301 #endif // OS_MACOSX | 302 #endif // OS_MACOSX |
| 302 } | 303 } |
| 303 return plugin_name; | 304 return plugin_name; |
| 304 } | 305 } |
| 305 | 306 |
| 306 void PluginServiceImpl::GetPlugins(const GetPluginsCallback& callback) { | 307 void PluginServiceImpl::GetPlugins(GetPluginsCallback callback) { |
| 307 scoped_refptr<base::SingleThreadTaskRunner> target_task_runner( | 308 base::PostTaskAndReplyWithResult( |
| 308 base::ThreadTaskRunnerHandle::Get()); | 309 plugin_list_task_runner_.get(), FROM_HERE, base::BindOnce([]() { |
| 309 | 310 std::vector<WebPluginInfo> plugins; |
| 310 plugin_list_task_runner_->PostTask( | 311 PluginList::Singleton()->GetPlugins(&plugins); |
| 311 FROM_HERE, | 312 return plugins; |
| 312 base::Bind(&PluginServiceImpl::GetPluginsInternal, base::Unretained(this), | 313 }), |
| 313 base::RetainedRef(target_task_runner), callback)); | 314 std::move(callback)); |
| 314 } | |
| 315 | |
| 316 void PluginServiceImpl::GetPluginsInternal( | |
| 317 base::SingleThreadTaskRunner* target_task_runner, | |
| 318 const PluginService::GetPluginsCallback& callback) { | |
| 319 DCHECK(plugin_list_sequence_checker_.CalledOnValidSequence()); | |
| 320 | |
| 321 std::vector<WebPluginInfo> plugins; | |
| 322 PluginList::Singleton()->GetPlugins(&plugins); | |
| 323 | |
| 324 target_task_runner->PostTask(FROM_HERE, base::Bind(callback, plugins)); | |
| 325 } | 315 } |
| 326 | 316 |
| 327 void PluginServiceImpl::RegisterPepperPlugins() { | 317 void PluginServiceImpl::RegisterPepperPlugins() { |
| 328 ComputePepperPluginList(&ppapi_plugins_); | 318 ComputePepperPluginList(&ppapi_plugins_); |
| 329 for (size_t i = 0; i < ppapi_plugins_.size(); ++i) { | 319 for (size_t i = 0; i < ppapi_plugins_.size(); ++i) { |
| 330 RegisterInternalPlugin(ppapi_plugins_[i].ToWebPluginInfo(), true); | 320 RegisterInternalPlugin(ppapi_plugins_[i].ToWebPluginInfo(), true); |
| 331 } | 321 } |
| 332 } | 322 } |
| 333 | 323 |
| 334 // There should generally be very few plugins so a brute-force search is fine. | 324 // There should generally be very few plugins so a brute-force search is fine. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 } | 403 } |
| 414 | 404 |
| 415 bool PluginServiceImpl::PpapiDevChannelSupported( | 405 bool PluginServiceImpl::PpapiDevChannelSupported( |
| 416 BrowserContext* browser_context, | 406 BrowserContext* browser_context, |
| 417 const GURL& document_url) { | 407 const GURL& document_url) { |
| 418 return GetContentClient()->browser()->IsPluginAllowedToUseDevChannelAPIs( | 408 return GetContentClient()->browser()->IsPluginAllowedToUseDevChannelAPIs( |
| 419 browser_context, document_url); | 409 browser_context, document_url); |
| 420 } | 410 } |
| 421 | 411 |
| 422 } // namespace content | 412 } // namespace content |
| OLD | NEW |