OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/plugin_service.h" | 5 #include "chrome/browser/plugin_service.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 int render_process_id, | 307 int render_process_id, |
308 int render_view_id, | 308 int render_view_id, |
309 const GURL& url, | 309 const GURL& url, |
310 const std::string& mime_type, | 310 const std::string& mime_type, |
311 PluginProcessHost::Client* client) { | 311 PluginProcessHost::Client* client) { |
312 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 312 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
313 webkit::npapi::WebPluginInfo info; | 313 webkit::npapi::WebPluginInfo info; |
314 bool found = GetFirstAllowedPluginInfo( | 314 bool found = GetFirstAllowedPluginInfo( |
315 render_process_id, render_view_id, url, mime_type, &info, NULL); | 315 render_process_id, render_view_id, url, mime_type, &info, NULL); |
316 FilePath plugin_path; | 316 FilePath plugin_path; |
317 if (found && info.enabled) | 317 if (found && webkit::npapi::IsPluginEnabled(info)) |
318 plugin_path = FilePath(info.path); | 318 plugin_path = FilePath(info.path); |
319 | 319 |
320 // Now we jump back to the IO thread to finish opening the channel. | 320 // Now we jump back to the IO thread to finish opening the channel. |
321 BrowserThread::PostTask( | 321 BrowserThread::PostTask( |
322 BrowserThread::IO, FROM_HERE, | 322 BrowserThread::IO, FROM_HERE, |
323 NewRunnableMethod( | 323 NewRunnableMethod( |
324 this, &PluginService::FinishOpenChannelToPlugin, | 324 this, &PluginService::FinishOpenChannelToPlugin, |
325 plugin_path, client)); | 325 plugin_path, client)); |
326 } | 326 } |
327 | 327 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 | 449 |
450 #if defined(OS_MACOSX) | 450 #if defined(OS_MACOSX) |
451 case NotificationType::APP_ACTIVATED: { | 451 case NotificationType::APP_ACTIVATED: { |
452 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 452 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
453 NewRunnableFunction(&NotifyPluginsOfActivation)); | 453 NewRunnableFunction(&NotifyPluginsOfActivation)); |
454 break; | 454 break; |
455 } | 455 } |
456 #endif | 456 #endif |
457 | 457 |
458 case NotificationType::PLUGIN_ENABLE_STATUS_CHANGED: { | 458 case NotificationType::PLUGIN_ENABLE_STATUS_CHANGED: { |
| 459 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); |
459 PurgePluginListCache(false); | 460 PurgePluginListCache(false); |
460 break; | 461 break; |
461 } | 462 } |
462 case NotificationType::RENDERER_PROCESS_CLOSED: { | 463 case NotificationType::RENDERER_PROCESS_CLOSED: { |
463 int render_process_id = Source<RenderProcessHost>(source).ptr()->id(); | 464 int render_process_id = Source<RenderProcessHost>(source).ptr()->id(); |
464 | 465 |
465 base::AutoLock auto_lock(overridden_plugins_lock_); | 466 base::AutoLock auto_lock(overridden_plugins_lock_); |
466 for (size_t i = 0; i < overridden_plugins_.size(); ++i) { | 467 for (size_t i = 0; i < overridden_plugins_.size(); ++i) { |
467 if (overridden_plugins_[i].render_process_id == render_process_id) { | 468 if (overridden_plugins_[i].render_process_id == render_process_id) { |
468 overridden_plugins_.erase(overridden_plugins_.begin() + i); | 469 overridden_plugins_.erase(overridden_plugins_.begin() + i); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 void PluginService::RegisterPepperPlugins() { | 501 void PluginService::RegisterPepperPlugins() { |
501 std::vector<PepperPluginInfo> plugins; | 502 std::vector<PepperPluginInfo> plugins; |
502 PepperPluginRegistry::GetList(&plugins); | 503 PepperPluginRegistry::GetList(&plugins); |
503 for (size_t i = 0; i < plugins.size(); ++i) { | 504 for (size_t i = 0; i < plugins.size(); ++i) { |
504 webkit::npapi::WebPluginInfo info; | 505 webkit::npapi::WebPluginInfo info; |
505 info.path = plugins[i].path; | 506 info.path = plugins[i].path; |
506 info.name = plugins[i].name.empty() ? | 507 info.name = plugins[i].name.empty() ? |
507 WideToUTF16(plugins[i].path.BaseName().ToWStringHack()) : | 508 WideToUTF16(plugins[i].path.BaseName().ToWStringHack()) : |
508 ASCIIToUTF16(plugins[i].name); | 509 ASCIIToUTF16(plugins[i].name); |
509 info.desc = ASCIIToUTF16(plugins[i].description); | 510 info.desc = ASCIIToUTF16(plugins[i].description); |
510 info.enabled = true; | 511 info.enabled = webkit::npapi::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED; |
511 | 512 |
512 // TODO(evan): Pepper shouldn't require us to parse strings to get | 513 // TODO(evan): Pepper shouldn't require us to parse strings to get |
513 // the list of mime types out. | 514 // the list of mime types out. |
514 if (!webkit::npapi::PluginList::ParseMimeTypes( | 515 if (!webkit::npapi::PluginList::ParseMimeTypes( |
515 JoinString(plugins[i].mime_types, '|'), | 516 JoinString(plugins[i].mime_types, '|'), |
516 plugins[i].file_extensions, | 517 plugins[i].file_extensions, |
517 ASCIIToUTF16(plugins[i].type_descriptions), | 518 ASCIIToUTF16(plugins[i].type_descriptions), |
518 &info.mime_types)) { | 519 &info.mime_types)) { |
519 LOG(ERROR) << "Error parsing mime types for " | 520 LOG(ERROR) << "Error parsing mime types for " |
520 << plugins[i].path.ToWStringHack(); | 521 << plugins[i].path.ToWStringHack(); |
521 return; | 522 return; |
522 } | 523 } |
523 | 524 |
524 webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin(info); | 525 webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin(info); |
525 } | 526 } |
526 } | 527 } |
527 | 528 |
528 #if defined(OS_LINUX) | 529 #if defined(OS_LINUX) |
529 // static | 530 // static |
530 void PluginService::RegisterFilePathWatcher( | 531 void PluginService::RegisterFilePathWatcher( |
531 FilePathWatcher *watcher, | 532 FilePathWatcher *watcher, |
532 const FilePath& path, | 533 const FilePath& path, |
533 FilePathWatcher::Delegate* delegate) { | 534 FilePathWatcher::Delegate* delegate) { |
534 bool result = watcher->Watch(path, delegate); | 535 bool result = watcher->Watch(path, delegate); |
535 DCHECK(result); | 536 DCHECK(result); |
536 } | 537 } |
537 #endif | 538 #endif |
OLD | NEW |