| 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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 // Handles exportable files if possible. | 364 // Handles exportable files if possible. |
| 365 - (void)handleExportableFile:(net::HttpResponseHeaders*)headers; | 365 - (void)handleExportableFile:(net::HttpResponseHeaders*)headers; |
| 366 | 366 |
| 367 // Called after the session history is replaced, useful for updating members | 367 // Called after the session history is replaced, useful for updating members |
| 368 // with new sessionID. | 368 // with new sessionID. |
| 369 - (void)didReplaceSessionHistory; | 369 - (void)didReplaceSessionHistory; |
| 370 | 370 |
| 371 // Called when the UIApplication's state becomes active. | 371 // Called when the UIApplication's state becomes active. |
| 372 - (void)applicationDidBecomeActive; | 372 - (void)applicationDidBecomeActive; |
| 373 | 373 |
| 374 // Blocks popup for page with |popupURL|, requested by the page with | |
| 375 // |openerURL|. | |
| 376 - (void)blockPopupForURL:(const GURL&)popupURL openerURL:(const GURL&)openerURL; | |
| 377 | |
| 378 @end | 374 @end |
| 379 | 375 |
| 380 namespace { | 376 namespace { |
| 381 // TabHistoryContext is used by history to scope the lifetime of navigation | 377 // TabHistoryContext is used by history to scope the lifetime of navigation |
| 382 // entry references to Tab. | 378 // entry references to Tab. |
| 383 class TabHistoryContext : public history::Context { | 379 class TabHistoryContext : public history::Context { |
| 384 public: | 380 public: |
| 385 TabHistoryContext() {} | 381 TabHistoryContext() {} |
| 386 ~TabHistoryContext() {} | 382 ~TabHistoryContext() {} |
| 387 | 383 |
| (...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1466 if (requireReloadAfterBecomingActive_) { | 1462 if (requireReloadAfterBecomingActive_) { |
| 1467 if (visible_) { | 1463 if (visible_) { |
| 1468 [self.webController reload]; | 1464 [self.webController reload]; |
| 1469 } else { | 1465 } else { |
| 1470 [self.webController requirePageReload]; | 1466 [self.webController requirePageReload]; |
| 1471 } | 1467 } |
| 1472 requireReloadAfterBecomingActive_ = NO; | 1468 requireReloadAfterBecomingActive_ = NO; |
| 1473 } | 1469 } |
| 1474 } | 1470 } |
| 1475 | 1471 |
| 1476 - (void)blockPopupForURL:(const GURL&)popupURL | |
| 1477 openerURL:(const GURL&)openerURL { | |
| 1478 web::NavigationItem* item = [self navigationManager]->GetLastCommittedItem(); | |
| 1479 web::Referrer referrer(openerURL, item->GetReferrer().policy); | |
| 1480 GURL localPopupURL(popupURL); | |
| 1481 base::WeakNSObject<Tab> weakSelf(self); | |
| 1482 // TODO(crbug.com/692117): Remove |window_name| from constructor. | |
| 1483 web::BlockedPopupInfo poupInfo(popupURL, referrer, nil /* window_name */, ^{ | |
| 1484 web::WebState* webState = [weakSelf webState]; | |
| 1485 if (webState) { | |
| 1486 web::WebState::OpenURLParams params( | |
| 1487 localPopupURL, referrer, WindowOpenDisposition::NEW_POPUP, | |
| 1488 ui::PAGE_TRANSITION_LINK, true /* is_renderer_initiated */); | |
| 1489 params.url = localPopupURL; | |
| 1490 params.referrer = referrer; | |
| 1491 params.transition = ui::PAGE_TRANSITION_LINK; | |
| 1492 webState->OpenURL(params); | |
| 1493 } | |
| 1494 }); | |
| 1495 BlockedPopupTabHelper::FromWebState(self.webState)->HandlePopup(poupInfo); | |
| 1496 } | |
| 1497 | |
| 1498 #pragma mark - | 1472 #pragma mark - |
| 1499 #pragma mark FindInPageControllerDelegate | 1473 #pragma mark FindInPageControllerDelegate |
| 1500 | 1474 |
| 1501 - (void)willAdjustScrollPosition { | 1475 - (void)willAdjustScrollPosition { |
| 1502 // Skip the next attempt to correct the scroll offset for the toolbar height. | 1476 // Skip the next attempt to correct the scroll offset for the toolbar height. |
| 1503 // Used when programatically scrolling down the y offset. | 1477 // Used when programatically scrolling down the y offset. |
| 1504 [fullScreenController_ shouldSkipNextScrollOffsetForHeader]; | 1478 [fullScreenController_ shouldSkipNextScrollOffsetForHeader]; |
| 1505 } | 1479 } |
| 1506 | 1480 |
| 1507 #pragma mark - | 1481 #pragma mark - |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1978 | 1952 |
| 1979 - (void)webControllerDidSuppressDialog:(id)webController { | 1953 - (void)webControllerDidSuppressDialog:(id)webController { |
| 1980 DCHECK(isPrerenderTab_); | 1954 DCHECK(isPrerenderTab_); |
| 1981 [delegate_ discardPrerender]; | 1955 [delegate_ discardPrerender]; |
| 1982 } | 1956 } |
| 1983 | 1957 |
| 1984 - (CRWWebController*)webController:(CRWWebController*)webController | 1958 - (CRWWebController*)webController:(CRWWebController*)webController |
| 1985 createWebControllerForURL:(const GURL&)URL | 1959 createWebControllerForURL:(const GURL&)URL |
| 1986 openerURL:(const GURL&)openerURL | 1960 openerURL:(const GURL&)openerURL |
| 1987 initiatedByUser:(BOOL)initiatedByUser { | 1961 initiatedByUser:(BOOL)initiatedByUser { |
| 1962 // Check if requested web controller is a popup and block it if necessary. |
| 1988 if (!initiatedByUser) { | 1963 if (!initiatedByUser) { |
| 1989 auto helper = BlockedPopupTabHelper::FromWebState(webController.webState); | 1964 web::WebState* webState = webController.webState; |
| 1990 if (helper->ShouldBlockPopup(openerURL)) { | 1965 auto blockedPopupTabHelper = BlockedPopupTabHelper::FromWebState(webState); |
| 1991 [self blockPopupForURL:URL openerURL:openerURL]; | 1966 if (blockedPopupTabHelper->ShouldBlockPopup(openerURL)) { |
| 1967 web::NavigationItem* item = |
| 1968 webState->GetNavigationManager()->GetLastCommittedItem(); |
| 1969 web::Referrer referrer(openerURL, item->GetReferrer().policy); |
| 1970 web::BlockedPopupInfo poupInfo(URL, referrer); |
| 1971 blockedPopupTabHelper->HandlePopup(poupInfo); |
| 1992 return nil; | 1972 return nil; |
| 1993 } | 1973 } |
| 1994 } | 1974 } |
| 1995 | 1975 |
| 1976 // Requested web controller should not be blocked from opening. |
| 1996 [self updateSnapshotWithOverlay:YES visibleFrameOnly:YES]; | 1977 [self updateSnapshotWithOverlay:YES visibleFrameOnly:YES]; |
| 1997 Tab* tab = [parentTabModel_ | 1978 Tab* tab = [parentTabModel_ |
| 1998 insertBlankTabWithTransition:ui::PAGE_TRANSITION_LINK | 1979 insertBlankTabWithTransition:ui::PAGE_TRANSITION_LINK |
| 1999 opener:self | 1980 opener:self |
| 2000 openedByDOM:YES | 1981 openedByDOM:YES |
| 2001 atIndex:TabModelConstants::kTabPositionAutomatically | 1982 atIndex:TabModelConstants::kTabPositionAutomatically |
| 2002 inBackground:NO]; | 1983 inBackground:NO]; |
| 2003 return tab.webController; | 1984 return tab.webController; |
| 2004 } | 1985 } |
| 2005 | 1986 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2206 | 2187 |
| 2207 - (TabModel*)parentTabModel { | 2188 - (TabModel*)parentTabModel { |
| 2208 return parentTabModel_; | 2189 return parentTabModel_; |
| 2209 } | 2190 } |
| 2210 | 2191 |
| 2211 - (FormInputAccessoryViewController*)inputAccessoryViewController { | 2192 - (FormInputAccessoryViewController*)inputAccessoryViewController { |
| 2212 return inputAccessoryViewController_.get(); | 2193 return inputAccessoryViewController_.get(); |
| 2213 } | 2194 } |
| 2214 | 2195 |
| 2215 @end | 2196 @end |
| OLD | NEW |