Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_observer.h" | 5 #include "chrome/browser/plugin_observer.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/content_settings/host_content_settings_map.h" | 8 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 9 #include "chrome/browser/google/google_util.h" | 9 #include "chrome/browser/google/google_util.h" |
| 10 #include "chrome/browser/plugin_installer_infobar_delegate.h" | 10 #include "chrome/browser/plugin_installer_infobar_delegate.h" |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 // PluginObserver ------------------------------------------------------------- | 285 // PluginObserver ------------------------------------------------------------- |
| 286 | 286 |
| 287 PluginObserver::PluginObserver(TabContentsWrapper* tab_contents) | 287 PluginObserver::PluginObserver(TabContentsWrapper* tab_contents) |
| 288 : TabContentsObserver(tab_contents->tab_contents()), | 288 : TabContentsObserver(tab_contents->tab_contents()), |
| 289 tab_contents_(tab_contents) { | 289 tab_contents_(tab_contents) { |
| 290 } | 290 } |
| 291 | 291 |
| 292 PluginObserver::~PluginObserver() { | 292 PluginObserver::~PluginObserver() { |
| 293 } | 293 } |
| 294 | 294 |
| 295 void PluginObserver::OnMissingPluginStatus(int status, | |
|
jam
2011/08/31 17:34:42
why is this method now on PluginObserver, since it
ananta
2011/08/31 20:18:14
Moved the handling to ChromePluginMessageFilter.
| |
| 296 int render_process_id, | |
| 297 int render_view_id, | |
| 298 int window) { | |
| 299 // TODO(PORT): pull in when plug-ins work | |
| 300 #if defined(OS_WIN) | |
| 301 RenderViewHost* host = RenderViewHost::FromID(render_process_id, | |
| 302 render_view_id); | |
| 303 if (!host || !host->delegate() || !host->delegate()->GetAsTabContents()) | |
| 304 return; | |
| 305 | |
| 306 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( | |
| 307 host->delegate()->GetAsTabContents()); | |
| 308 if (!tcw) | |
| 309 return; | |
| 310 | |
| 311 if (status == webkit::npapi::default_plugin::MISSING_PLUGIN_AVAILABLE) { | |
| 312 tcw->AddInfoBar( | |
| 313 new PluginInstallerInfoBarDelegate( | |
| 314 host->delegate()->GetAsTabContents(), window)); | |
| 315 return; | |
| 316 } | |
| 317 | |
| 318 DCHECK_EQ(webkit::npapi::default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD, | |
| 319 status); | |
| 320 for (size_t i = 0; i < tcw->infobar_count(); ++i) { | |
| 321 InfoBarDelegate* delegate = tcw->GetInfoBarDelegateAt(i); | |
| 322 if (delegate->AsPluginInstallerInfoBarDelegate() != NULL) { | |
| 323 tcw->RemoveInfoBar(delegate); | |
| 324 return; | |
| 325 } | |
| 326 } | |
| 327 #else | |
| 328 // TODO(port): Implement the infobar that accompanies the default plugin. | |
| 329 // Linux: http://crbug.com/10952 | |
| 330 // Mac: http://crbug.com/17392 | |
| 331 NOTIMPLEMENTED(); | |
| 332 #endif // OS_WIN | |
| 333 } | |
| 334 | |
| 295 bool PluginObserver::OnMessageReceived(const IPC::Message& message) { | 335 bool PluginObserver::OnMessageReceived(const IPC::Message& message) { |
| 296 IPC_BEGIN_MESSAGE_MAP(PluginObserver, message) | 336 IPC_BEGIN_MESSAGE_MAP(PluginObserver, message) |
| 297 IPC_MESSAGE_HANDLER(ViewHostMsg_MissingPluginStatus, OnMissingPluginStatus) | |
| 298 IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin) | 337 IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin) |
| 299 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedOutdatedPlugin, | 338 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedOutdatedPlugin, |
| 300 OnBlockedOutdatedPlugin) | 339 OnBlockedOutdatedPlugin) |
| 301 IPC_MESSAGE_UNHANDLED(return false) | 340 IPC_MESSAGE_UNHANDLED(return false) |
| 302 IPC_END_MESSAGE_MAP() | 341 IPC_END_MESSAGE_MAP() |
| 303 | 342 |
| 304 return true; | 343 return true; |
| 305 } | 344 } |
| 306 | 345 |
| 307 PluginInstallerInfoBarDelegate* PluginObserver::GetPluginInstaller() { | |
| 308 if (plugin_installer_ == NULL) | |
| 309 plugin_installer_.reset(new PluginInstallerInfoBarDelegate(tab_contents())); | |
| 310 return plugin_installer_->AsPluginInstallerInfoBarDelegate(); | |
| 311 } | |
| 312 | |
| 313 void PluginObserver::OnMissingPluginStatus(int status) { | |
| 314 // TODO(PORT): pull in when plug-ins work | |
| 315 #if defined(OS_WIN) | |
| 316 if (status == webkit::npapi::default_plugin::MISSING_PLUGIN_AVAILABLE) { | |
| 317 tab_contents_->AddInfoBar( | |
| 318 new PluginInstallerInfoBarDelegate(tab_contents())); | |
| 319 return; | |
| 320 } | |
| 321 | |
| 322 DCHECK_EQ(webkit::npapi::default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD, | |
| 323 status); | |
| 324 for (size_t i = 0; i < tab_contents_->infobar_count(); ++i) { | |
| 325 InfoBarDelegate* delegate = tab_contents_->GetInfoBarDelegateAt(i); | |
| 326 if (delegate->AsPluginInstallerInfoBarDelegate() != NULL) { | |
| 327 tab_contents_->RemoveInfoBar(delegate); | |
| 328 return; | |
| 329 } | |
| 330 } | |
| 331 #endif | |
| 332 } | |
| 333 | |
| 334 void PluginObserver::OnCrashedPlugin(const FilePath& plugin_path) { | 346 void PluginObserver::OnCrashedPlugin(const FilePath& plugin_path) { |
| 335 DCHECK(!plugin_path.value().empty()); | 347 DCHECK(!plugin_path.value().empty()); |
| 336 | 348 |
| 337 string16 plugin_name = plugin_path.LossyDisplayName(); | 349 string16 plugin_name = plugin_path.LossyDisplayName(); |
| 338 webkit::WebPluginInfo plugin_info; | 350 webkit::WebPluginInfo plugin_info; |
| 339 if (webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( | 351 if (webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( |
| 340 plugin_path, &plugin_info) && | 352 plugin_path, &plugin_info) && |
| 341 !plugin_info.name.empty()) { | 353 !plugin_info.name.empty()) { |
| 342 plugin_name = plugin_info.name; | 354 plugin_name = plugin_info.name; |
| 343 #if defined(OS_MACOSX) | 355 #if defined(OS_MACOSX) |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 356 true)); | 368 true)); |
| 357 } | 369 } |
| 358 | 370 |
| 359 void PluginObserver::OnBlockedOutdatedPlugin(const string16& name, | 371 void PluginObserver::OnBlockedOutdatedPlugin(const string16& name, |
| 360 const GURL& update_url) { | 372 const GURL& update_url) { |
| 361 tab_contents_->AddInfoBar(update_url.is_empty() ? | 373 tab_contents_->AddInfoBar(update_url.is_empty() ? |
| 362 static_cast<InfoBarDelegate*>(new BlockedPluginInfoBarDelegate( | 374 static_cast<InfoBarDelegate*>(new BlockedPluginInfoBarDelegate( |
| 363 tab_contents(), name)) : | 375 tab_contents(), name)) : |
| 364 new OutdatedPluginInfoBarDelegate(tab_contents(), name, update_url)); | 376 new OutdatedPluginInfoBarDelegate(tab_contents(), name, update_url)); |
| 365 } | 377 } |
| OLD | NEW |