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

Side by Side Diff: ios/chrome/browser/tabs/tab.mm

Issue 2757073002: Cleanup of how -enableDesktopUserAgent uses NavigationManager utility. (Closed)
Patch Set: Added DCHECK Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | ios/chrome/browser/web/navigation_manager_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 visibleItem->GetUserAgentType() == web::UserAgentType::DESKTOP; 1482 visibleItem->GetUserAgentType() == web::UserAgentType::DESKTOP;
1483 } 1483 }
1484 1484
1485 - (void)enableDesktopUserAgent { 1485 - (void)enableDesktopUserAgent {
1486 DCHECK_EQ(self.usesDesktopUserAgent, NO); 1486 DCHECK_EQ(self.usesDesktopUserAgent, NO);
1487 DCHECK([self navigationManager]); 1487 DCHECK([self navigationManager]);
1488 [self navigationManager]->OverrideDesktopUserAgentForNextPendingItem(); 1488 [self navigationManager]->OverrideDesktopUserAgentForNextPendingItem();
1489 } 1489 }
1490 1490
1491 - (void)reloadForDesktopUserAgent { 1491 - (void)reloadForDesktopUserAgent {
1492 // |loadWithParams| will recreate the removed UIWebView. 1492 // This removes the web view, which will be recreated at the end of this.
1493 [self.webController requirePageReconstruction]; 1493 [self.webController requirePageReconstruction];
1494 1494
1495 // TODO(crbug.com/228171): A hack in session_controller -addPendingItem 1495 // TODO(crbug.com/228171): A hack in session_controller -addPendingItem
1496 // discusses making tab responsible for distinguishing history stack 1496 // discusses making tab responsible for distinguishing history stack
1497 // navigation from new navigations. Because we want a new navigation here, we 1497 // navigation from new navigations.
1498 // use |PAGE_TRANSITION_FORM_SUBMIT|. When session_controller changes, so 1498 web::NavigationManager* navigationManager = [self navigationManager];
1499 // should this. 1499 DCHECK(navigationManager);
1500 ui::PageTransition transition =
1501 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_FORM_SUBMIT);
1502 DCHECK([self navigationManager]);
1503 web::NavigationItem* lastNonRedirectedItem = 1500 web::NavigationItem* lastNonRedirectedItem =
1504 GetLastNonRedirectedItem([self navigationManager]); 1501 GetLastNonRedirectedItem(navigationManager);
1505 if (!lastNonRedirectedItem) 1502 if (!lastNonRedirectedItem)
1506 return; 1503 return;
1507 1504
1508 // |originalUrl| will be empty if a page was open by DOM. 1505 // |reloadURL| will be empty if a page was open by DOM.
1509 GURL reloadURL(lastNonRedirectedItem->GetOriginalRequestURL()); 1506 GURL reloadURL(lastNonRedirectedItem->GetOriginalRequestURL());
1510 if (reloadURL.is_empty()) { 1507 if (reloadURL.is_empty()) {
1511 DCHECK( 1508 DCHECK(
1512 [[self navigationManagerImpl]->GetSessionController() isOpenedByDOM]); 1509 [[self navigationManagerImpl]->GetSessionController() isOpenedByDOM]);
1513 reloadURL = lastNonRedirectedItem->GetVirtualURL(); 1510 reloadURL = lastNonRedirectedItem->GetVirtualURL();
1514 } 1511 }
1515 1512
1516 web::NavigationManager::WebLoadParams params(reloadURL); 1513 web::NavigationManager::WebLoadParams params(reloadURL);
1517 params.referrer = lastNonRedirectedItem->GetReferrer(); 1514 params.referrer = lastNonRedirectedItem->GetReferrer();
1518 params.transition_type = transition; 1515 // A new navigation is needed here for reloading with desktop User-Agent.
1519 if (self.navigationManager) 1516 params.transition_type =
1520 self.navigationManager->LoadURLWithParams(params); 1517 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_FORM_SUBMIT);
1518 navigationManager->LoadURLWithParams(params);
1521 } 1519 }
1522 1520
1523 - (id<SnapshotOverlayProvider>)snapshotOverlayProvider { 1521 - (id<SnapshotOverlayProvider>)snapshotOverlayProvider {
1524 return snapshotOverlayProvider_.get(); 1522 return snapshotOverlayProvider_.get();
1525 } 1523 }
1526 1524
1527 - (void)setSnapshotOverlayProvider: 1525 - (void)setSnapshotOverlayProvider:
1528 (id<SnapshotOverlayProvider>)snapshotOverlayProvider { 1526 (id<SnapshotOverlayProvider>)snapshotOverlayProvider {
1529 snapshotOverlayProvider_.reset(snapshotOverlayProvider); 1527 snapshotOverlayProvider_.reset(snapshotOverlayProvider);
1530 } 1528 }
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
2100 2098
2101 - (TabModel*)parentTabModel { 2099 - (TabModel*)parentTabModel {
2102 return parentTabModel_; 2100 return parentTabModel_;
2103 } 2101 }
2104 2102
2105 - (FormInputAccessoryViewController*)inputAccessoryViewController { 2103 - (FormInputAccessoryViewController*)inputAccessoryViewController {
2106 return inputAccessoryViewController_.get(); 2104 return inputAccessoryViewController_.get();
2107 } 2105 }
2108 2106
2109 @end 2107 @end
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/web/navigation_manager_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698