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

Unified Diff: ios/chrome/browser/tabs/tab.mm

Issue 2717613006: Moved ios popup opening code from Tab to BlockedPopupTabHelper. (Closed)
Patch Set: Rebased Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ios/chrome/browser/web/blocked_popup_tab_helper.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/tabs/tab.mm
diff --git a/ios/chrome/browser/tabs/tab.mm b/ios/chrome/browser/tabs/tab.mm
index f49e7c9bdddcc2d9f8ea15d905adef4e24518ce7..2355b75547e749c472486f476b7b165bb372c1e3 100644
--- a/ios/chrome/browser/tabs/tab.mm
+++ b/ios/chrome/browser/tabs/tab.mm
@@ -384,10 +384,6 @@ enum class RendererTerminationTabState {
// Called when the UIApplication's state becomes active.
- (void)applicationDidBecomeActive;
-// Blocks popup for page with |popupURL|, requested by the page with
-// |openerURL|.
-- (void)blockPopupForURL:(const GURL&)popupURL openerURL:(const GURL&)openerURL;
-
@end
namespace {
@@ -1507,28 +1503,6 @@ void TabInfoBarObserver::OnInfoBarReplaced(infobars::InfoBar* old_infobar,
}
}
-- (void)blockPopupForURL:(const GURL&)popupURL
- openerURL:(const GURL&)openerURL {
- web::NavigationItem* item = [self navigationManager]->GetLastCommittedItem();
- web::Referrer referrer(openerURL, item->GetReferrer().policy);
- GURL localPopupURL(popupURL);
- base::WeakNSObject<Tab> weakSelf(self);
- // TODO(crbug.com/692117): Remove |window_name| from constructor.
- web::BlockedPopupInfo poupInfo(popupURL, referrer, nil /* window_name */, ^{
- web::WebState* webState = [weakSelf webState];
- if (webState) {
- web::WebState::OpenURLParams params(
- localPopupURL, referrer, WindowOpenDisposition::NEW_POPUP,
- ui::PAGE_TRANSITION_LINK, true /* is_renderer_initiated */);
- params.url = localPopupURL;
- params.referrer = referrer;
- params.transition = ui::PAGE_TRANSITION_LINK;
- webState->OpenURL(params);
- }
- });
- BlockedPopupTabHelper::FromWebState(self.webState)->HandlePopup(poupInfo);
-}
-
#pragma mark -
#pragma mark FindInPageControllerDelegate
@@ -2027,14 +2001,21 @@ void TabInfoBarObserver::OnInfoBarReplaced(infobars::InfoBar* old_infobar,
createWebControllerForURL:(const GURL&)URL
openerURL:(const GURL&)openerURL
initiatedByUser:(BOOL)initiatedByUser {
+ // Check if requested web controller is a popup and block it if necessary.
if (!initiatedByUser) {
- auto* helper = BlockedPopupTabHelper::FromWebState(webController.webState);
+ web::WebState* webState = webController.webState;
+ auto* helper = BlockedPopupTabHelper::FromWebState(webState);
if (helper->ShouldBlockPopup(openerURL)) {
- [self blockPopupForURL:URL openerURL:openerURL];
+ web::NavigationItem* item =
+ webState->GetNavigationManager()->GetLastCommittedItem();
+ web::Referrer referrer(openerURL, item->GetReferrer().policy);
+ web::BlockedPopupInfo poupInfo(URL, referrer);
+ helper->HandlePopup(poupInfo);
return nil;
}
}
+ // Requested web controller should not be blocked from opening.
[self updateSnapshotWithOverlay:YES visibleFrameOnly:YES];
Tab* tab = [parentTabModel_
insertBlankTabWithTransition:ui::PAGE_TRANSITION_LINK
« no previous file with comments | « no previous file | ios/chrome/browser/web/blocked_popup_tab_helper.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698