| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/file_version_info.h" | 9 #include "base/file_version_info.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 #endif | 764 #endif |
| 765 | 765 |
| 766 void TabContents::AddNewContents(TabContents* new_contents, | 766 void TabContents::AddNewContents(TabContents* new_contents, |
| 767 WindowOpenDisposition disposition, | 767 WindowOpenDisposition disposition, |
| 768 const gfx::Rect& initial_pos, | 768 const gfx::Rect& initial_pos, |
| 769 bool user_gesture, | 769 bool user_gesture, |
| 770 const GURL& creator_url) { | 770 const GURL& creator_url) { |
| 771 if (!delegate_) | 771 if (!delegate_) |
| 772 return; | 772 return; |
| 773 | 773 |
| 774 #if defined(OS_WIN) || defined(OS_LINUX) | |
| 775 if ((disposition == NEW_POPUP) && !user_gesture && | 774 if ((disposition == NEW_POPUP) && !user_gesture && |
| 776 !CommandLine::ForCurrentProcess()->HasSwitch( | 775 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 777 switches::kDisablePopupBlocking)) { | 776 switches::kDisablePopupBlocking)) { |
| 778 // Unrequested popups from normal pages are constrained unless they're in | 777 // Unrequested popups from normal pages are constrained unless they're in |
| 779 // the whitelist. The popup owner will handle checking this. | 778 // the whitelist. The popup owner will handle checking this. |
| 780 delegate_->GetConstrainingContents(this)->AddPopup(new_contents, | 779 delegate_->GetConstrainingContents(this)->AddPopup(new_contents, |
| 781 initial_pos, | 780 initial_pos, |
| 782 creator_url.is_valid() ? creator_url.host() : std::string()); | 781 creator_url.is_valid() ? creator_url.host() : std::string()); |
| 783 } else { | 782 } else { |
| 784 new_contents->DisassociateFromPopupCount(); | 783 new_contents->DisassociateFromPopupCount(); |
| 785 delegate_->AddNewContents(this, new_contents, disposition, initial_pos, | 784 delegate_->AddNewContents(this, new_contents, disposition, initial_pos, |
| 786 user_gesture); | 785 user_gesture); |
| 787 } | 786 } |
| 788 PopupNotificationVisibilityChanged(ShowingBlockedPopupNotification()); | 787 PopupNotificationVisibilityChanged(ShowingBlockedPopupNotification()); |
| 789 #else | |
| 790 // TODO(port): implement the popup blocker stuff | |
| 791 delegate_->AddNewContents(this, new_contents, disposition, initial_pos, | |
| 792 user_gesture); | |
| 793 #endif | |
| 794 } | 788 } |
| 795 | 789 |
| 796 void TabContents::CloseAllSuppressedPopups() { | 790 void TabContents::CloseAllSuppressedPopups() { |
| 797 if (blocked_popups_) | 791 if (blocked_popups_) |
| 798 blocked_popups_->CloseAll(); | 792 blocked_popups_->CloseAll(); |
| 799 } | 793 } |
| 800 | 794 |
| 801 void TabContents::PopupNotificationVisibilityChanged(bool visible) { | 795 void TabContents::PopupNotificationVisibilityChanged(bool visible) { |
| 802 render_view_host()->PopupNotificationVisibilityChanged(visible); | 796 render_view_host()->PopupNotificationVisibilityChanged(visible); |
| 803 } | 797 } |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 NotificationType type = is_loading ? NotificationType::LOAD_START : | 1071 NotificationType type = is_loading ? NotificationType::LOAD_START : |
| 1078 NotificationType::LOAD_STOP; | 1072 NotificationType::LOAD_STOP; |
| 1079 NotificationDetails det = NotificationService::NoDetails(); | 1073 NotificationDetails det = NotificationService::NoDetails(); |
| 1080 if (details) | 1074 if (details) |
| 1081 det = Details<LoadNotificationDetails>(details); | 1075 det = Details<LoadNotificationDetails>(details); |
| 1082 NotificationService::current()->Notify(type, | 1076 NotificationService::current()->Notify(type, |
| 1083 Source<NavigationController>(&controller_), | 1077 Source<NavigationController>(&controller_), |
| 1084 det); | 1078 det); |
| 1085 } | 1079 } |
| 1086 | 1080 |
| 1087 #if defined(OS_WIN) || defined(OS_LINUX) | |
| 1088 void TabContents::CreateBlockedPopupContainerIfNecessary() { | 1081 void TabContents::CreateBlockedPopupContainerIfNecessary() { |
| 1089 if (blocked_popups_) | 1082 if (blocked_popups_) |
| 1090 return; | 1083 return; |
| 1091 | 1084 |
| 1092 blocked_popups_ = BlockedPopupContainer::Create(this, profile()); | 1085 blocked_popups_ = BlockedPopupContainer::Create(this, profile()); |
| 1093 } | 1086 } |
| 1094 | 1087 |
| 1095 void TabContents::AddPopup(TabContents* new_contents, | 1088 void TabContents::AddPopup(TabContents* new_contents, |
| 1096 const gfx::Rect& initial_pos, | 1089 const gfx::Rect& initial_pos, |
| 1097 const std::string& host) { | 1090 const std::string& host) { |
| 1098 CreateBlockedPopupContainerIfNecessary(); | 1091 CreateBlockedPopupContainerIfNecessary(); |
| 1099 blocked_popups_->AddTabContents(new_contents, initial_pos, host); | 1092 blocked_popups_->AddTabContents(new_contents, initial_pos, host); |
| 1100 } | 1093 } |
| 1101 #endif | |
| 1102 | 1094 |
| 1103 // TODO(brettw) This should be on the TabContentsView. | 1095 // TODO(brettw) This should be on the TabContentsView. |
| 1104 void TabContents::RepositionSupressedPopupsToFit() { | 1096 void TabContents::RepositionSupressedPopupsToFit() { |
| 1105 if (blocked_popups_) | 1097 if (blocked_popups_) |
| 1106 blocked_popups_->RepositionBlockedPopupContainer(); | 1098 blocked_popups_->RepositionBlockedPopupContainer(); |
| 1107 } | 1099 } |
| 1108 | 1100 |
| 1109 bool TabContents::ShowingBlockedPopupNotification() const { | 1101 bool TabContents::ShowingBlockedPopupNotification() const { |
| 1110 return blocked_popups_ != NULL && | 1102 return blocked_popups_ != NULL && |
| 1111 blocked_popups_->GetBlockedPopupCount() != 0; | 1103 blocked_popups_->GetBlockedPopupCount() != 0; |
| (...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2341 NavigationController::LoadCommittedDetails& committed_details = | 2333 NavigationController::LoadCommittedDetails& committed_details = |
| 2342 *(Details<NavigationController::LoadCommittedDetails>(details).ptr()); | 2334 *(Details<NavigationController::LoadCommittedDetails>(details).ptr()); |
| 2343 ExpireInfoBars(committed_details); | 2335 ExpireInfoBars(committed_details); |
| 2344 break; | 2336 break; |
| 2345 } | 2337 } |
| 2346 | 2338 |
| 2347 default: | 2339 default: |
| 2348 NOTREACHED(); | 2340 NOTREACHED(); |
| 2349 } | 2341 } |
| 2350 } | 2342 } |
| OLD | NEW |