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 "chrome/browser/plugins/plugin_observer.h" | 5 #include "chrome/browser/plugins/plugin_observer.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 } | 331 } |
332 | 332 |
333 bool PluginObserver::OnMessageReceived( | 333 bool PluginObserver::OnMessageReceived( |
334 const IPC::Message& message, | 334 const IPC::Message& message, |
335 content::RenderFrameHost* render_frame_host) { | 335 content::RenderFrameHost* render_frame_host) { |
336 IPC_BEGIN_MESSAGE_MAP(PluginObserver, message) | 336 IPC_BEGIN_MESSAGE_MAP(PluginObserver, message) |
337 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedOutdatedPlugin, | 337 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedOutdatedPlugin, |
338 OnBlockedOutdatedPlugin) | 338 OnBlockedOutdatedPlugin) |
339 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_NPAPINotSupported, | 339 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_NPAPINotSupported, |
340 OnNPAPINotSupported) | 340 OnNPAPINotSupported) |
341 #if defined(ENABLE_PLUGIN_INSTALLATION) | |
342 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FindMissingPlugin, | |
343 OnFindMissingPlugin) | |
344 #endif | |
345 | 341 |
346 IPC_MESSAGE_UNHANDLED(return false) | 342 IPC_MESSAGE_UNHANDLED(return false) |
347 IPC_END_MESSAGE_MAP() | 343 IPC_END_MESSAGE_MAP() |
348 | 344 |
349 return true; | 345 return true; |
350 } | 346 } |
351 | 347 |
352 bool PluginObserver::OnMessageReceived(const IPC::Message& message) { | 348 bool PluginObserver::OnMessageReceived(const IPC::Message& message) { |
353 IPC_BEGIN_MESSAGE_MAP(PluginObserver, message) | 349 IPC_BEGIN_MESSAGE_MAP(PluginObserver, message) |
354 #if defined(ENABLE_PLUGIN_INSTALLATION) | 350 #if defined(ENABLE_PLUGIN_INSTALLATION) |
(...skipping 27 matching lines...) Expand all Loading... |
382 NOTREACHED(); | 378 NOTREACHED(); |
383 } | 379 } |
384 #else | 380 #else |
385 // If we don't support third-party plugin installation, we shouldn't have | 381 // If we don't support third-party plugin installation, we shouldn't have |
386 // outdated plugins. | 382 // outdated plugins. |
387 NOTREACHED(); | 383 NOTREACHED(); |
388 #endif // defined(ENABLE_PLUGIN_INSTALLATION) | 384 #endif // defined(ENABLE_PLUGIN_INSTALLATION) |
389 } | 385 } |
390 | 386 |
391 #if defined(ENABLE_PLUGIN_INSTALLATION) | 387 #if defined(ENABLE_PLUGIN_INSTALLATION) |
392 void PluginObserver::OnFindMissingPlugin(int placeholder_id, | |
393 const std::string& mime_type) { | |
394 std::string lang = "en-US"; // Oh yes. | |
395 scoped_ptr<PluginMetadata> plugin_metadata; | |
396 PluginInstaller* installer = NULL; | |
397 bool found_plugin = PluginFinder::GetInstance()->FindPlugin( | |
398 mime_type, lang, &installer, &plugin_metadata); | |
399 if (!found_plugin) { | |
400 Send(new ChromeViewMsg_DidNotFindMissingPlugin(placeholder_id)); | |
401 return; | |
402 } | |
403 DCHECK(installer); | |
404 DCHECK(plugin_metadata.get()); | |
405 | |
406 plugin_placeholders_[placeholder_id] = | |
407 new PluginPlaceholderHost(this, placeholder_id, plugin_metadata->name(), | |
408 installer); | |
409 PluginInstallerInfoBarDelegate::Create( | |
410 InfoBarService::FromWebContents(web_contents()), installer, | |
411 plugin_metadata.Pass(), | |
412 base::Bind(&PluginObserver::InstallMissingPlugin, | |
413 weak_ptr_factory_.GetWeakPtr(), installer)); | |
414 } | |
415 | |
416 void PluginObserver::InstallMissingPlugin( | |
417 PluginInstaller* installer, | |
418 const PluginMetadata* plugin_metadata) { | |
419 if (plugin_metadata->url_for_display()) { | |
420 installer->OpenDownloadURL(plugin_metadata->plugin_url(), web_contents()); | |
421 } else { | |
422 TabModalConfirmDialog::Create( | |
423 new ConfirmInstallDialogDelegate( | |
424 web_contents(), installer, plugin_metadata->Clone()), | |
425 web_contents()); | |
426 } | |
427 } | |
428 | |
429 void PluginObserver::OnRemovePluginPlaceholderHost(int placeholder_id) { | 388 void PluginObserver::OnRemovePluginPlaceholderHost(int placeholder_id) { |
430 std::map<int, PluginPlaceholderHost*>::iterator it = | 389 std::map<int, PluginPlaceholderHost*>::iterator it = |
431 plugin_placeholders_.find(placeholder_id); | 390 plugin_placeholders_.find(placeholder_id); |
432 if (it == plugin_placeholders_.end()) { | 391 if (it == plugin_placeholders_.end()) { |
433 NOTREACHED(); | 392 NOTREACHED(); |
434 return; | 393 return; |
435 } | 394 } |
436 delete it->second; | 395 delete it->second; |
437 plugin_placeholders_.erase(it); | 396 plugin_placeholders_.erase(it); |
438 } | 397 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 scoped_ptr<PluginMetadata> plugin; | 442 scoped_ptr<PluginMetadata> plugin; |
484 bool ret = PluginFinder::GetInstance()->FindPluginWithIdentifier( | 443 bool ret = PluginFinder::GetInstance()->FindPluginWithIdentifier( |
485 identifier, NULL, &plugin); | 444 identifier, NULL, &plugin); |
486 DCHECK(ret); | 445 DCHECK(ret); |
487 | 446 |
488 PluginMetroModeInfoBarDelegate::Create( | 447 PluginMetroModeInfoBarDelegate::Create( |
489 InfoBarService::FromWebContents(web_contents()), | 448 InfoBarService::FromWebContents(web_contents()), |
490 PluginMetroModeInfoBarDelegate::DESKTOP_MODE_REQUIRED, plugin->name()); | 449 PluginMetroModeInfoBarDelegate::DESKTOP_MODE_REQUIRED, plugin->name()); |
491 #endif | 450 #endif |
492 } | 451 } |
OLD | NEW |