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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 } | 340 } |
341 | 341 |
342 void PluginServiceImpl::OpenChannelToPpapiPlugin( | 342 void PluginServiceImpl::OpenChannelToPpapiPlugin( |
343 const FilePath& path, | 343 const FilePath& path, |
344 PpapiPluginProcessHost::PluginClient* client) { | 344 PpapiPluginProcessHost::PluginClient* client) { |
345 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiPluginProcess( | 345 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiPluginProcess( |
346 path, client); | 346 path, client); |
347 if (plugin_host) | 347 if (plugin_host) |
348 plugin_host->OpenChannelToPlugin(client); | 348 plugin_host->OpenChannelToPlugin(client); |
349 else // Send error. | 349 else // Send error. |
350 client->OnChannelOpened(base::kNullProcessHandle, IPC::ChannelHandle()); | 350 client->OnChannelOpened(base::kNullProcessHandle, IPC::ChannelHandle(), 0); |
351 } | 351 } |
352 | 352 |
353 void PluginServiceImpl::OpenChannelToPpapiBroker( | 353 void PluginServiceImpl::OpenChannelToPpapiBroker( |
354 const FilePath& path, | 354 const FilePath& path, |
355 PpapiPluginProcessHost::BrokerClient* client) { | 355 PpapiPluginProcessHost::BrokerClient* client) { |
356 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiBrokerProcess(path); | 356 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiBrokerProcess(path); |
357 if (plugin_host) | 357 if (plugin_host) |
358 plugin_host->OpenChannelToPlugin(client); | 358 plugin_host->OpenChannelToPlugin(client); |
359 else // Send error. | 359 else // Send error. |
360 client->OnChannelOpened(base::kNullProcessHandle, IPC::ChannelHandle()); | 360 client->OnChannelOpened(base::kNullProcessHandle, IPC::ChannelHandle(), 0); |
361 } | 361 } |
362 | 362 |
363 void PluginServiceImpl::CancelOpenChannelToNpapiPlugin( | 363 void PluginServiceImpl::CancelOpenChannelToNpapiPlugin( |
364 PluginProcessHost::Client* client) { | 364 PluginProcessHost::Client* client) { |
365 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 365 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
366 DCHECK(ContainsKey(pending_plugin_clients_, client)); | 366 DCHECK(ContainsKey(pending_plugin_clients_, client)); |
367 pending_plugin_clients_.erase(client); | 367 pending_plugin_clients_.erase(client); |
368 } | 368 } |
369 | 369 |
370 void PluginServiceImpl::ForwardGetAllowedPluginForOpenChannelToPlugin( | 370 void PluginServiceImpl::ForwardGetAllowedPluginForOpenChannelToPlugin( |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 ++it) { | 477 ++it) { |
478 if (it->path == plugin_path) { | 478 if (it->path == plugin_path) { |
479 *info = *it; | 479 *info = *it; |
480 return true; | 480 return true; |
481 } | 481 } |
482 } | 482 } |
483 | 483 |
484 return false; | 484 return false; |
485 } | 485 } |
486 | 486 |
| 487 string16 PluginServiceImpl::GetPluginDisplayNameByPath(const FilePath& path) { |
| 488 string16 plugin_name = path.LossyDisplayName(); |
| 489 webkit::WebPluginInfo info; |
| 490 if (PluginService::GetInstance()->GetPluginInfoByPath(path, &info) && |
| 491 !info.name.empty()) { |
| 492 plugin_name = info.name; |
| 493 #if defined(OS_MACOSX) |
| 494 // Many plugins on the Mac have .plugin in the actual name, which looks |
| 495 // terrible, so look for that and strip it off if present. |
| 496 const std::string kPluginExtension = ".plugin"; |
| 497 if (EndsWith(plugin_name, ASCIIToUTF16(kPluginExtension), true)) |
| 498 plugin_name.erase(plugin_name.length() - kPluginExtension.length()); |
| 499 #endif // OS_MACOSX |
| 500 } |
| 501 return plugin_name; |
| 502 } |
| 503 |
487 void PluginServiceImpl::GetPlugins(const GetPluginsCallback& callback) { | 504 void PluginServiceImpl::GetPlugins(const GetPluginsCallback& callback) { |
488 scoped_refptr<base::MessageLoopProxy> target_loop( | 505 scoped_refptr<base::MessageLoopProxy> target_loop( |
489 MessageLoop::current()->message_loop_proxy()); | 506 MessageLoop::current()->message_loop_proxy()); |
490 | 507 |
491 #if defined(OS_WIN) | 508 #if defined(OS_WIN) |
492 BrowserThread::PostTask( | 509 BrowserThread::PostTask( |
493 BrowserThread::FILE, FROM_HERE, | 510 BrowserThread::FILE, FROM_HERE, |
494 base::Bind(&PluginServiceImpl::GetPluginsInternal, base::Unretained(this), | 511 base::Bind(&PluginServiceImpl::GetPluginsInternal, base::Unretained(this), |
495 target_loop, callback)); | 512 target_loop, callback)); |
496 #else | 513 #else |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 plugin_list_->RegisterInternalPlugin(info, add_at_beginning); | 709 plugin_list_->RegisterInternalPlugin(info, add_at_beginning); |
693 } | 710 } |
694 | 711 |
695 string16 PluginServiceImpl::GetPluginGroupName(const std::string& plugin_name) { | 712 string16 PluginServiceImpl::GetPluginGroupName(const std::string& plugin_name) { |
696 return plugin_list_->GetPluginGroupName(plugin_name); | 713 return plugin_list_->GetPluginGroupName(plugin_name); |
697 } | 714 } |
698 | 715 |
699 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() { | 716 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() { |
700 return plugin_list_; | 717 return plugin_list_; |
701 } | 718 } |
OLD | NEW |