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

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

Issue 3186022: Merging r56866 to M6 branch:... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/472/src/
Patch Set: Created 10 years, 4 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 | « no previous file | no next file » | 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) 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/tab_contents/tab_contents.h" 5 #include "chrome/browser/tab_contents/tab_contents.h"
6 6
7 #if defined(OS_CHROMEOS) 7 #if defined(OS_CHROMEOS)
8 // For GdkScreen 8 // For GdkScreen
9 #include <gdk/gdk.h> 9 #include <gdk/gdk.h>
10 #endif // defined(OS_CHROMEOS) 10 #endif // defined(OS_CHROMEOS)
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 } 1033 }
1034 1034
1035 std::vector<InfoBarDelegate*>::iterator it = 1035 std::vector<InfoBarDelegate*>::iterator it =
1036 find(infobar_delegates_.begin(), infobar_delegates_.end(), delegate); 1036 find(infobar_delegates_.begin(), infobar_delegates_.end(), delegate);
1037 if (it != infobar_delegates_.end()) { 1037 if (it != infobar_delegates_.end()) {
1038 InfoBarDelegate* delegate = *it; 1038 InfoBarDelegate* delegate = *it;
1039 NotificationService::current()->Notify( 1039 NotificationService::current()->Notify(
1040 NotificationType::TAB_CONTENTS_INFOBAR_REMOVED, 1040 NotificationType::TAB_CONTENTS_INFOBAR_REMOVED,
1041 Source<TabContents>(this), 1041 Source<TabContents>(this),
1042 Details<InfoBarDelegate>(delegate)); 1042 Details<InfoBarDelegate>(delegate));
1043 infobar_delegates_.erase(it);
1044 1043
1045 // Remove ourselves as an observer if we are tracking no more InfoBars. 1044 // Just to be safe, make sure the delegate was not removed by an observer.
1046 if (infobar_delegates_.empty()) { 1045 it = find(infobar_delegates_.begin(), infobar_delegates_.end(), delegate);
1047 registrar_.Remove(this, NotificationType::NAV_ENTRY_COMMITTED, 1046 if (it != infobar_delegates_.end()) {
1048 Source<NavigationController>(&controller_)); 1047 infobar_delegates_.erase(it);
1048 // Remove ourselves as an observer if we are tracking no more InfoBars.
1049 if (infobar_delegates_.empty()) {
1050 registrar_.Remove(this, NotificationType::NAV_ENTRY_COMMITTED,
1051 Source<NavigationController>(&controller_));
1052 }
1053 } else {
1054 // If you hit this NOTREACHED, please comment in bug
1055 // http://crbug.com/50428 how you got there.
1056 NOTREACHED();
1049 } 1057 }
1050 } 1058 }
1051 } 1059 }
1052 1060
1053 void TabContents::ReplaceInfoBar(InfoBarDelegate* old_delegate, 1061 void TabContents::ReplaceInfoBar(InfoBarDelegate* old_delegate,
1054 InfoBarDelegate* new_delegate) { 1062 InfoBarDelegate* new_delegate) {
1055 if (delegate_ && !delegate_->infobars_enabled()) { 1063 if (delegate_ && !delegate_->infobars_enabled()) {
1056 new_delegate->InfoBarClosed(); 1064 new_delegate->InfoBarClosed();
1057 return; 1065 return;
1058 } 1066 }
1059 1067
1060 std::vector<InfoBarDelegate*>::iterator it = 1068 std::vector<InfoBarDelegate*>::iterator it =
1061 find(infobar_delegates_.begin(), infobar_delegates_.end(), old_delegate); 1069 find(infobar_delegates_.begin(), infobar_delegates_.end(), old_delegate);
1062 DCHECK(it != infobar_delegates_.end()); 1070 DCHECK(it != infobar_delegates_.end());
1063 1071
1064 // Notify the container about the change of plans. 1072 // Notify the container about the change of plans.
1065 scoped_ptr<std::pair<InfoBarDelegate*, InfoBarDelegate*> > details( 1073 scoped_ptr<std::pair<InfoBarDelegate*, InfoBarDelegate*> > details(
1066 new std::pair<InfoBarDelegate*, InfoBarDelegate*>( 1074 new std::pair<InfoBarDelegate*, InfoBarDelegate*>(
1067 old_delegate, new_delegate)); 1075 old_delegate, new_delegate));
1068 NotificationService::current()->Notify( 1076 NotificationService::current()->Notify(
1069 NotificationType::TAB_CONTENTS_INFOBAR_REPLACED, 1077 NotificationType::TAB_CONTENTS_INFOBAR_REPLACED,
1070 Source<TabContents>(this), 1078 Source<TabContents>(this),
1071 Details<std::pair<InfoBarDelegate*, InfoBarDelegate*> >(details.get())); 1079 Details<std::pair<InfoBarDelegate*, InfoBarDelegate*> >(details.get()));
1072 1080
1073 // Remove the old one. 1081 // Just to be safe, make sure the delegate was not removed by an observer.
1074 infobar_delegates_.erase(it); 1082 it = find(infobar_delegates_.begin(), infobar_delegates_.end(), old_delegate);
1083 if (it != infobar_delegates_.end()) {
1084 // Remove the old one.
1085 infobar_delegates_.erase(it);
1086 } else {
1087 // If you hit this NOTREACHED, please comment in bug
1088 // http://crbug.com/50428 how you got there.
1089 NOTREACHED();
1090 }
1075 1091
1076 // Add the new one. 1092 // Add the new one.
1093 DCHECK(find(infobar_delegates_.begin(),
1094 infobar_delegates_.end(), new_delegate) ==
1095 infobar_delegates_.end());
1077 infobar_delegates_.push_back(new_delegate); 1096 infobar_delegates_.push_back(new_delegate);
1078 } 1097 }
1079 1098
1080 bool TabContents::ShouldShowBookmarkBar() { 1099 bool TabContents::ShouldShowBookmarkBar() {
1081 if (showing_interstitial_page()) 1100 if (showing_interstitial_page())
1082 return false; 1101 return false;
1083 1102
1084 // See GetDOMUIForCurrentState() comment for more info. This case is very 1103 // See GetDOMUIForCurrentState() comment for more info. This case is very
1085 // similar, but for non-first loads, we want to use the committed entry. This 1104 // similar, but for non-first loads, we want to use the committed entry. This
1086 // is so the bookmarks bar disappears at the same time the page does. 1105 // is so the bookmarks bar disappears at the same time the page does.
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 void TabContents::ExpireInfoBars( 1473 void TabContents::ExpireInfoBars(
1455 const NavigationController::LoadCommittedDetails& details) { 1474 const NavigationController::LoadCommittedDetails& details) {
1456 // Only hide InfoBars when the user has done something that makes the main 1475 // Only hide InfoBars when the user has done something that makes the main
1457 // frame load. We don't want various automatic or subframe navigations making 1476 // frame load. We don't want various automatic or subframe navigations making
1458 // it disappear. 1477 // it disappear.
1459 if (!details.is_user_initiated_main_frame_load()) 1478 if (!details.is_user_initiated_main_frame_load())
1460 return; 1479 return;
1461 1480
1462 for (int i = infobar_delegate_count() - 1; i >= 0; --i) { 1481 for (int i = infobar_delegate_count() - 1; i >= 0; --i) {
1463 InfoBarDelegate* delegate = GetInfoBarDelegateAt(i); 1482 InfoBarDelegate* delegate = GetInfoBarDelegateAt(i);
1483 if (!delegate) {
1484 // If you hit this NOTREACHED, please comment in bug
1485 // http://crbug.com/50428 how you got there.
1486 NOTREACHED();
1487 continue;
1488 }
1489
1464 if (delegate->ShouldExpire(details)) 1490 if (delegate->ShouldExpire(details))
1465 RemoveInfoBar(delegate); 1491 RemoveInfoBar(delegate);
1466 } 1492 }
1467 } 1493 }
1468 1494
1469 DOMUI* TabContents::GetDOMUIForCurrentState() { 1495 DOMUI* TabContents::GetDOMUIForCurrentState() {
1470 // When there is a pending navigation entry, we want to use the pending DOMUI 1496 // When there is a pending navigation entry, we want to use the pending DOMUI
1471 // that goes along with it to control the basic flags. For example, we want to 1497 // that goes along with it to control the basic flags. For example, we want to
1472 // show the pending URL in the URL bar, so we want the display_url flag to 1498 // show the pending URL in the URL bar, so we want the display_url flag to
1473 // be from the pending entry. 1499 // be from the pending entry.
(...skipping 1773 matching lines...) Expand 10 before | Expand all | Expand 10 after
3247 AddInfoBar(new SavePasswordInfoBarDelegate(this, form_to_save)); 3273 AddInfoBar(new SavePasswordInfoBarDelegate(this, form_to_save));
3248 } 3274 }
3249 3275
3250 Profile* TabContents::GetProfileForPasswordManager() { 3276 Profile* TabContents::GetProfileForPasswordManager() {
3251 return profile(); 3277 return profile();
3252 } 3278 }
3253 3279
3254 bool TabContents::DidLastPageLoadEncounterSSLErrors() { 3280 bool TabContents::DidLastPageLoadEncounterSSLErrors() {
3255 return controller().ssl_manager()->ProcessedSSLErrorFromRequest(); 3281 return controller().ssl_manager()->ProcessedSSLErrorFromRequest();
3256 } 3282 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698