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

Side by Side Diff: chrome/browser/ui/tab_contents/tab_contents_wrapper.cc

Issue 7810002: Move infobar handling to a tab helper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update 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
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/ui/tab_contents/tab_contents_wrapper.h" 5 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 8
9 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
11 #include "base/utf_string_conversions.h" 10 #include "base/stringprintf.h"
12 #include "chrome/browser/autocomplete_history_manager.h" 11 #include "chrome/browser/autocomplete_history_manager.h"
13 #include "chrome/browser/autofill/autofill_manager.h" 12 #include "chrome/browser/autofill/autofill_manager.h"
14 #include "chrome/browser/automation/automation_tab_helper.h" 13 #include "chrome/browser/automation/automation_tab_helper.h"
15 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/browser_shutdown.h" 15 #include "chrome/browser/browser_shutdown.h"
17 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 16 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
18 #include "chrome/browser/download/download_request_limiter_observer.h" 17 #include "chrome/browser/download/download_request_limiter_observer.h"
19 #include "chrome/browser/extensions/extension_tab_helper.h" 18 #include "chrome/browser/extensions/extension_tab_helper.h"
20 #include "chrome/browser/extensions/extension_webnavigation_api.h" 19 #include "chrome/browser/extensions/extension_webnavigation_api.h"
21 #include "chrome/browser/external_protocol/external_protocol_observer.h" 20 #include "chrome/browser/external_protocol/external_protocol_observer.h"
22 #include "chrome/browser/favicon/favicon_tab_helper.h" 21 #include "chrome/browser/favicon/favicon_tab_helper.h"
23 #include "chrome/browser/file_select_helper.h"
24 #include "chrome/browser/google/google_util.h" 22 #include "chrome/browser/google/google_util.h"
25 #include "chrome/browser/history/history_tab_helper.h" 23 #include "chrome/browser/history/history_tab_helper.h"
26 #include "chrome/browser/intents/web_intent_data.h" 24 #include "chrome/browser/infobars/infobar_tab_helper.h"
27 #include "chrome/browser/omnibox_search_hint.h" 25 #include "chrome/browser/omnibox_search_hint.h"
28 #include "chrome/browser/password_manager/password_manager.h" 26 #include "chrome/browser/password_manager/password_manager.h"
29 #include "chrome/browser/password_manager_delegate_impl.h" 27 #include "chrome/browser/password_manager_delegate_impl.h"
30 #include "chrome/browser/pdf_unsupported_feature.h" 28 #include "chrome/browser/pdf_unsupported_feature.h"
31 #include "chrome/browser/plugin_observer.h" 29 #include "chrome/browser/plugin_observer.h"
32 #include "chrome/browser/prefs/pref_service.h" 30 #include "chrome/browser/prefs/pref_service.h"
33 #include "chrome/browser/prerender/prerender_observer.h" 31 #include "chrome/browser/prerender/prerender_observer.h"
34 #include "chrome/browser/printing/print_preview_message_handler.h" 32 #include "chrome/browser/printing/print_preview_message_handler.h"
35 #include "chrome/browser/profiles/profile.h"
36 #include "chrome/browser/remoting/firewall_traversal_tab_helper.h" 33 #include "chrome/browser/remoting/firewall_traversal_tab_helper.h"
37 #include "chrome/browser/renderer_host/web_cache_manager.h" 34 #include "chrome/browser/renderer_host/web_cache_manager.h"
38 #include "chrome/browser/renderer_preferences_util.h" 35 #include "chrome/browser/renderer_preferences_util.h"
39 #include "chrome/browser/sessions/restore_tab_helper.h" 36 #include "chrome/browser/sessions/restore_tab_helper.h"
40 #include "chrome/browser/safe_browsing/client_side_detection_host.h" 37 #include "chrome/browser/safe_browsing/client_side_detection_host.h"
41 #include "chrome/browser/sync/glue/synced_tab_delegate.h"
42 #include "chrome/browser/tab_contents/infobar.h"
43 #include "chrome/browser/tab_contents/infobar_delegate.h"
44 #include "chrome/browser/tab_contents/insecure_content_infobar_delegate.h"
45 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h"
46 #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h" 38 #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h"
47 #include "chrome/browser/tab_contents/thumbnail_generator.h" 39 #include "chrome/browser/tab_contents/thumbnail_generator.h"
48 #include "chrome/browser/themes/theme_service.h" 40 #include "chrome/browser/themes/theme_service.h"
49 #include "chrome/browser/themes/theme_service_factory.h" 41 #include "chrome/browser/themes/theme_service_factory.h"
50 #include "chrome/browser/translate/translate_tab_helper.h" 42 #include "chrome/browser/translate/translate_tab_helper.h"
51 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" 43 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
52 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" 44 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
53 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 45 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
54 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" 46 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h"
55 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" 47 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h"
56 #include "chrome/common/chrome_notification_types.h" 48 #include "chrome/common/chrome_notification_types.h"
57 #include "chrome/common/chrome_switches.h" 49 #include "chrome/common/chrome_switches.h"
58 #include "chrome/common/pref_names.h" 50 #include "chrome/common/pref_names.h"
59 #include "chrome/common/render_messages.h" 51 #include "chrome/common/render_messages.h"
60 #include "content/browser/child_process_security_policy.h"
61 #include "content/browser/renderer_host/render_view_host.h" 52 #include "content/browser/renderer_host/render_view_host.h"
62 #include "content/browser/tab_contents/navigation_details.h"
63 #include "content/browser/tab_contents/tab_contents.h"
64 #include "content/browser/tab_contents/tab_contents_view.h" 53 #include "content/browser/tab_contents/tab_contents_view.h"
65 #include "content/browser/user_metrics.h"
66 #include "content/common/notification_service.h" 54 #include "content/common/notification_service.h"
67 #include "content/common/view_messages.h" 55 #include "content/common/view_messages.h"
68 #include "grit/generated_resources.h" 56 #include "grit/generated_resources.h"
69 #include "grit/locale_settings.h" 57 #include "grit/locale_settings.h"
70 #include "grit/platform_locale_settings.h" 58 #include "grit/platform_locale_settings.h"
71 #include "ui/base/l10n/l10n_util.h" 59 #include "ui/base/l10n/l10n_util.h"
72 #include "webkit/glue/webpreferences.h" 60 #include "webkit/glue/webpreferences.h"
73 61
74 namespace { 62 namespace {
75 63
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 107 }
120 108
121 } // namespace 109 } // namespace
122 110
123 //////////////////////////////////////////////////////////////////////////////// 111 ////////////////////////////////////////////////////////////////////////////////
124 // TabContentsWrapper, public: 112 // TabContentsWrapper, public:
125 113
126 TabContentsWrapper::TabContentsWrapper(TabContents* contents) 114 TabContentsWrapper::TabContentsWrapper(TabContents* contents)
127 : TabContentsObserver(contents), 115 : TabContentsObserver(contents),
128 delegate_(NULL), 116 delegate_(NULL),
129 infobars_enabled_(true),
130 ALLOW_THIS_IN_INITIALIZER_LIST( 117 ALLOW_THIS_IN_INITIALIZER_LIST(
131 synced_tab_delegate_(new TabContentsWrapperSyncedTabDelegate(this))), 118 synced_tab_delegate_(new TabContentsWrapperSyncedTabDelegate(this))),
132 in_destructor_(false), 119 in_destructor_(false),
133 tab_contents_(contents) { 120 tab_contents_(contents) {
134 DCHECK(contents); 121 DCHECK(contents);
135 DCHECK(!GetCurrentWrapperForContents(contents)); 122 DCHECK(!GetCurrentWrapperForContents(contents));
136 // Stash this in the property bag so it can be retrieved without having to 123 // Stash this in the property bag so it can be retrieved without having to
137 // go to a Browser. 124 // go to a Browser.
138 property_accessor()->SetProperty(contents->property_bag(), this); 125 property_accessor()->SetProperty(contents->property_bag(), this);
139 126
140 // Create the tab helpers. 127 // Create the tab helpers.
141 autocomplete_history_manager_.reset(new AutocompleteHistoryManager(contents)); 128 autocomplete_history_manager_.reset(new AutocompleteHistoryManager(contents));
142 autofill_manager_.reset(new AutofillManager(this)); 129 autofill_manager_.reset(new AutofillManager(this));
143 automation_tab_helper_.reset(new AutomationTabHelper(contents)); 130 automation_tab_helper_.reset(new AutomationTabHelper(contents));
144 blocked_content_tab_helper_.reset(new BlockedContentTabHelper(this)); 131 blocked_content_tab_helper_.reset(new BlockedContentTabHelper(this));
145 bookmark_tab_helper_.reset(new BookmarkTabHelper(this)); 132 bookmark_tab_helper_.reset(new BookmarkTabHelper(this));
146 extension_tab_helper_.reset(new ExtensionTabHelper(this)); 133 extension_tab_helper_.reset(new ExtensionTabHelper(this));
147 favicon_tab_helper_.reset(new FaviconTabHelper(contents)); 134 favicon_tab_helper_.reset(new FaviconTabHelper(contents));
148 find_tab_helper_.reset(new FindTabHelper(contents)); 135 find_tab_helper_.reset(new FindTabHelper(contents));
149 firewall_traversal_tab_helper_.reset( 136 firewall_traversal_tab_helper_.reset(
150 new FirewallTraversalTabHelper(contents)); 137 new FirewallTraversalTabHelper(contents));
151 history_tab_helper_.reset(new HistoryTabHelper(contents)); 138 history_tab_helper_.reset(new HistoryTabHelper(contents));
139 infobar_tab_helper_.reset(new InfoBarTabHelper(this));
152 restore_tab_helper_.reset(new RestoreTabHelper(this)); 140 restore_tab_helper_.reset(new RestoreTabHelper(this));
153 password_manager_delegate_.reset(new PasswordManagerDelegateImpl(this)); 141 password_manager_delegate_.reset(new PasswordManagerDelegateImpl(this));
154 password_manager_.reset( 142 password_manager_.reset(
155 new PasswordManager(contents, password_manager_delegate_.get())); 143 new PasswordManager(contents, password_manager_delegate_.get()));
156 #if defined(ENABLE_SAFE_BROWSING) 144 #if defined(ENABLE_SAFE_BROWSING)
157 if (profile()->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled) && 145 if (profile()->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled) &&
158 g_browser_process->safe_browsing_detection_service()) { 146 g_browser_process->safe_browsing_detection_service()) {
159 safebrowsing_detection_host_.reset( 147 safebrowsing_detection_host_.reset(
160 safe_browsing::ClientSideDetectionHost::Create(contents)); 148 safe_browsing::ClientSideDetectionHost::Create(contents));
161 } 149 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 if (prefs) { 189 if (prefs) {
202 for (int i = 0; i < kPrefsToObserveLength; ++i) 190 for (int i = 0; i < kPrefsToObserveLength; ++i)
203 pref_change_registrar_.Add(kPrefsToObserve[i], this); 191 pref_change_registrar_.Add(kPrefsToObserve[i], this);
204 } 192 }
205 193
206 renderer_preferences_util::UpdateFromSystemSettings( 194 renderer_preferences_util::UpdateFromSystemSettings(
207 tab_contents()->GetMutableRendererPrefs(), profile()); 195 tab_contents()->GetMutableRendererPrefs(), profile());
208 } 196 }
209 197
210 TabContentsWrapper::~TabContentsWrapper() { 198 TabContentsWrapper::~TabContentsWrapper() {
211 in_destructor_ = true; 199 in_destructor_ = true;
Peter Kasting 2011/08/31 18:47:32 You should explicitly reset |infobar_tab_helper_|
212
213 // Destroy all remaining InfoBars. It's important to not animate here so that
214 // we guarantee that we'll delete all delegates before we do anything else.
215 //
216 // TODO(pkasting): If there is no InfoBarContainer, this leaks all the
217 // InfoBarDelegates. This will be fixed once we call CloseSoon() directly on
218 // Infobars.
219 RemoveAllInfoBars(false);
220 } 200 }
221 201
222 PropertyAccessor<TabContentsWrapper*>* TabContentsWrapper::property_accessor() { 202 PropertyAccessor<TabContentsWrapper*>* TabContentsWrapper::property_accessor() {
223 return g_tab_contents_wrapper_property_accessor.Pointer(); 203 return g_tab_contents_wrapper_property_accessor.Pointer();
224 } 204 }
225 205
226 void TabContentsWrapper::RegisterUserPrefs(PrefService* prefs) { 206 void TabContentsWrapper::RegisterUserPrefs(PrefService* prefs) {
227 prefs->RegisterBooleanPref(prefs::kAlternateErrorPagesEnabled, 207 prefs->RegisterBooleanPref(prefs::kAlternateErrorPagesEnabled,
228 true, 208 true,
229 PrefService::SYNCABLE_PREF); 209 PrefService::SYNCABLE_PREF);
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 } 446 }
467 447
468 //////////////////////////////////////////////////////////////////////////////// 448 ////////////////////////////////////////////////////////////////////////////////
469 // TabContentsWrapper implementation: 449 // TabContentsWrapper implementation:
470 450
471 void TabContentsWrapper::RenderViewCreated(RenderViewHost* render_view_host) { 451 void TabContentsWrapper::RenderViewCreated(RenderViewHost* render_view_host) {
472 UpdateAlternateErrorPageURL(render_view_host); 452 UpdateAlternateErrorPageURL(render_view_host);
473 } 453 }
474 454
475 void TabContentsWrapper::RenderViewGone() { 455 void TabContentsWrapper::RenderViewGone() {
476 RemoveAllInfoBars(true);
477
478 // Tell the view that we've crashed so it can prepare the sad tab page. 456 // Tell the view that we've crashed so it can prepare the sad tab page.
479 // Only do this if we're not in browser shutdown, so that TabContents 457 // Only do this if we're not in browser shutdown, so that TabContents
480 // objects that are not in a browser (e.g., HTML dialogs) and thus are 458 // objects that are not in a browser (e.g., HTML dialogs) and thus are
481 // visible do not flash a sad tab page. 459 // visible do not flash a sad tab page.
482 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID) { 460 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID) {
483 tab_contents()->view()->OnTabCrashed( 461 tab_contents()->view()->OnTabCrashed(
484 tab_contents()->crashed_status(), tab_contents()->crashed_error_code()); 462 tab_contents()->crashed_status(), tab_contents()->crashed_error_code());
485 } 463 }
486 } 464 }
487 465
488 void TabContentsWrapper::DidBecomeSelected() { 466 void TabContentsWrapper::DidBecomeSelected() {
489 WebCacheManager::GetInstance()->ObserveActivity( 467 WebCacheManager::GetInstance()->ObserveActivity(
490 tab_contents()->GetRenderProcessHost()->id()); 468 tab_contents()->GetRenderProcessHost()->id());
491 } 469 }
492 470
493 bool TabContentsWrapper::OnMessageReceived(const IPC::Message& message) { 471 bool TabContentsWrapper::OnMessageReceived(const IPC::Message& message) {
494 bool handled = true; 472 bool handled = true;
495 IPC_BEGIN_MESSAGE_MAP(TabContentsWrapper, message) 473 IPC_BEGIN_MESSAGE_MAP(TabContentsWrapper, message)
496 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_Snapshot, OnSnapshot) 474 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_Snapshot, OnSnapshot)
497 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_PDFHasUnsupportedFeature, 475 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_PDFHasUnsupportedFeature,
498 OnPDFHasUnsupportedFeature) 476 OnPDFHasUnsupportedFeature)
499 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DidBlockDisplayingInsecureContent,
500 OnDidBlockDisplayingInsecureContent)
501 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DidBlockRunningInsecureContent,
502 OnDidBlockRunningInsecureContent)
503 IPC_MESSAGE_UNHANDLED(handled = false) 477 IPC_MESSAGE_UNHANDLED(handled = false)
504 IPC_END_MESSAGE_MAP() 478 IPC_END_MESSAGE_MAP()
505 return handled; 479 return handled;
506 } 480 }
507 481
508 void TabContentsWrapper::TabContentsDestroyed(TabContents* tab) { 482 void TabContentsWrapper::TabContentsDestroyed(TabContents* tab) {
509 // Destruction of the TabContents should only be done by us from our 483 // Destruction of the TabContents should only be done by us from our
510 // destructor. Otherwise it's very likely we (or one of the helpers we own) 484 // destructor. Otherwise it's very likely we (or one of the helpers we own)
511 // will attempt to access the TabContents and we'll crash. 485 // will attempt to access the TabContents and we'll crash.
512 DCHECK(in_destructor_); 486 DCHECK(in_destructor_);
513 } 487 }
514 488
515 void TabContentsWrapper::Observe(int type, 489 void TabContentsWrapper::Observe(int type,
516 const NotificationSource& source, 490 const NotificationSource& source,
517 const NotificationDetails& details) { 491 const NotificationDetails& details) {
518 switch (type) { 492 switch (type) {
519 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: {
520 DCHECK(&tab_contents_->controller() ==
521 Source<NavigationController>(source).ptr());
522
523 content::LoadCommittedDetails& committed_details =
524 *(Details<content::LoadCommittedDetails>(details).ptr());
525
526 // NOTE: It is not safe to change the following code to count upwards or
527 // use iterators, as the RemoveInfoBar() call synchronously modifies our
528 // delegate list.
529 for (size_t i = infobars_.size(); i > 0; --i) {
530 InfoBarDelegate* delegate = GetInfoBarDelegateAt(i - 1);
531 if (delegate->ShouldExpire(committed_details))
532 RemoveInfoBar(delegate);
533 }
534
535 break;
536 }
537 case chrome::NOTIFICATION_GOOGLE_URL_UPDATED: 493 case chrome::NOTIFICATION_GOOGLE_URL_UPDATED:
538 UpdateAlternateErrorPageURL(render_view_host()); 494 UpdateAlternateErrorPageURL(render_view_host());
539 break; 495 break;
540 case chrome::NOTIFICATION_USER_STYLE_SHEET_UPDATED: 496 case chrome::NOTIFICATION_USER_STYLE_SHEET_UPDATED:
541 UpdateWebPreferences(); 497 UpdateWebPreferences();
542 break; 498 break;
543 #if defined(OS_POSIX) && !defined(OS_MACOSX) 499 #if defined(OS_POSIX) && !defined(OS_MACOSX)
544 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: { 500 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: {
545 UpdateRendererPreferences(); 501 UpdateRendererPreferences();
546 break; 502 break;
(...skipping 17 matching lines...) Expand all
564 } else { 520 } else {
565 NOTREACHED() << "unexpected pref change notification" << *pref_name_in; 521 NOTREACHED() << "unexpected pref change notification" << *pref_name_in;
566 } 522 }
567 break; 523 break;
568 } 524 }
569 default: 525 default:
570 NOTREACHED(); 526 NOTREACHED();
571 } 527 }
572 } 528 }
573 529
574 void TabContentsWrapper::AddInfoBar(InfoBarDelegate* delegate) {
575 if (!infobars_enabled_) {
576 delegate->InfoBarClosed();
577 return;
578 }
579
580 for (size_t i = 0; i < infobars_.size(); ++i) {
581 if (GetInfoBarDelegateAt(i)->EqualsDelegate(delegate)) {
582 delegate->InfoBarClosed();
583 return;
584 }
585 }
586
587 infobars_.push_back(delegate);
588 NotificationService::current()->Notify(
589 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
590 Source<TabContentsWrapper>(this), Details<InfoBarAddedDetails>(delegate));
591
592 // Add ourselves as an observer for navigations the first time a delegate is
593 // added. We use this notification to expire InfoBars that need to expire on
594 // page transitions.
595 if (infobars_.size() == 1) {
596 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
597 Source<NavigationController>(&tab_contents_->controller()));
598 }
599 }
600
601 void TabContentsWrapper::RemoveInfoBar(InfoBarDelegate* delegate) {
602 RemoveInfoBarInternal(delegate, true);
603 }
604
605 void TabContentsWrapper::ReplaceInfoBar(InfoBarDelegate* old_delegate,
606 InfoBarDelegate* new_delegate) {
607 if (!infobars_enabled_) {
608 AddInfoBar(new_delegate); // Deletes the delegate.
609 return;
610 }
611
612 size_t i;
613 for (i = 0; i < infobars_.size(); ++i) {
614 if (GetInfoBarDelegateAt(i) == old_delegate)
615 break;
616 }
617 DCHECK_LT(i, infobars_.size());
618
619 infobars_.insert(infobars_.begin() + i, new_delegate);
620
621 old_delegate->clear_owner();
622 InfoBarReplacedDetails replaced_details(old_delegate, new_delegate);
623 NotificationService::current()->Notify(
624 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED,
625 Source<TabContentsWrapper>(this),
626 Details<InfoBarReplacedDetails>(&replaced_details));
627
628 infobars_.erase(infobars_.begin() + i + 1);
629 }
630
631 InfoBarDelegate* TabContentsWrapper::GetInfoBarDelegateAt(size_t index) {
632 return infobars_[index];
633 }
634
635 //////////////////////////////////////////////////////////////////////////////// 530 ////////////////////////////////////////////////////////////////////////////////
636 // Internal helpers 531 // Internal helpers
637 532
638 void TabContentsWrapper::OnSnapshot(const SkBitmap& bitmap) { 533 void TabContentsWrapper::OnSnapshot(const SkBitmap& bitmap) {
639 NotificationService::current()->Notify( 534 NotificationService::current()->Notify(
640 chrome::NOTIFICATION_TAB_SNAPSHOT_TAKEN, 535 chrome::NOTIFICATION_TAB_SNAPSHOT_TAKEN,
641 Source<TabContentsWrapper>(this), 536 Source<TabContentsWrapper>(this),
642 Details<const SkBitmap>(&bitmap)); 537 Details<const SkBitmap>(&bitmap));
643 } 538 }
644 539
645 void TabContentsWrapper::OnPDFHasUnsupportedFeature() { 540 void TabContentsWrapper::OnPDFHasUnsupportedFeature() {
646 PDFHasUnsupportedFeature(this); 541 PDFHasUnsupportedFeature(this);
647 } 542 }
648 543
649 void TabContentsWrapper::OnDidBlockDisplayingInsecureContent() {
650 // At most one infobar and do not supersede the stronger running content bar.
651 for (size_t i = 0; i < infobars_.size(); ++i) {
652 if (GetInfoBarDelegateAt(i)->AsInsecureContentInfoBarDelegate())
653 return;
654 }
655 AddInfoBar(new InsecureContentInfoBarDelegate(this,
656 InsecureContentInfoBarDelegate::DISPLAY));
657 }
658
659 void TabContentsWrapper::OnDidBlockRunningInsecureContent() {
660 // At most one infobar superseding any weaker displaying content bar.
661 for (size_t i = 0; i < infobars_.size(); ++i) {
662 InsecureContentInfoBarDelegate* delegate =
663 GetInfoBarDelegateAt(i)->AsInsecureContentInfoBarDelegate();
664 if (delegate) {
665 if (delegate->type() != InsecureContentInfoBarDelegate::RUN) {
666 ReplaceInfoBar(delegate, new InsecureContentInfoBarDelegate(this,
667 InsecureContentInfoBarDelegate::RUN));
668 }
669 return;
670 }
671 }
672 AddInfoBar(new InsecureContentInfoBarDelegate(this,
673 InsecureContentInfoBarDelegate::RUN));
674 }
675
676 GURL TabContentsWrapper::GetAlternateErrorPageURL() const { 544 GURL TabContentsWrapper::GetAlternateErrorPageURL() const {
677 GURL url; 545 GURL url;
678 // Disable alternate error pages when in Incognito mode. 546 // Disable alternate error pages when in Incognito mode.
679 if (profile()->IsOffTheRecord()) 547 if (profile()->IsOffTheRecord())
680 return url; 548 return url;
681 549
682 PrefService* prefs = profile()->GetPrefs(); 550 PrefService* prefs = profile()->GetPrefs();
683 if (prefs->GetBoolean(prefs::kAlternateErrorPagesEnabled)) { 551 if (prefs->GetBoolean(prefs::kAlternateErrorPagesEnabled)) {
684 url = google_util::AppendGoogleLocaleParam( 552 url = google_util::AppendGoogleLocaleParam(
685 GURL(google_util::kLinkDoctorBaseURL)); 553 GURL(google_util::kLinkDoctorBaseURL));
(...skipping 30 matching lines...) Expand all
716 } 584 }
717 } else { 585 } else {
718 safebrowsing_detection_host_.reset(); 586 safebrowsing_detection_host_.reset();
719 } 587 }
720 render_view_host()->Send( 588 render_view_host()->Send(
721 new ChromeViewMsg_SetClientSidePhishingDetection(routing_id(), 589 new ChromeViewMsg_SetClientSidePhishingDetection(routing_id(),
722 safe_browsing)); 590 safe_browsing));
723 #endif 591 #endif
724 } 592 }
725 593
726 void TabContentsWrapper::RemoveInfoBarInternal(InfoBarDelegate* delegate,
727 bool animate) {
728 if (!infobars_enabled_) {
729 DCHECK(infobars_.empty());
730 return;
731 }
732
733 size_t i;
734 for (i = 0; i < infobars_.size(); ++i) {
735 if (GetInfoBarDelegateAt(i) == delegate)
736 break;
737 }
738 DCHECK_LT(i, infobars_.size());
739 InfoBarDelegate* infobar = infobars_[i];
740
741 infobar->clear_owner();
742 InfoBarRemovedDetails removed_details(infobar, animate);
743 NotificationService::current()->Notify(
744 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
745 Source<TabContentsWrapper>(this),
746 Details<InfoBarRemovedDetails>(&removed_details));
747
748 infobars_.erase(infobars_.begin() + i);
749 // Remove ourselves as an observer if we are tracking no more InfoBars.
750 if (infobars_.empty()) {
751 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
752 Source<NavigationController>(&tab_contents_->controller()));
753 }
754 }
755
756 void TabContentsWrapper::RemoveAllInfoBars(bool animate) {
757 while (!infobars_.empty())
758 RemoveInfoBarInternal(GetInfoBarDelegateAt(infobar_count() - 1), animate);
759 }
760
761 void TabContentsWrapper::ExitFullscreenMode() { 594 void TabContentsWrapper::ExitFullscreenMode() {
762 Send(new ViewMsg_ExitFullscreen(routing_id())); 595 Send(new ViewMsg_ExitFullscreen(routing_id()));
763 } 596 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698