| 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 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 referrer:(const web::Referrer&)referrer | 615 referrer:(const web::Referrer&)referrer |
| 616 transition:(ui::PageTransition)transition | 616 transition:(ui::PageTransition)transition |
| 617 provider:(id<CRWNativeContentProvider>)provider | 617 provider:(id<CRWNativeContentProvider>)provider |
| 618 opener:(Tab*)opener | 618 opener:(Tab*)opener |
| 619 desktopUserAgent:(BOOL)desktopUserAgent | 619 desktopUserAgent:(BOOL)desktopUserAgent |
| 620 configuration:(void (^)(Tab*))configuration { | 620 configuration:(void (^)(Tab*))configuration { |
| 621 Tab* tab = [[[Tab alloc] initWithBrowserState:browserState | 621 Tab* tab = [[[Tab alloc] initWithBrowserState:browserState |
| 622 opener:opener | 622 opener:opener |
| 623 openedByDOM:NO | 623 openedByDOM:NO |
| 624 model:nil] autorelease]; | 624 model:nil] autorelease]; |
| 625 if (desktopUserAgent) | |
| 626 [tab enableDesktopUserAgent]; | |
| 627 [[tab webController] setNativeProvider:provider]; | 625 [[tab webController] setNativeProvider:provider]; |
| 628 [[tab webController] setWebUsageEnabled:YES]; | 626 [[tab webController] setWebUsageEnabled:YES]; |
| 629 | 627 |
| 630 if (configuration) | 628 if (configuration) |
| 631 configuration(tab); | 629 configuration(tab); |
| 632 | 630 |
| 633 web::NavigationManager::WebLoadParams params(URL); | 631 web::NavigationManager::WebLoadParams params(URL); |
| 634 params.transition_type = transition; | 632 params.transition_type = transition; |
| 635 params.referrer = referrer; | 633 params.referrer = referrer; |
| 634 if (desktopUserAgent) { |
| 635 params.user_agent_override_option = |
| 636 web::NavigationManager::UserAgentOverrideOption::DESKTOP; |
| 637 } |
| 638 |
| 636 [[tab webController] loadWithParams:params]; | 639 [[tab webController] loadWithParams:params]; |
| 637 | 640 |
| 638 return tab; | 641 return tab; |
| 639 } | 642 } |
| 640 | 643 |
| 641 - (void)dealloc { | 644 - (void)dealloc { |
| 642 DCHECK([NSThread isMainThread]); | 645 DCHECK([NSThread isMainThread]); |
| 643 // Note that -[CRWWebController close] has already been called, so nothing | 646 // Note that -[CRWWebController close] has already been called, so nothing |
| 644 // significant should be done with it in this method. | 647 // significant should be done with it in this method. |
| 645 DCHECK_NE(self.webController.delegate, self); | 648 DCHECK_NE(self.webController.delegate, self); |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1477 | 1480 |
| 1478 - (BOOL)usesDesktopUserAgent { | 1481 - (BOOL)usesDesktopUserAgent { |
| 1479 if (!self.navigationManager) | 1482 if (!self.navigationManager) |
| 1480 return NO; | 1483 return NO; |
| 1481 | 1484 |
| 1482 web::NavigationItem* visibleItem = self.navigationManager->GetVisibleItem(); | 1485 web::NavigationItem* visibleItem = self.navigationManager->GetVisibleItem(); |
| 1483 return visibleItem && | 1486 return visibleItem && |
| 1484 visibleItem->GetUserAgentType() == web::UserAgentType::DESKTOP; | 1487 visibleItem->GetUserAgentType() == web::UserAgentType::DESKTOP; |
| 1485 } | 1488 } |
| 1486 | 1489 |
| 1487 - (void)enableDesktopUserAgent { | |
| 1488 DCHECK_EQ(self.usesDesktopUserAgent, NO); | |
| 1489 DCHECK([self navigationManager]); | |
| 1490 [self navigationManager]->OverrideDesktopUserAgentForNextPendingItem(); | |
| 1491 } | |
| 1492 | |
| 1493 - (void)reloadForDesktopUserAgent { | 1490 - (void)reloadForDesktopUserAgent { |
| 1494 // This removes the web view, which will be recreated at the end of this. | 1491 // This removes the web view, which will be recreated at the end of this. |
| 1495 [self.webController requirePageReconstruction]; | 1492 [self.webController requirePageReconstruction]; |
| 1496 | 1493 |
| 1497 // TODO(crbug.com/228171): A hack in session_controller -addPendingItem | 1494 // TODO(crbug.com/228171): A hack in session_controller -addPendingItem |
| 1498 // discusses making tab responsible for distinguishing history stack | 1495 // discusses making tab responsible for distinguishing history stack |
| 1499 // navigation from new navigations. | 1496 // navigation from new navigations. |
| 1500 web::NavigationManager* navigationManager = [self navigationManager]; | 1497 web::NavigationManager* navigationManager = [self navigationManager]; |
| 1501 DCHECK(navigationManager); | 1498 DCHECK(navigationManager); |
| 1502 web::NavigationItem* lastNonRedirectedItem = | 1499 web::NavigationItem* lastNonRedirectedItem = |
| 1503 GetLastNonRedirectedItem(navigationManager); | 1500 GetLastNonRedirectedItem(navigationManager); |
| 1504 if (!lastNonRedirectedItem) | 1501 if (!lastNonRedirectedItem) |
| 1505 return; | 1502 return; |
| 1506 | 1503 |
| 1507 // |reloadURL| will be empty if a page was open by DOM. | 1504 // |reloadURL| will be empty if a page was open by DOM. |
| 1508 GURL reloadURL(lastNonRedirectedItem->GetOriginalRequestURL()); | 1505 GURL reloadURL(lastNonRedirectedItem->GetOriginalRequestURL()); |
| 1509 if (reloadURL.is_empty()) { | 1506 if (reloadURL.is_empty()) { |
| 1510 DCHECK(self.webState && self.webState->HasOpener()); | 1507 DCHECK(self.webState && self.webState->HasOpener()); |
| 1511 reloadURL = lastNonRedirectedItem->GetVirtualURL(); | 1508 reloadURL = lastNonRedirectedItem->GetVirtualURL(); |
| 1512 } | 1509 } |
| 1513 | 1510 |
| 1514 web::NavigationManager::WebLoadParams params(reloadURL); | 1511 web::NavigationManager::WebLoadParams params(reloadURL); |
| 1515 params.referrer = lastNonRedirectedItem->GetReferrer(); | 1512 params.referrer = lastNonRedirectedItem->GetReferrer(); |
| 1516 // A new navigation is needed here for reloading with desktop User-Agent. | 1513 // A new navigation is needed here for reloading with desktop User-Agent. |
| 1514 params.user_agent_override_option = |
| 1515 web::NavigationManager::UserAgentOverrideOption::DESKTOP; |
| 1517 params.transition_type = | 1516 params.transition_type = |
| 1518 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_FORM_SUBMIT); | 1517 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_FORM_SUBMIT); |
| 1519 navigationManager->LoadURLWithParams(params); | 1518 navigationManager->LoadURLWithParams(params); |
| 1520 } | 1519 } |
| 1521 | 1520 |
| 1522 - (id<SnapshotOverlayProvider>)snapshotOverlayProvider { | 1521 - (id<SnapshotOverlayProvider>)snapshotOverlayProvider { |
| 1523 return snapshotOverlayProvider_.get(); | 1522 return snapshotOverlayProvider_.get(); |
| 1524 } | 1523 } |
| 1525 | 1524 |
| 1526 - (void)setSnapshotOverlayProvider: | 1525 - (void)setSnapshotOverlayProvider: |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2087 | 2086 |
| 2088 - (TabModel*)parentTabModel { | 2087 - (TabModel*)parentTabModel { |
| 2089 return parentTabModel_; | 2088 return parentTabModel_; |
| 2090 } | 2089 } |
| 2091 | 2090 |
| 2092 - (FormInputAccessoryViewController*)inputAccessoryViewController { | 2091 - (FormInputAccessoryViewController*)inputAccessoryViewController { |
| 2093 return inputAccessoryViewController_.get(); | 2092 return inputAccessoryViewController_.get(); |
| 2094 } | 2093 } |
| 2095 | 2094 |
| 2096 @end | 2095 @end |
| OLD | NEW |