| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #import "ios/chrome/browser/tabs/tab.h" | 5 #import "ios/chrome/browser/tabs/tab.h" |
| 6 | 6 |
| 7 #import <CoreLocation/CoreLocation.h> | 7 #import <CoreLocation/CoreLocation.h> |
| 8 #import <UIKit/UIKit.h> | 8 #import <UIKit/UIKit.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 // Handles exportable files if possible. | 377 // Handles exportable files if possible. |
| 378 - (void)handleExportableFile:(net::HttpResponseHeaders*)headers; | 378 - (void)handleExportableFile:(net::HttpResponseHeaders*)headers; |
| 379 | 379 |
| 380 // Called after the session history is replaced, useful for updating members | 380 // Called after the session history is replaced, useful for updating members |
| 381 // with new sessionID. | 381 // with new sessionID. |
| 382 - (void)didReplaceSessionHistory; | 382 - (void)didReplaceSessionHistory; |
| 383 | 383 |
| 384 // Called when the UIApplication's state becomes active. | 384 // Called when the UIApplication's state becomes active. |
| 385 - (void)applicationDidBecomeActive; | 385 - (void)applicationDidBecomeActive; |
| 386 | 386 |
| 387 // Blocks popup for page with |popupURL|, requested by the page with | |
| 388 // |openerURL|. | |
| 389 - (void)blockPopupForURL:(const GURL&)popupURL openerURL:(const GURL&)openerURL; | |
| 390 | |
| 391 @end | 387 @end |
| 392 | 388 |
| 393 namespace { | 389 namespace { |
| 394 // TabHistoryContext is used by history to scope the lifetime of navigation | 390 // TabHistoryContext is used by history to scope the lifetime of navigation |
| 395 // entry references to Tab. | 391 // entry references to Tab. |
| 396 class TabHistoryContext : public history::Context { | 392 class TabHistoryContext : public history::Context { |
| 397 public: | 393 public: |
| 398 TabHistoryContext() {} | 394 TabHistoryContext() {} |
| 399 ~TabHistoryContext() {} | 395 ~TabHistoryContext() {} |
| 400 | 396 |
| (...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1500 if (requireReloadAfterBecomingActive_) { | 1496 if (requireReloadAfterBecomingActive_) { |
| 1501 if (visible_) { | 1497 if (visible_) { |
| 1502 [self.webController reload]; | 1498 [self.webController reload]; |
| 1503 } else { | 1499 } else { |
| 1504 [self.webController requirePageReload]; | 1500 [self.webController requirePageReload]; |
| 1505 } | 1501 } |
| 1506 requireReloadAfterBecomingActive_ = NO; | 1502 requireReloadAfterBecomingActive_ = NO; |
| 1507 } | 1503 } |
| 1508 } | 1504 } |
| 1509 | 1505 |
| 1510 - (void)blockPopupForURL:(const GURL&)popupURL | |
| 1511 openerURL:(const GURL&)openerURL { | |
| 1512 web::NavigationItem* item = [self navigationManager]->GetLastCommittedItem(); | |
| 1513 web::Referrer referrer(openerURL, item->GetReferrer().policy); | |
| 1514 GURL localPopupURL(popupURL); | |
| 1515 base::WeakNSObject<Tab> weakSelf(self); | |
| 1516 // TODO(crbug.com/692117): Remove |window_name| from constructor. | |
| 1517 web::BlockedPopupInfo poupInfo(popupURL, referrer, nil /* window_name */, ^{ | |
| 1518 web::WebState* webState = [weakSelf webState]; | |
| 1519 if (webState) { | |
| 1520 web::WebState::OpenURLParams params( | |
| 1521 localPopupURL, referrer, WindowOpenDisposition::NEW_POPUP, | |
| 1522 ui::PAGE_TRANSITION_LINK, true /* is_renderer_initiated */); | |
| 1523 params.url = localPopupURL; | |
| 1524 params.referrer = referrer; | |
| 1525 params.transition = ui::PAGE_TRANSITION_LINK; | |
| 1526 webState->OpenURL(params); | |
| 1527 } | |
| 1528 }); | |
| 1529 BlockedPopupTabHelper::FromWebState(self.webState)->HandlePopup(poupInfo); | |
| 1530 } | |
| 1531 | |
| 1532 #pragma mark - | 1506 #pragma mark - |
| 1533 #pragma mark FindInPageControllerDelegate | 1507 #pragma mark FindInPageControllerDelegate |
| 1534 | 1508 |
| 1535 - (void)willAdjustScrollPosition { | 1509 - (void)willAdjustScrollPosition { |
| 1536 // Skip the next attempt to correct the scroll offset for the toolbar height. | 1510 // Skip the next attempt to correct the scroll offset for the toolbar height. |
| 1537 // Used when programatically scrolling down the y offset. | 1511 // Used when programatically scrolling down the y offset. |
| 1538 [fullScreenController_ shouldSkipNextScrollOffsetForHeader]; | 1512 [fullScreenController_ shouldSkipNextScrollOffsetForHeader]; |
| 1539 } | 1513 } |
| 1540 | 1514 |
| 1541 #pragma mark - | 1515 #pragma mark - |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2020 | 1994 |
| 2021 - (void)webControllerDidSuppressDialog:(id)webController { | 1995 - (void)webControllerDidSuppressDialog:(id)webController { |
| 2022 DCHECK(isPrerenderTab_); | 1996 DCHECK(isPrerenderTab_); |
| 2023 [delegate_ discardPrerender]; | 1997 [delegate_ discardPrerender]; |
| 2024 } | 1998 } |
| 2025 | 1999 |
| 2026 - (CRWWebController*)webController:(CRWWebController*)webController | 2000 - (CRWWebController*)webController:(CRWWebController*)webController |
| 2027 createWebControllerForURL:(const GURL&)URL | 2001 createWebControllerForURL:(const GURL&)URL |
| 2028 openerURL:(const GURL&)openerURL | 2002 openerURL:(const GURL&)openerURL |
| 2029 initiatedByUser:(BOOL)initiatedByUser { | 2003 initiatedByUser:(BOOL)initiatedByUser { |
| 2004 // Check if requested web controller is a popup and block it if necessary. |
| 2030 if (!initiatedByUser) { | 2005 if (!initiatedByUser) { |
| 2031 auto* helper = BlockedPopupTabHelper::FromWebState(webController.webState); | 2006 web::WebState* webState = webController.webState; |
| 2007 auto* helper = BlockedPopupTabHelper::FromWebState(webState); |
| 2032 if (helper->ShouldBlockPopup(openerURL)) { | 2008 if (helper->ShouldBlockPopup(openerURL)) { |
| 2033 [self blockPopupForURL:URL openerURL:openerURL]; | 2009 web::NavigationItem* item = |
| 2010 webState->GetNavigationManager()->GetLastCommittedItem(); |
| 2011 web::Referrer referrer(openerURL, item->GetReferrer().policy); |
| 2012 web::BlockedPopupInfo poupInfo(URL, referrer); |
| 2013 helper->HandlePopup(poupInfo); |
| 2034 return nil; | 2014 return nil; |
| 2035 } | 2015 } |
| 2036 } | 2016 } |
| 2037 | 2017 |
| 2018 // Requested web controller should not be blocked from opening. |
| 2038 [self updateSnapshotWithOverlay:YES visibleFrameOnly:YES]; | 2019 [self updateSnapshotWithOverlay:YES visibleFrameOnly:YES]; |
| 2039 Tab* tab = [parentTabModel_ | 2020 Tab* tab = [parentTabModel_ |
| 2040 insertBlankTabWithTransition:ui::PAGE_TRANSITION_LINK | 2021 insertBlankTabWithTransition:ui::PAGE_TRANSITION_LINK |
| 2041 opener:self | 2022 opener:self |
| 2042 openedByDOM:YES | 2023 openedByDOM:YES |
| 2043 atIndex:TabModelConstants::kTabPositionAutomatically | 2024 atIndex:TabModelConstants::kTabPositionAutomatically |
| 2044 inBackground:NO]; | 2025 inBackground:NO]; |
| 2045 return tab.webController; | 2026 return tab.webController; |
| 2046 } | 2027 } |
| 2047 | 2028 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2247 | 2228 |
| 2248 - (TabModel*)parentTabModel { | 2229 - (TabModel*)parentTabModel { |
| 2249 return parentTabModel_; | 2230 return parentTabModel_; |
| 2250 } | 2231 } |
| 2251 | 2232 |
| 2252 - (FormInputAccessoryViewController*)inputAccessoryViewController { | 2233 - (FormInputAccessoryViewController*)inputAccessoryViewController { |
| 2253 return inputAccessoryViewController_.get(); | 2234 return inputAccessoryViewController_.get(); |
| 2254 } | 2235 } |
| 2255 | 2236 |
| 2256 @end | 2237 @end |
| OLD | NEW |