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

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

Issue 2718273003: Change return type of Tab -navigationManager. (Closed)
Patch Set: Fix BrowserViewControllerTest unit tests. 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 | « ios/chrome/browser/tabs/tab.h ('k') | ios/chrome/browser/tabs/tab_model.mm » ('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 855 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 if (![self.webController isViewAlive] && [parentTabModel_ tabUsageRecorder]) { 866 if (![self.webController isViewAlive] && [parentTabModel_ tabUsageRecorder]) {
867 [parentTabModel_ tabUsageRecorder]->RecordPageLoadStart(self); 867 [parentTabModel_ tabUsageRecorder]->RecordPageLoadStart(self);
868 } 868 }
869 return self.webState ? self.webState->GetView() : nil; 869 return self.webState ? self.webState->GetView() : nil;
870 } 870 }
871 871
872 - (UIView*)viewForPrinting { 872 - (UIView*)viewForPrinting {
873 return self.webController.viewForPrinting; 873 return self.webController.viewForPrinting;
874 } 874 }
875 875
876 - (NavigationManagerImpl*)navigationManager { 876 - (web::NavigationManager*)navigationManager {
877 if (!webStateImpl_) 877 return webStateImpl_ ? webStateImpl_->GetNavigationManager() : nullptr;
878 return nil; 878 }
879 return &(webStateImpl_->GetNavigationManagerImpl()); 879
880 - (web::NavigationManagerImpl*)navigationManagerImpl {
881 return webStateImpl_ ? &(webStateImpl_->GetNavigationManagerImpl()) : nullptr;
880 } 882 }
881 883
882 - (id<StoreKitLauncher>)storeKitLauncher { 884 - (id<StoreKitLauncher>)storeKitLauncher {
883 return storeKitLauncher_.get(); 885 return storeKitLauncher_.get();
884 } 886 }
885 887
886 - (void)setStoreKitLauncher:(id<StoreKitLauncher>)storeKitLauncher { 888 - (void)setStoreKitLauncher:(id<StoreKitLauncher>)storeKitLauncher {
887 storeKitLauncher_.reset(storeKitLauncher); 889 storeKitLauncher_.reset(storeKitLauncher);
888 } 890 }
889 891
890 // Swap out the existing session history with a new list of navigations. Forces 892 // Swap out the existing session history with a new list of navigations. Forces
891 // the tab to reload to update the UI accordingly. This is ok because none of 893 // the tab to reload to update the UI accordingly. This is ok because none of
892 // the session history is stored in the tab; it's always fetched through the 894 // the session history is stored in the tab; it's always fetched through the
893 // navigation manager. 895 // navigation manager.
894 - (void)replaceHistoryWithNavigations: 896 - (void)replaceHistoryWithNavigations:
895 (const std::vector<sessions::SerializedNavigationEntry>&)navigations 897 (const std::vector<sessions::SerializedNavigationEntry>&)navigations
896 currentIndex:(NSInteger)currentIndex { 898 currentIndex:(NSInteger)currentIndex {
897 std::vector<std::unique_ptr<web::NavigationItem>> items = 899 std::vector<std::unique_ptr<web::NavigationItem>> items =
898 sessions::IOSSerializedNavigationBuilder::ToNavigationItems(navigations); 900 sessions::IOSSerializedNavigationBuilder::ToNavigationItems(navigations);
899 [self navigationManager]->ReplaceSessionHistory(std::move(items), 901 [self navigationManagerImpl]->ReplaceSessionHistory(std::move(items),
900 currentIndex); 902 currentIndex);
901 [self didReplaceSessionHistory]; 903 [self didReplaceSessionHistory];
902 904
903 [self.webController loadCurrentURL]; 905 [self.webController loadCurrentURL];
904 } 906 }
905 907
906 - (void)didReplaceSessionHistory { 908 - (void)didReplaceSessionHistory {
907 // Replace fullScreenController_ with a new sessionID when the navigation 909 // Replace fullScreenController_ with a new sessionID when the navigation
908 // manager changes. 910 // manager changes.
909 // TODO(crbug.com/661666): Consider just updating sessionID and not replacing 911 // TODO(crbug.com/661666): Consider just updating sessionID and not replacing
910 // |fullScreenController_|. 912 // |fullScreenController_|.
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 } 1269 }
1268 1270
1269 - (void)dismissModals { 1271 - (void)dismissModals {
1270 [openInController_ disable]; 1272 [openInController_ disable];
1271 [self.webController dismissModals]; 1273 [self.webController dismissModals];
1272 } 1274 }
1273 1275
1274 - (web::NavigationItem*)currentNavigationItem { 1276 - (web::NavigationItem*)currentNavigationItem {
1275 if (![self navigationManager]) 1277 if (![self navigationManager])
1276 return nil; 1278 return nil;
1277 return [[self navigationManager]->GetSessionController() currentItem]; 1279 return [[self navigationManagerImpl]->GetSessionController() currentItem];
1278 } 1280 }
1279 1281
1280 - (void)setShouldObserveInfoBarManager:(BOOL)shouldObserveInfoBarManager { 1282 - (void)setShouldObserveInfoBarManager:(BOOL)shouldObserveInfoBarManager {
1281 tabInfoBarObserver_->SetShouldObserveInfoBarManager( 1283 tabInfoBarObserver_->SetShouldObserveInfoBarManager(
1282 shouldObserveInfoBarManager); 1284 shouldObserveInfoBarManager);
1283 } 1285 }
1284 1286
1285 - (void)setShouldObserveFaviconChanges:(BOOL)shouldObserveFaviconChanges { 1287 - (void)setShouldObserveFaviconChanges:(BOOL)shouldObserveFaviconChanges {
1286 if (shouldObserveFaviconChanges) { 1288 if (shouldObserveFaviconChanges) {
1287 favicon::FaviconDriver* faviconDriver = 1289 favicon::FaviconDriver* faviconDriver =
(...skipping 30 matching lines...) Expand all
1318 1320
1319 - (BOOL)canGoForward { 1321 - (BOOL)canGoForward {
1320 return self.navigationManager && self.navigationManager->CanGoForward(); 1322 return self.navigationManager && self.navigationManager->CanGoForward();
1321 } 1323 }
1322 1324
1323 - (void)goToItem:(const web::NavigationItem*)item { 1325 - (void)goToItem:(const web::NavigationItem*)item {
1324 DCHECK(item); 1326 DCHECK(item);
1325 1327
1326 if (self.navigationManager) { 1328 if (self.navigationManager) {
1327 CRWSessionController* sessionController = 1329 CRWSessionController* sessionController =
1328 self.navigationManager->GetSessionController(); 1330 [self navigationManagerImpl]->GetSessionController();
1329 NSInteger itemIndex = [sessionController indexOfItem:item]; 1331 NSInteger itemIndex = [sessionController indexOfItem:item];
1330 DCHECK_NE(itemIndex, NSNotFound); 1332 DCHECK_NE(itemIndex, NSNotFound);
1331 self.navigationManager->GoToIndex(itemIndex); 1333 self.navigationManager->GoToIndex(itemIndex);
1332 } 1334 }
1333 } 1335 }
1334 1336
1335 - (BOOL)openExternalURL:(const GURL&)url linkClicked:(BOOL)linkClicked { 1337 - (BOOL)openExternalURL:(const GURL&)url linkClicked:(BOOL)linkClicked {
1336 if (!externalAppLauncher_.get()) 1338 if (!externalAppLauncher_.get())
1337 externalAppLauncher_.reset([[ExternalAppLauncher alloc] init]); 1339 externalAppLauncher_.reset([[ExternalAppLauncher alloc] init]);
1338 1340
(...skipping 29 matching lines...) Expand all
1368 1370
1369 if (!finalURL.is_valid()) { 1371 if (!finalURL.is_valid()) {
1370 return NO; 1372 return NO;
1371 } 1373 }
1372 } 1374 }
1373 1375
1374 if ([externalAppLauncher_ openURL:finalURL linkClicked:linkClicked]) { 1376 if ([externalAppLauncher_ openURL:finalURL linkClicked:linkClicked]) {
1375 // Clears pending navigation history after successfully launching the 1377 // Clears pending navigation history after successfully launching the
1376 // external app. 1378 // external app.
1377 DCHECK([self navigationManager]); 1379 DCHECK([self navigationManager]);
1378 [[self navigationManager]->GetSessionController() discardNonCommittedItems]; 1380 [self navigationManager]->DiscardNonCommittedItems();
1379 // Ensure the UI reflects the current entry, not the just-discarded pending 1381 // Ensure the UI reflects the current entry, not the just-discarded pending
1380 // entry. 1382 // entry.
1381 [parentTabModel_ notifyTabChanged:self]; 1383 [parentTabModel_ notifyTabChanged:self];
1382 return YES; 1384 return YES;
1383 } 1385 }
1384 return NO; 1386 return NO;
1385 } 1387 }
1386 1388
1387 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry { 1389 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry {
1388 [parentTabModel_ notifyTabChanged:self]; 1390 [parentTabModel_ notifyTabChanged:self];
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 1596
1595 // TODO(crbug.com/228171): A hack in session_controller -addPendingItem 1597 // TODO(crbug.com/228171): A hack in session_controller -addPendingItem
1596 // discusses making tab responsible for distinguishing history stack 1598 // discusses making tab responsible for distinguishing history stack
1597 // navigation from new navigations. Because we want a new navigation here, we 1599 // navigation from new navigations. Because we want a new navigation here, we
1598 // use |PAGE_TRANSITION_FORM_SUBMIT|. When session_controller changes, so 1600 // use |PAGE_TRANSITION_FORM_SUBMIT|. When session_controller changes, so
1599 // should this. 1601 // should this.
1600 ui::PageTransition transition = 1602 ui::PageTransition transition =
1601 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_FORM_SUBMIT); 1603 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_FORM_SUBMIT);
1602 DCHECK([self navigationManager]); 1604 DCHECK([self navigationManager]);
1603 CRWSessionController* sessionController = 1605 CRWSessionController* sessionController =
1604 [self navigationManager]->GetSessionController(); 1606 [self navigationManagerImpl]->GetSessionController();
1605 web::NavigationItem* lastUserItem = [sessionController lastUserItem]; 1607 web::NavigationItem* lastUserItem = [sessionController lastUserItem];
1606 if (!lastUserItem) 1608 if (!lastUserItem)
1607 return; 1609 return;
1608 1610
1609 // |originalUrl| will be empty if a page was open by DOM. 1611 // |originalUrl| will be empty if a page was open by DOM.
1610 GURL reloadURL(lastUserItem->GetOriginalRequestURL()); 1612 GURL reloadURL(lastUserItem->GetOriginalRequestURL());
1611 if (reloadURL.is_empty()) { 1613 if (reloadURL.is_empty()) {
1612 DCHECK(sessionController.openedByDOM); 1614 DCHECK(sessionController.openedByDOM);
1613 reloadURL = lastUserItem->GetVirtualURL(); 1615 reloadURL = lastUserItem->GetVirtualURL();
1614 } 1616 }
(...skipping 18 matching lines...) Expand all
1633 DCHECK(U2FController_); 1635 DCHECK(U2FController_);
1634 [U2FController_ evaluateU2FResultFromU2FURL:URL webState:self.webState]; 1636 [U2FController_ evaluateU2FResultFromU2FURL:URL webState:self.webState];
1635 } 1637 }
1636 1638
1637 #pragma mark - CRWWebDelegate and CRWWebStateObserver protocol methods. 1639 #pragma mark - CRWWebDelegate and CRWWebStateObserver protocol methods.
1638 1640
1639 // The web page wants to close its own window. 1641 // The web page wants to close its own window.
1640 - (void)webPageOrderedClose { 1642 - (void)webPageOrderedClose {
1641 // Only allow a web page to close itself if it was opened by DOM, or if there 1643 // Only allow a web page to close itself if it was opened by DOM, or if there
1642 // are no navigation items. 1644 // are no navigation items.
1643 DCHECK([[self navigationManager]->GetSessionController() isOpenedByDOM] || 1645 DCHECK([[self navigationManagerImpl]->GetSessionController() isOpenedByDOM] ||
1644 ![self navigationManager]->GetItemCount()); 1646 ![self navigationManager]->GetItemCount());
1645 [self closeThisTab]; 1647 [self closeThisTab];
1646 } 1648 }
1647 1649
1648 // This method is invoked whenever the system believes the URL is about to 1650 // This method is invoked whenever the system believes the URL is about to
1649 // change, or immediately after any unexpected change of the URL. The apparent 1651 // change, or immediately after any unexpected change of the URL. The apparent
1650 // destination URL is included in the |url| parameter. 1652 // destination URL is included in the |url| parameter.
1651 // Warning: because of the present design it is possible for malicious websites 1653 // Warning: because of the present design it is possible for malicious websites
1652 // to invoke superflous instances of this delegate with artibrary URLs. 1654 // to invoke superflous instances of this delegate with artibrary URLs.
1653 // Ensure there is nothing here that could be a risk to the user beyond mild 1655 // Ensure there is nothing here that could be a risk to the user beyond mild
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 return YES; 1870 return YES;
1869 } 1871 }
1870 1872
1871 // Auto-open didn't work. Reset the auto-open flag. 1873 // Auto-open didn't work. Reset the auto-open flag.
1872 [metadata unsetShouldAutoOpenLinks]; 1874 [metadata unsetShouldAutoOpenLinks];
1873 return NO; 1875 return NO;
1874 } 1876 }
1875 1877
1876 - (double)lastVisitedTimestamp { 1878 - (double)lastVisitedTimestamp {
1877 DCHECK([self navigationManager]); 1879 DCHECK([self navigationManager]);
1878 return 1880 return [[self navigationManagerImpl]->GetSessionController()
1879 [[self navigationManager]->GetSessionController() lastVisitedTimestamp]; 1881 lastVisitedTimestamp];
1880 } 1882 }
1881 1883
1882 - (void)updateLastVisitedTimestamp { 1884 - (void)updateLastVisitedTimestamp {
1883 // Stores this information in self.history and it will be written into disc 1885 // Stores this information in self.history and it will be written into disc
1884 // with other information when needed. 1886 // with other information when needed.
1885 DCHECK([self navigationManager]); 1887 DCHECK([self navigationManager]);
1886 [[self navigationManager]->GetSessionController() 1888 [[self navigationManagerImpl]->GetSessionController()
1887 setLastVisitedTimestamp:[[NSDate date] timeIntervalSince1970]]; 1889 setLastVisitedTimestamp:[[NSDate date] timeIntervalSince1970]];
1888 } 1890 }
1889 1891
1890 - (infobars::InfoBarManager*)infoBarManager { 1892 - (infobars::InfoBarManager*)infoBarManager {
1891 DCHECK(self.webState); 1893 DCHECK(self.webState);
1892 return InfoBarManagerImpl::FromWebState(self.webState); 1894 return InfoBarManagerImpl::FromWebState(self.webState);
1893 } 1895 }
1894 1896
1895 - (NSArray*)snapshotOverlays { 1897 - (NSArray*)snapshotOverlays {
1896 return [snapshotOverlayProvider_ snapshotOverlaysForTab:self]; 1898 return [snapshotOverlayProvider_ snapshotOverlaysForTab:self];
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
2232 2234
2233 - (TabModel*)parentTabModel { 2235 - (TabModel*)parentTabModel {
2234 return parentTabModel_; 2236 return parentTabModel_;
2235 } 2237 }
2236 2238
2237 - (FormInputAccessoryViewController*)inputAccessoryViewController { 2239 - (FormInputAccessoryViewController*)inputAccessoryViewController {
2238 return inputAccessoryViewController_.get(); 2240 return inputAccessoryViewController_.get();
2239 } 2241 }
2240 2242
2241 @end 2243 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/tabs/tab.h ('k') | ios/chrome/browser/tabs/tab_model.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698