Chromium Code Reviews| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 #include "ios/chrome/browser/sessions/ios_chrome_session_tab_helper.h" | 78 #include "ios/chrome/browser/sessions/ios_chrome_session_tab_helper.h" |
| 79 #include "ios/chrome/browser/signin/account_consistency_service_factory.h" | 79 #include "ios/chrome/browser/signin/account_consistency_service_factory.h" |
| 80 #include "ios/chrome/browser/signin/account_reconcilor_factory.h" | 80 #include "ios/chrome/browser/signin/account_reconcilor_factory.h" |
| 81 #include "ios/chrome/browser/signin/authentication_service.h" | 81 #include "ios/chrome/browser/signin/authentication_service.h" |
| 82 #include "ios/chrome/browser/signin/authentication_service_factory.h" | 82 #include "ios/chrome/browser/signin/authentication_service_factory.h" |
| 83 #include "ios/chrome/browser/signin/signin_capability.h" | 83 #include "ios/chrome/browser/signin/signin_capability.h" |
| 84 #import "ios/chrome/browser/snapshots/snapshot_manager.h" | 84 #import "ios/chrome/browser/snapshots/snapshot_manager.h" |
| 85 #import "ios/chrome/browser/snapshots/snapshot_overlay_provider.h" | 85 #import "ios/chrome/browser/snapshots/snapshot_overlay_provider.h" |
| 86 #import "ios/chrome/browser/snapshots/web_controller_snapshot_helper.h" | 86 #import "ios/chrome/browser/snapshots/web_controller_snapshot_helper.h" |
| 87 #include "ios/chrome/browser/ssl/ios_security_state_tab_helper.h" | 87 #include "ios/chrome/browser/ssl/ios_security_state_tab_helper.h" |
| 88 #import "ios/chrome/browser/storekit_launcher.h" | 88 #import "ios/chrome/browser/store_kit/store_kit_tab_helper.h" |
| 89 #include "ios/chrome/browser/sync/ios_chrome_synced_tab_delegate.h" | 89 #include "ios/chrome/browser/sync/ios_chrome_synced_tab_delegate.h" |
| 90 #import "ios/chrome/browser/tabs/legacy_tab_helper.h" | 90 #import "ios/chrome/browser/tabs/legacy_tab_helper.h" |
| 91 #import "ios/chrome/browser/tabs/tab_delegate.h" | 91 #import "ios/chrome/browser/tabs/tab_delegate.h" |
| 92 #import "ios/chrome/browser/tabs/tab_dialog_delegate.h" | 92 #import "ios/chrome/browser/tabs/tab_dialog_delegate.h" |
| 93 #import "ios/chrome/browser/tabs/tab_headers_delegate.h" | 93 #import "ios/chrome/browser/tabs/tab_headers_delegate.h" |
| 94 #import "ios/chrome/browser/tabs/tab_model.h" | 94 #import "ios/chrome/browser/tabs/tab_model.h" |
| 95 #import "ios/chrome/browser/tabs/tab_private.h" | 95 #import "ios/chrome/browser/tabs/tab_private.h" |
| 96 #import "ios/chrome/browser/tabs/tab_snapshotting_delegate.h" | 96 #import "ios/chrome/browser/tabs/tab_snapshotting_delegate.h" |
| 97 #include "ios/chrome/browser/translate/chrome_ios_translate_client.h" | 97 #include "ios/chrome/browser/translate/chrome_ios_translate_client.h" |
| 98 #import "ios/chrome/browser/u2f/u2f_controller.h" | 98 #import "ios/chrome/browser/u2f/u2f_controller.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 } // namespace | 215 } // namespace |
| 216 | 216 |
| 217 @interface Tab ()<CRWWebStateObserver, | 217 @interface Tab ()<CRWWebStateObserver, |
| 218 FindInPageControllerDelegate, | 218 FindInPageControllerDelegate, |
| 219 ReaderModeControllerDelegate> { | 219 ReaderModeControllerDelegate> { |
| 220 TabModel* parentTabModel_; // weak | 220 TabModel* parentTabModel_; // weak |
| 221 ios::ChromeBrowserState* browserState_; // weak | 221 ios::ChromeBrowserState* browserState_; // weak |
| 222 | 222 |
| 223 base::scoped_nsobject<OpenInController> openInController_; | 223 base::scoped_nsobject<OpenInController> openInController_; |
| 224 base::WeakNSProtocol<id<PassKitDialogProvider>> passKitDialogProvider_; | 224 base::WeakNSProtocol<id<PassKitDialogProvider>> passKitDialogProvider_; |
| 225 // TODO(crbug.com/546213): Move this out of Tab, probably to native app | |
| 226 // launcher since that's the only thing that uses it. | |
| 227 base::WeakNSProtocol<id<StoreKitLauncher>> storeKitLauncher_; | |
| 228 | 225 |
| 229 // Whether or not this tab is currently being displayed. | 226 // Whether or not this tab is currently being displayed. |
| 230 BOOL visible_; | 227 BOOL visible_; |
| 231 | 228 |
| 232 // Holds entries that need to be added to the history DB. Prerender tabs do | 229 // Holds entries that need to be added to the history DB. Prerender tabs do |
| 233 // not write navigation data to the history DB. Instead, they cache history | 230 // not write navigation data to the history DB. Instead, they cache history |
| 234 // data in this vector and add it to the DB when the prerender status is | 231 // data in this vector and add it to the DB when the prerender status is |
| 235 // removed (when the Tab is swapped in as a real Tab). | 232 // removed (when the Tab is swapped in as a real Tab). |
| 236 std::vector<history::HistoryAddPageArgs> addPageVector_; | 233 std::vector<history::HistoryAddPageArgs> addPageVector_; |
| 237 | 234 |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 564 IOSChromeSessionTabHelper::CreateForWebState(self.webState); | 561 IOSChromeSessionTabHelper::CreateForWebState(self.webState); |
| 565 | 562 |
| 566 NetworkActivityIndicatorTabHelper::CreateForWebState(self.webState, | 563 NetworkActivityIndicatorTabHelper::CreateForWebState(self.webState, |
| 567 self.tabId); | 564 self.tabId); |
| 568 IOSChromeSyncedTabDelegate::CreateForWebState(self.webState); | 565 IOSChromeSyncedTabDelegate::CreateForWebState(self.webState); |
| 569 InfoBarManagerImpl::CreateForWebState(self.webState); | 566 InfoBarManagerImpl::CreateForWebState(self.webState); |
| 570 IOSSecurityStateTabHelper::CreateForWebState(self.webState); | 567 IOSSecurityStateTabHelper::CreateForWebState(self.webState); |
| 571 RepostFormTabHelper::CreateForWebState(self.webState); | 568 RepostFormTabHelper::CreateForWebState(self.webState); |
| 572 BlockedPopupTabHelper::CreateForWebState(self.webState); | 569 BlockedPopupTabHelper::CreateForWebState(self.webState); |
| 573 FindTabHelper::CreateForWebState(self.webState, self); | 570 FindTabHelper::CreateForWebState(self.webState, self); |
| 571 StoreKitTabHelper::CreateForWebState(self.webState); | |
| 574 | 572 |
| 575 if (reading_list::switches::IsReadingListEnabled()) { | 573 if (reading_list::switches::IsReadingListEnabled()) { |
| 576 ReadingListModel* model = | 574 ReadingListModel* model = |
| 577 ReadingListModelFactory::GetForBrowserState(browserState_); | 575 ReadingListModelFactory::GetForBrowserState(browserState_); |
| 578 ReadingListWebStateObserver::FromWebState(self.webState, model); | 576 ReadingListWebStateObserver::FromWebState(self.webState, model); |
| 579 } | 577 } |
| 580 | 578 |
| 581 tabInfoBarObserver_.reset(new TabInfoBarObserver(self)); | 579 tabInfoBarObserver_.reset(new TabInfoBarObserver(self)); |
| 582 tabInfoBarObserver_->SetShouldObserveInfoBarManager(true); | 580 tabInfoBarObserver_->SetShouldObserveInfoBarManager(true); |
| 583 | 581 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 878 } | 876 } |
| 879 | 877 |
| 880 - (web::NavigationManager*)navigationManager { | 878 - (web::NavigationManager*)navigationManager { |
| 881 return webStateImpl_ ? webStateImpl_->GetNavigationManager() : nullptr; | 879 return webStateImpl_ ? webStateImpl_->GetNavigationManager() : nullptr; |
| 882 } | 880 } |
| 883 | 881 |
| 884 - (web::NavigationManagerImpl*)navigationManagerImpl { | 882 - (web::NavigationManagerImpl*)navigationManagerImpl { |
| 885 return webStateImpl_ ? &(webStateImpl_->GetNavigationManagerImpl()) : nullptr; | 883 return webStateImpl_ ? &(webStateImpl_->GetNavigationManagerImpl()) : nullptr; |
| 886 } | 884 } |
| 887 | 885 |
| 888 - (id<StoreKitLauncher>)storeKitLauncher { | 886 - (id<StoreKitLauncher>)storeKitLauncher { |
|
rohitrao (ping after 24h)
2017/03/07 13:38:07
I'd like to get these methods out of Tab as well,
pkl (ping after 24h if needed)
2017/03/07 21:24:46
Yes, good point. Done.
| |
| 889 return storeKitLauncher_.get(); | 887 StoreKitTabHelper* tabHelper = StoreKitTabHelper::FromWebState(self.webState); |
| 888 return tabHelper ? tabHelper->GetLauncher() : nil; | |
|
rohitrao (ping after 24h)
2017/03/07 13:38:07
We call CreateFromWebState() in Tab's init, so the
sdefresne
2017/03/07 17:11:16
We can create Tab without TabHelper (see -initWith
pkl (ping after 24h if needed)
2017/03/07 21:24:46
Removing this...the case is moot.
pkl (ping after 24h if needed)
2017/03/07 21:24:46
Removing this...the case is moot.
| |
| 890 } | 889 } |
| 891 | 890 |
| 892 - (void)setStoreKitLauncher:(id<StoreKitLauncher>)storeKitLauncher { | 891 - (void)setStoreKitLauncher:(id<StoreKitLauncher>)storeKitLauncher { |
| 893 storeKitLauncher_.reset(storeKitLauncher); | 892 StoreKitTabHelper* tabHelper = StoreKitTabHelper::FromWebState(self.webState); |
| 893 if (tabHelper) | |
| 894 tabHelper->SetLauncher(storeKitLauncher); | |
| 894 } | 895 } |
| 895 | 896 |
| 896 // Swap out the existing session history with a new list of navigations. Forces | 897 // Swap out the existing session history with a new list of navigations. Forces |
| 897 // the tab to reload to update the UI accordingly. This is ok because none of | 898 // the tab to reload to update the UI accordingly. This is ok because none of |
| 898 // the session history is stored in the tab; it's always fetched through the | 899 // the session history is stored in the tab; it's always fetched through the |
| 899 // navigation manager. | 900 // navigation manager. |
| 900 - (void)replaceHistoryWithNavigations: | 901 - (void)replaceHistoryWithNavigations: |
| 901 (const std::vector<sessions::SerializedNavigationEntry>&)navigations | 902 (const std::vector<sessions::SerializedNavigationEntry>&)navigations |
| 902 currentIndex:(NSInteger)currentIndex { | 903 currentIndex:(NSInteger)currentIndex { |
| 903 std::vector<std::unique_ptr<web::NavigationItem>> items = | 904 std::vector<std::unique_ptr<web::NavigationItem>> items = |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1205 } | 1206 } |
| 1206 | 1207 |
| 1207 // This can't be done in dealloc in case someone holds an extra strong | 1208 // This can't be done in dealloc in case someone holds an extra strong |
| 1208 // reference to the Tab, which would cause the close sequence to fire at a | 1209 // reference to the Tab, which would cause the close sequence to fire at a |
| 1209 // random time. | 1210 // random time. |
| 1210 - (void)close { | 1211 - (void)close { |
| 1211 self.fullScreenControllerDelegate = nil; | 1212 self.fullScreenControllerDelegate = nil; |
| 1212 self.overscrollActionsControllerDelegate = nil; | 1213 self.overscrollActionsControllerDelegate = nil; |
| 1213 self.passKitDialogProvider = nil; | 1214 self.passKitDialogProvider = nil; |
| 1214 self.snapshotOverlayProvider = nil; | 1215 self.snapshotOverlayProvider = nil; |
| 1215 self.storeKitLauncher = nil; | |
|
rohitrao (ping after 24h)
2017/03/07 13:38:07
Should we call SetLauncher(nil) here?
pkl (ping after 24h if needed)
2017/03/07 21:24:46
Already removed.
| |
| 1216 | 1216 |
| 1217 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 1217 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 1218 | 1218 |
| 1219 [passwordController_ detach]; | 1219 [passwordController_ detach]; |
| 1220 passwordController_.reset(); | 1220 passwordController_.reset(); |
| 1221 tabInfoBarObserver_.reset(); | 1221 tabInfoBarObserver_.reset(); |
| 1222 | 1222 |
| 1223 faviconDriverObserverBridge_.reset(); | 1223 faviconDriverObserverBridge_.reset(); |
| 1224 [openInController_ detachFromWebController]; | 1224 [openInController_ detachFromWebController]; |
| 1225 openInController_.reset(); | 1225 openInController_.reset(); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1444 - (void)closeThisTab { | 1444 - (void)closeThisTab { |
| 1445 if (!parentTabModel_) | 1445 if (!parentTabModel_) |
| 1446 return; | 1446 return; |
| 1447 | 1447 |
| 1448 NSUInteger index = [parentTabModel_ indexOfTab:self]; | 1448 NSUInteger index = [parentTabModel_ indexOfTab:self]; |
| 1449 if (index != NSNotFound) | 1449 if (index != NSNotFound) |
| 1450 [parentTabModel_ closeTabAtIndex:index]; | 1450 [parentTabModel_ closeTabAtIndex:index]; |
| 1451 } | 1451 } |
| 1452 | 1452 |
| 1453 - (id<CRWNativeContent>)controllerForUnhandledContentAtURL:(const GURL&)url { | 1453 - (id<CRWNativeContent>)controllerForUnhandledContentAtURL:(const GURL&)url { |
| 1454 StoreKitTabHelper* helper = StoreKitTabHelper::FromWebState(self.webState); | |
| 1455 if (!helper) | |
| 1456 return nil; | |
| 1457 id<StoreKitLauncher> storeKitLauncher = helper->GetLauncher(); | |
| 1458 if (!storeKitLauncher) | |
| 1459 return nil; | |
| 1454 DownloadManagerController* downloadController = | 1460 DownloadManagerController* downloadController = |
| 1455 [[[DownloadManagerController alloc] | 1461 [[[DownloadManagerController alloc] |
| 1456 initWithURL:url | 1462 initWithURL:url |
| 1457 requestContextGetter:browserState_->GetRequestContext() | 1463 requestContextGetter:browserState_->GetRequestContext() |
| 1458 storeKitLauncher:self.storeKitLauncher] autorelease]; | 1464 storeKitLauncher:storeKitLauncher] autorelease]; |
| 1459 [downloadController start]; | 1465 [downloadController start]; |
| 1460 return downloadController; | 1466 return downloadController; |
| 1461 } | 1467 } |
| 1462 | 1468 |
| 1463 - (void)handleExportableFile:(net::HttpResponseHeaders*)headers { | 1469 - (void)handleExportableFile:(net::HttpResponseHeaders*)headers { |
| 1464 // Only "application/pdf" is supported for now. | 1470 // Only "application/pdf" is supported for now. |
| 1465 if (self.webState->GetContentsMimeType() != "application/pdf") | 1471 if (self.webState->GetContentsMimeType() != "application/pdf") |
| 1466 return; | 1472 return; |
| 1467 | 1473 |
| 1468 [[NSNotificationCenter defaultCenter] | 1474 [[NSNotificationCenter defaultCenter] |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1549 // if the page does a late redirect itself or if the user tapped on a link and | 1555 // if the page does a late redirect itself or if the user tapped on a link and |
| 1550 // triggered reader mode before the page load is detected by webState. | 1556 // triggered reader mode before the page load is detected by webState. |
| 1551 if (url == self.url) | 1557 if (url == self.url) |
| 1552 [self.webController loadHTMLForCurrentURL:html]; | 1558 [self.webController loadHTMLForCurrentURL:html]; |
| 1553 | 1559 |
| 1554 [self.readerModeController exitReaderMode]; | 1560 [self.readerModeController exitReaderMode]; |
| 1555 } | 1561 } |
| 1556 | 1562 |
| 1557 #pragma mark - | 1563 #pragma mark - |
| 1558 | 1564 |
| 1559 - (void)openAppStore:(NSString*)appId { | 1565 - (void)openAppStore:(NSString*)appId { |
|
rohitrao (ping after 24h)
2017/03/07 13:38:08
This is another method that should eventually be r
pkl (ping after 24h if needed)
2017/03/07 21:24:46
Yes, removed.
| |
| 1560 [storeKitLauncher_ openAppStore:appId]; | 1566 StoreKitTabHelper* tabHelper = StoreKitTabHelper::FromWebState(self.webState); |
| 1567 if (tabHelper) | |
| 1568 tabHelper->OpenAppStore(appId); | |
| 1561 } | 1569 } |
| 1562 | 1570 |
| 1563 - (BOOL)usesDesktopUserAgent { | 1571 - (BOOL)usesDesktopUserAgent { |
| 1564 if (!self.navigationManager) | 1572 if (!self.navigationManager) |
| 1565 return NO; | 1573 return NO; |
| 1566 | 1574 |
| 1567 web::NavigationItem* visibleItem = self.navigationManager->GetVisibleItem(); | 1575 web::NavigationItem* visibleItem = self.navigationManager->GetVisibleItem(); |
| 1568 return visibleItem && | 1576 return visibleItem && |
| 1569 visibleItem->GetUserAgentType() == web::UserAgentType::DESKTOP; | 1577 visibleItem->GetUserAgentType() == web::UserAgentType::DESKTOP; |
| 1570 } | 1578 } |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2188 } | 2196 } |
| 2189 | 2197 |
| 2190 - (NativeAppNavigationController*)nativeAppNavigationController { | 2198 - (NativeAppNavigationController*)nativeAppNavigationController { |
| 2191 return nativeAppNavigationController_; | 2199 return nativeAppNavigationController_; |
| 2192 } | 2200 } |
| 2193 | 2201 |
| 2194 - (void)initNativeAppNavigationController { | 2202 - (void)initNativeAppNavigationController { |
| 2195 if (browserState_->IsOffTheRecord()) | 2203 if (browserState_->IsOffTheRecord()) |
| 2196 return; | 2204 return; |
| 2197 DCHECK(!nativeAppNavigationController_); | 2205 DCHECK(!nativeAppNavigationController_); |
| 2198 nativeAppNavigationController_.reset([[NativeAppNavigationController alloc] | 2206 nativeAppNavigationController_.reset( |
| 2199 initWithWebState:self.webState | 2207 [[NativeAppNavigationController alloc] initWithWebState:self.webState]); |
| 2200 requestContextGetter:browserState_->GetRequestContext() | |
| 2201 tab:self]); | |
| 2202 DCHECK(nativeAppNavigationController_); | 2208 DCHECK(nativeAppNavigationController_); |
| 2203 } | 2209 } |
| 2204 | 2210 |
| 2205 - (id<PassKitDialogProvider>)passKitDialogProvider { | 2211 - (id<PassKitDialogProvider>)passKitDialogProvider { |
| 2206 return passKitDialogProvider_.get(); | 2212 return passKitDialogProvider_.get(); |
| 2207 } | 2213 } |
| 2208 | 2214 |
| 2209 - (void)setPassKitDialogProvider:(id<PassKitDialogProvider>)provider { | 2215 - (void)setPassKitDialogProvider:(id<PassKitDialogProvider>)provider { |
| 2210 passKitDialogProvider_.reset(provider); | 2216 passKitDialogProvider_.reset(provider); |
| 2211 } | 2217 } |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 2236 | 2242 |
| 2237 - (TabModel*)parentTabModel { | 2243 - (TabModel*)parentTabModel { |
| 2238 return parentTabModel_; | 2244 return parentTabModel_; |
| 2239 } | 2245 } |
| 2240 | 2246 |
| 2241 - (FormInputAccessoryViewController*)inputAccessoryViewController { | 2247 - (FormInputAccessoryViewController*)inputAccessoryViewController { |
| 2242 return inputAccessoryViewController_.get(); | 2248 return inputAccessoryViewController_.get(); |
| 2243 } | 2249 } |
| 2244 | 2250 |
| 2245 @end | 2251 @end |
| OLD | NEW |