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

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

Issue 2724103005: Remove Tab -currentNavigationItem. (Closed)
Patch Set: Rebase. 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/tabs/tab_private.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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 // C++ bridge that receives notifications from the FaviconDriver. 321 // C++ bridge that receives notifications from the FaviconDriver.
322 std::unique_ptr<FaviconDriverObserverBridge> faviconDriverObserverBridge_; 322 std::unique_ptr<FaviconDriverObserverBridge> faviconDriverObserverBridge_;
323 323
324 // U2F call controller object. 324 // U2F call controller object.
325 base::scoped_nsobject<U2FController> U2FController_; 325 base::scoped_nsobject<U2FController> U2FController_;
326 326
327 // C++ observer used to trigger snapshots after the removal of InfoBars. 327 // C++ observer used to trigger snapshots after the removal of InfoBars.
328 std::unique_ptr<TabInfoBarObserver> tabInfoBarObserver_; 328 std::unique_ptr<TabInfoBarObserver> tabInfoBarObserver_;
329 } 329 }
330 330
331 // Returns the current NavigationItem for the sesionController associated with
332 // this tab. Don't use this to get the underlying NavigationItem; instead
333 // go through the NavigationManager.
334 // This is nil if there's no NavigationManager.
335 @property(nonatomic, readonly) web::NavigationItem* currentNavigationItem;
336
337 // Returns the tab's reader mode controller. May contain nil if the feature is 331 // Returns the tab's reader mode controller. May contain nil if the feature is
338 // disabled. 332 // disabled.
339 @property(nonatomic, readonly) ReaderModeController* readerModeController; 333 @property(nonatomic, readonly) ReaderModeController* readerModeController;
340 334
341 // Returns a list of FormSuggestionProviders to be queried for suggestions 335 // Returns a list of FormSuggestionProviders to be queried for suggestions
342 // in order of priority. 336 // in order of priority.
343 - (NSArray*)suggestionProviders; 337 - (NSArray*)suggestionProviders;
344 338
345 // Returns a list of FormInputAccessoryViewProviders to be queried for an input 339 // Returns a list of FormInputAccessoryViewProviders to be queried for an input
346 // accessory view in order of priority. 340 // accessory view in order of priority.
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 - (void)retrieveSnapshot:(void (^)(UIImage*))callback { 751 - (void)retrieveSnapshot:(void (^)(UIImage*))callback {
758 [webControllerSnapshotHelper_ 752 [webControllerSnapshotHelper_
759 retrieveSnapshotForWebController:self.webController 753 retrieveSnapshotForWebController:self.webController
760 sessionID:self.tabId 754 sessionID:self.tabId
761 withOverlays:[self snapshotOverlays] 755 withOverlays:[self snapshotOverlays]
762 callback:callback]; 756 callback:callback];
763 } 757 }
764 758
765 - (const GURL&)url { 759 - (const GURL&)url {
766 // See note in header; this method should be removed. 760 // See note in header; this method should be removed.
767 web::NavigationItem* item = [self currentNavigationItem]; 761 web::NavigationItem* item =
762 [[self navigationManagerImpl]->GetSessionController() currentItem];
768 return item ? item->GetVirtualURL() : GURL::EmptyGURL(); 763 return item ? item->GetVirtualURL() : GURL::EmptyGURL();
769 } 764 }
770 765
771 - (NSString*)title { 766 - (NSString*)title {
772 base::string16 title = webStateImpl_->GetTitle(); 767 base::string16 title = webStateImpl_->GetTitle();
773 if (title.empty()) 768 if (title.empty())
774 title = l10n_util::GetStringUTF16(IDS_DEFAULT_TAB_TITLE); 769 title = l10n_util::GetStringUTF16(IDS_DEFAULT_TAB_TITLE);
775 return base::SysUTF16ToNSString(title); 770 return base::SysUTF16ToNSString(title);
776 } 771 }
777 772
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 return; 1034 return;
1040 1035
1041 history::HistoryService* historyService = 1036 history::HistoryService* historyService =
1042 ios::HistoryServiceFactory::GetForBrowserState( 1037 ios::HistoryServiceFactory::GetForBrowserState(
1043 browserState_, ServiceAccessType::IMPLICIT_ACCESS); 1038 browserState_, ServiceAccessType::IMPLICIT_ACCESS);
1044 DCHECK(historyService); 1039 DCHECK(historyService);
1045 historyService->SetPageTitle(self.url, base::SysNSStringToUTF16(title)); 1040 historyService->SetPageTitle(self.url, base::SysNSStringToUTF16(title));
1046 } 1041 }
1047 1042
1048 - (void)addCurrentEntryToHistoryDB { 1043 - (void)addCurrentEntryToHistoryDB {
1049 DCHECK(self.currentNavigationItem); 1044 DCHECK([self navigationManager]->GetVisibleItem());
1050 // If incognito, don't update history. 1045 // If incognito, don't update history.
1051 if (browserState_->IsOffTheRecord()) 1046 if (browserState_->IsOffTheRecord())
1052 return; 1047 return;
1053 1048
1054 web::NavigationItem* item = [self navigationManager]->GetVisibleItem(); 1049 web::NavigationItem* item = [self navigationManager]->GetVisibleItem();
1055 1050
1056 // Do not update the history db for back/forward navigations. 1051 // Do not update the history db for back/forward navigations.
1057 // TODO(crbug.com/661667): We do not currently tag the entry with a 1052 // TODO(crbug.com/661667): We do not currently tag the entry with a
1058 // FORWARD_BACK transition. Fix. 1053 // FORWARD_BACK transition. Fix.
1059 if (item->GetTransitionType() & ui::PAGE_TRANSITION_FORWARD_BACK) 1054 if (item->GetTransitionType() & ui::PAGE_TRANSITION_FORWARD_BACK)
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 !PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD) && 1157 !PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD) &&
1163 (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) == 0) { 1158 (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) == 0) {
1164 base::RecordAction(UserMetricsAction("MobileTabClobbered")); 1159 base::RecordAction(UserMetricsAction("MobileTabClobbered"));
1165 } 1160 }
1166 if ([parentTabModel_ tabUsageRecorder]) 1161 if ([parentTabModel_ tabUsageRecorder])
1167 [parentTabModel_ tabUsageRecorder]->RecordPageLoadStart(self); 1162 [parentTabModel_ tabUsageRecorder]->RecordPageLoadStart(self);
1168 1163
1169 // Reset |isVoiceSearchResultsTab| since a new page is being navigated to. 1164 // Reset |isVoiceSearchResultsTab| since a new page is being navigated to.
1170 self.isVoiceSearchResultsTab = NO; 1165 self.isVoiceSearchResultsTab = NO;
1171 1166
1167 web::NavigationItem* navigationItem =
1168 [self navigationManager]->GetPendingItem();
1169
1170 // TODO(crbug.com/676129): the pending item is not correctly set when the
1171 // page is reloading, use the last committed item if pending item is null.
1172 // Remove this once tracking bug is fixed.
1173 if (!navigationItem)
1174 navigationItem = [self navigationManager]->GetLastCommittedItem();
1175
1172 [[OmniboxGeolocationController sharedInstance] 1176 [[OmniboxGeolocationController sharedInstance]
1173 addLocationToNavigationItem:self.currentNavigationItem 1177 addLocationToNavigationItem:navigationItem
1174 browserState:browserState_]; 1178 browserState:browserState_];
1175 } 1179 }
1176 1180
1177 - (void)loadSessionTab:(const sessions::SessionTab*)sessionTab { 1181 - (void)loadSessionTab:(const sessions::SessionTab*)sessionTab {
1178 DCHECK(sessionTab); 1182 DCHECK(sessionTab);
1179 [self replaceHistoryWithNavigations:sessionTab->navigations 1183 [self replaceHistoryWithNavigations:sessionTab->navigations
1180 currentIndex:sessionTab->current_navigation_index]; 1184 currentIndex:sessionTab->current_navigation_index];
1181 } 1185 }
1182 1186
1183 - (void)reload { 1187 - (void)reload {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 1273
1270 LegacyTabHelper::RemoveFromWebState(webStateImpl_.get()); 1274 LegacyTabHelper::RemoveFromWebState(webStateImpl_.get());
1271 webStateImpl_.reset(); 1275 webStateImpl_.reset();
1272 } 1276 }
1273 1277
1274 - (void)dismissModals { 1278 - (void)dismissModals {
1275 [openInController_ disable]; 1279 [openInController_ disable];
1276 [self.webController dismissModals]; 1280 [self.webController dismissModals];
1277 } 1281 }
1278 1282
1279 - (web::NavigationItem*)currentNavigationItem {
1280 if (![self navigationManager])
1281 return nil;
1282 return [[self navigationManagerImpl]->GetSessionController() currentItem];
1283 }
1284
1285 - (void)setShouldObserveInfoBarManager:(BOOL)shouldObserveInfoBarManager { 1283 - (void)setShouldObserveInfoBarManager:(BOOL)shouldObserveInfoBarManager {
1286 tabInfoBarObserver_->SetShouldObserveInfoBarManager( 1284 tabInfoBarObserver_->SetShouldObserveInfoBarManager(
1287 shouldObserveInfoBarManager); 1285 shouldObserveInfoBarManager);
1288 } 1286 }
1289 1287
1290 - (void)setShouldObserveFaviconChanges:(BOOL)shouldObserveFaviconChanges { 1288 - (void)setShouldObserveFaviconChanges:(BOOL)shouldObserveFaviconChanges {
1291 if (shouldObserveFaviconChanges) { 1289 if (shouldObserveFaviconChanges) {
1292 favicon::FaviconDriver* faviconDriver = 1290 favicon::FaviconDriver* faviconDriver =
1293 favicon::WebFaviconDriver::FromWebState(self.webState); 1291 favicon::WebFaviconDriver::FromWebState(self.webState);
1294 // Some MockWebContents used in tests do not support the FaviconDriver. 1292 // Some MockWebContents used in tests do not support the FaviconDriver.
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
1738 DCHECK(self.webController.loadPhase == web::PAGE_LOADED); 1736 DCHECK(self.webController.loadPhase == web::PAGE_LOADED);
1739 1737
1740 // Cancel prerendering if response is "application/octet-stream". It can be a 1738 // Cancel prerendering if response is "application/octet-stream". It can be a
1741 // video file which should not be played from preload tab (crbug.com/436813). 1739 // video file which should not be played from preload tab (crbug.com/436813).
1742 if (isPrerenderTab_ && 1740 if (isPrerenderTab_ &&
1743 self.webState->GetContentsMimeType() == "application/octet-stream") { 1741 self.webState->GetContentsMimeType() == "application/octet-stream") {
1744 [delegate_ discardPrerender]; 1742 [delegate_ discardPrerender];
1745 } 1743 }
1746 1744
1747 bool wasPost = false; 1745 bool wasPost = false;
1748 if (self.currentNavigationItem) 1746 GURL lastCommittedURL;
1749 wasPost = self.currentNavigationItem->HasPostData(); 1747 web::NavigationItem* lastCommittedItem =
1750 GURL lastCommittedURL = self.webState->GetLastCommittedURL(); 1748 [self navigationManager]->GetLastCommittedItem();
1749 if (lastCommittedItem) {
1750 wasPost = lastCommittedItem->HasPostData();
1751 lastCommittedURL = lastCommittedItem->GetVirtualURL();
1752 }
1751 if (loadSuccess) 1753 if (loadSuccess)
1752 [autoReloadBridge_ loadFinishedForURL:lastCommittedURL wasPost:wasPost]; 1754 [autoReloadBridge_ loadFinishedForURL:lastCommittedURL wasPost:wasPost];
1753 else 1755 else
1754 [autoReloadBridge_ loadFailedForURL:lastCommittedURL wasPost:wasPost]; 1756 [autoReloadBridge_ loadFailedForURL:lastCommittedURL wasPost:wasPost];
1755 [webControllerSnapshotHelper_ setSnapshotCoalescingEnabled:YES]; 1757 [webControllerSnapshotHelper_ setSnapshotCoalescingEnabled:YES];
1756 if (!loadSuccess) { 1758 if (!loadSuccess) {
1757 [fullScreenController_ disableFullScreen]; 1759 [fullScreenController_ disableFullScreen];
1758 } 1760 }
1759 [self recordInterfaceOrientation]; 1761 [self recordInterfaceOrientation];
1760 navigation_metrics::OriginsSeenService* originsSeenService = 1762 navigation_metrics::OriginsSeenService* originsSeenService =
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
2225 2227
2226 - (TabModel*)parentTabModel { 2228 - (TabModel*)parentTabModel {
2227 return parentTabModel_; 2229 return parentTabModel_;
2228 } 2230 }
2229 2231
2230 - (FormInputAccessoryViewController*)inputAccessoryViewController { 2232 - (FormInputAccessoryViewController*)inputAccessoryViewController {
2231 return inputAccessoryViewController_.get(); 2233 return inputAccessoryViewController_.get();
2232 } 2234 }
2233 2235
2234 @end 2236 @end
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/tabs/tab_private.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698