Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(954)

Side by Side Diff: chrome/browser/plugin_observer.cc

Issue 7810002: Move infobar handling to a tab helper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/pdf_unsupported_feature.cc ('k') | chrome/browser/tab_contents/infobar.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/infobars/infobar_tab_helper.h"
10 #include "chrome/browser/plugin_installer_infobar_delegate.h" 11 #include "chrome/browser/plugin_installer_infobar_delegate.h"
11 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" 13 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
13 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" 14 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h"
14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
15 #include "chrome/common/render_messages.h" 16 #include "chrome/common/render_messages.h"
16 #include "chrome/common/url_constants.h" 17 #include "chrome/common/url_constants.h"
17 #include "content/browser/renderer_host/render_view_host.h" 18 #include "content/browser/renderer_host/render_view_host.h"
18 #include "content/browser/user_metrics.h" 19 #include "content/browser/user_metrics.h"
19 #include "content/common/view_messages.h" 20 #include "content/common/view_messages.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 307
307 PluginInstallerInfoBarDelegate* PluginObserver::GetPluginInstaller() { 308 PluginInstallerInfoBarDelegate* PluginObserver::GetPluginInstaller() {
308 if (plugin_installer_ == NULL) 309 if (plugin_installer_ == NULL)
309 plugin_installer_.reset(new PluginInstallerInfoBarDelegate(tab_contents())); 310 plugin_installer_.reset(new PluginInstallerInfoBarDelegate(tab_contents()));
310 return plugin_installer_->AsPluginInstallerInfoBarDelegate(); 311 return plugin_installer_->AsPluginInstallerInfoBarDelegate();
311 } 312 }
312 313
313 void PluginObserver::OnMissingPluginStatus(int status) { 314 void PluginObserver::OnMissingPluginStatus(int status) {
314 // TODO(PORT): pull in when plug-ins work 315 // TODO(PORT): pull in when plug-ins work
315 #if defined(OS_WIN) 316 #if defined(OS_WIN)
317 InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper();
316 if (status == webkit::npapi::default_plugin::MISSING_PLUGIN_AVAILABLE) { 318 if (status == webkit::npapi::default_plugin::MISSING_PLUGIN_AVAILABLE) {
317 tab_contents_->AddInfoBar( 319 infobar_helper->AddInfoBar(
318 new PluginInstallerInfoBarDelegate(tab_contents())); 320 new PluginInstallerInfoBarDelegate(tab_contents()));
319 return; 321 return;
320 } 322 }
321 323
322 DCHECK_EQ(webkit::npapi::default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD, 324 DCHECK_EQ(webkit::npapi::default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD,
323 status); 325 status);
324 for (size_t i = 0; i < tab_contents_->infobar_count(); ++i) { 326 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) {
325 InfoBarDelegate* delegate = tab_contents_->GetInfoBarDelegateAt(i); 327 InfoBarDelegate* delegate = infobar_helper->GetInfoBarDelegateAt(i);
326 if (delegate->AsPluginInstallerInfoBarDelegate() != NULL) { 328 if (delegate->AsPluginInstallerInfoBarDelegate() != NULL) {
327 tab_contents_->RemoveInfoBar(delegate); 329 infobar_helper->RemoveInfoBar(delegate);
328 return; 330 return;
329 } 331 }
330 } 332 }
331 #endif 333 #endif
332 } 334 }
333 335
334 void PluginObserver::OnCrashedPlugin(const FilePath& plugin_path) { 336 void PluginObserver::OnCrashedPlugin(const FilePath& plugin_path) {
335 DCHECK(!plugin_path.value().empty()); 337 DCHECK(!plugin_path.value().empty());
336 338
337 string16 plugin_name = plugin_path.LossyDisplayName(); 339 string16 plugin_name = plugin_path.LossyDisplayName();
338 webkit::WebPluginInfo plugin_info; 340 webkit::WebPluginInfo plugin_info;
339 if (webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( 341 if (webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath(
340 plugin_path, &plugin_info) && 342 plugin_path, &plugin_info) &&
341 !plugin_info.name.empty()) { 343 !plugin_info.name.empty()) {
342 plugin_name = plugin_info.name; 344 plugin_name = plugin_info.name;
343 #if defined(OS_MACOSX) 345 #if defined(OS_MACOSX)
344 // Many plugins on the Mac have .plugin in the actual name, which looks 346 // Many plugins on the Mac have .plugin in the actual name, which looks
345 // terrible, so look for that and strip it off if present. 347 // terrible, so look for that and strip it off if present.
346 const std::string kPluginExtension = ".plugin"; 348 const std::string kPluginExtension = ".plugin";
347 if (EndsWith(plugin_name, ASCIIToUTF16(kPluginExtension), true)) 349 if (EndsWith(plugin_name, ASCIIToUTF16(kPluginExtension), true))
348 plugin_name.erase(plugin_name.length() - kPluginExtension.length()); 350 plugin_name.erase(plugin_name.length() - kPluginExtension.length());
349 #endif // OS_MACOSX 351 #endif // OS_MACOSX
350 } 352 }
351 gfx::Image* icon = &ResourceBundle::GetSharedInstance().GetNativeImageNamed( 353 gfx::Image* icon = &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
352 IDR_INFOBAR_PLUGIN_CRASHED); 354 IDR_INFOBAR_PLUGIN_CRASHED);
353 tab_contents_->AddInfoBar(new SimpleAlertInfoBarDelegate(tab_contents(), 355 tab_contents_->infobar_tab_helper()->AddInfoBar(
354 icon, 356 new SimpleAlertInfoBarDelegate(
355 l10n_util::GetStringFUTF16(IDS_PLUGIN_CRASHED_PROMPT, plugin_name), 357 tab_contents(),
356 true)); 358 icon,
359 l10n_util::GetStringFUTF16(IDS_PLUGIN_CRASHED_PROMPT, plugin_name),
360 true));
357 } 361 }
358 362
359 void PluginObserver::OnBlockedOutdatedPlugin(const string16& name, 363 void PluginObserver::OnBlockedOutdatedPlugin(const string16& name,
360 const GURL& update_url) { 364 const GURL& update_url) {
361 tab_contents_->AddInfoBar(update_url.is_empty() ? 365 tab_contents_->infobar_tab_helper()->AddInfoBar(update_url.is_empty() ?
362 static_cast<InfoBarDelegate*>(new BlockedPluginInfoBarDelegate( 366 static_cast<InfoBarDelegate*>(new BlockedPluginInfoBarDelegate(
363 tab_contents(), name)) : 367 tab_contents(), name)) :
364 new OutdatedPluginInfoBarDelegate(tab_contents(), name, update_url)); 368 new OutdatedPluginInfoBarDelegate(tab_contents(), name, update_url));
365 } 369 }
OLDNEW
« no previous file with comments | « chrome/browser/pdf_unsupported_feature.cc ('k') | chrome/browser/tab_contents/infobar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698