| 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 IOSChromeSessionTabHelper::CreateForWebState(self.webState); | 555 IOSChromeSessionTabHelper::CreateForWebState(self.webState); |
| 559 | 556 |
| 560 NetworkActivityIndicatorTabHelper::CreateForWebState(self.webState, | 557 NetworkActivityIndicatorTabHelper::CreateForWebState(self.webState, |
| 561 self.tabId); | 558 self.tabId); |
| 562 IOSChromeSyncedTabDelegate::CreateForWebState(self.webState); | 559 IOSChromeSyncedTabDelegate::CreateForWebState(self.webState); |
| 563 InfoBarManagerImpl::CreateForWebState(self.webState); | 560 InfoBarManagerImpl::CreateForWebState(self.webState); |
| 564 IOSSecurityStateTabHelper::CreateForWebState(self.webState); | 561 IOSSecurityStateTabHelper::CreateForWebState(self.webState); |
| 565 RepostFormTabHelper::CreateForWebState(self.webState); | 562 RepostFormTabHelper::CreateForWebState(self.webState); |
| 566 BlockedPopupTabHelper::CreateForWebState(self.webState); | 563 BlockedPopupTabHelper::CreateForWebState(self.webState); |
| 567 FindTabHelper::CreateForWebState(self.webState, self); | 564 FindTabHelper::CreateForWebState(self.webState, self); |
| 565 StoreKitTabHelper::CreateForWebState(self.webState); |
| 568 | 566 |
| 569 if (reading_list::switches::IsReadingListEnabled()) { | 567 if (reading_list::switches::IsReadingListEnabled()) { |
| 570 ReadingListModel* model = | 568 ReadingListModel* model = |
| 571 ReadingListModelFactory::GetForBrowserState(browserState_); | 569 ReadingListModelFactory::GetForBrowserState(browserState_); |
| 572 ReadingListWebStateObserver::FromWebState(self.webState, model); | 570 ReadingListWebStateObserver::FromWebState(self.webState, model); |
| 573 } | 571 } |
| 574 | 572 |
| 575 tabInfoBarObserver_.reset(new TabInfoBarObserver(self)); | 573 tabInfoBarObserver_.reset(new TabInfoBarObserver(self)); |
| 576 tabInfoBarObserver_->SetShouldObserveInfoBarManager(true); | 574 tabInfoBarObserver_->SetShouldObserveInfoBarManager(true); |
| 577 | 575 |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 } | 871 } |
| 874 | 872 |
| 875 - (web::NavigationManager*)navigationManager { | 873 - (web::NavigationManager*)navigationManager { |
| 876 return webStateImpl_ ? webStateImpl_->GetNavigationManager() : nullptr; | 874 return webStateImpl_ ? webStateImpl_->GetNavigationManager() : nullptr; |
| 877 } | 875 } |
| 878 | 876 |
| 879 - (web::NavigationManagerImpl*)navigationManagerImpl { | 877 - (web::NavigationManagerImpl*)navigationManagerImpl { |
| 880 return webStateImpl_ ? &(webStateImpl_->GetNavigationManagerImpl()) : nullptr; | 878 return webStateImpl_ ? &(webStateImpl_->GetNavigationManagerImpl()) : nullptr; |
| 881 } | 879 } |
| 882 | 880 |
| 883 - (id<StoreKitLauncher>)storeKitLauncher { | |
| 884 return storeKitLauncher_.get(); | |
| 885 } | |
| 886 | |
| 887 - (void)setStoreKitLauncher:(id<StoreKitLauncher>)storeKitLauncher { | |
| 888 storeKitLauncher_.reset(storeKitLauncher); | |
| 889 } | |
| 890 | |
| 891 // Swap out the existing session history with a new list of navigations. Forces | 881 // Swap out the existing session history with a new list of navigations. Forces |
| 892 // the tab to reload to update the UI accordingly. This is ok because none of | 882 // the tab to reload to update the UI accordingly. This is ok because none of |
| 893 // the session history is stored in the tab; it's always fetched through the | 883 // the session history is stored in the tab; it's always fetched through the |
| 894 // navigation manager. | 884 // navigation manager. |
| 895 - (void)replaceHistoryWithNavigations: | 885 - (void)replaceHistoryWithNavigations: |
| 896 (const std::vector<sessions::SerializedNavigationEntry>&)navigations | 886 (const std::vector<sessions::SerializedNavigationEntry>&)navigations |
| 897 currentIndex:(NSInteger)currentIndex { | 887 currentIndex:(NSInteger)currentIndex { |
| 898 std::vector<std::unique_ptr<web::NavigationItem>> items = | 888 std::vector<std::unique_ptr<web::NavigationItem>> items = |
| 899 sessions::IOSSerializedNavigationBuilder::ToNavigationItems(navigations); | 889 sessions::IOSSerializedNavigationBuilder::ToNavigationItems(navigations); |
| 900 [self navigationManagerImpl]->ReplaceSessionHistory(std::move(items), | 890 [self navigationManagerImpl]->ReplaceSessionHistory(std::move(items), |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 } | 1199 } |
| 1210 | 1200 |
| 1211 // This can't be done in dealloc in case someone holds an extra strong | 1201 // This can't be done in dealloc in case someone holds an extra strong |
| 1212 // reference to the Tab, which would cause the close sequence to fire at a | 1202 // reference to the Tab, which would cause the close sequence to fire at a |
| 1213 // random time. | 1203 // random time. |
| 1214 - (void)close { | 1204 - (void)close { |
| 1215 self.fullScreenControllerDelegate = nil; | 1205 self.fullScreenControllerDelegate = nil; |
| 1216 self.overscrollActionsControllerDelegate = nil; | 1206 self.overscrollActionsControllerDelegate = nil; |
| 1217 self.passKitDialogProvider = nil; | 1207 self.passKitDialogProvider = nil; |
| 1218 self.snapshotOverlayProvider = nil; | 1208 self.snapshotOverlayProvider = nil; |
| 1219 self.storeKitLauncher = nil; | |
| 1220 | 1209 |
| 1221 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 1210 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 1222 | 1211 |
| 1223 [passwordController_ detach]; | 1212 [passwordController_ detach]; |
| 1224 passwordController_.reset(); | 1213 passwordController_.reset(); |
| 1225 tabInfoBarObserver_.reset(); | 1214 tabInfoBarObserver_.reset(); |
| 1226 | 1215 |
| 1227 faviconDriverObserverBridge_.reset(); | 1216 faviconDriverObserverBridge_.reset(); |
| 1228 [openInController_ detachFromWebController]; | 1217 [openInController_ detachFromWebController]; |
| 1229 openInController_.reset(); | 1218 openInController_.reset(); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1448 - (void)closeThisTab { | 1437 - (void)closeThisTab { |
| 1449 if (!parentTabModel_) | 1438 if (!parentTabModel_) |
| 1450 return; | 1439 return; |
| 1451 | 1440 |
| 1452 NSUInteger index = [parentTabModel_ indexOfTab:self]; | 1441 NSUInteger index = [parentTabModel_ indexOfTab:self]; |
| 1453 if (index != NSNotFound) | 1442 if (index != NSNotFound) |
| 1454 [parentTabModel_ closeTabAtIndex:index]; | 1443 [parentTabModel_ closeTabAtIndex:index]; |
| 1455 } | 1444 } |
| 1456 | 1445 |
| 1457 - (id<CRWNativeContent>)controllerForUnhandledContentAtURL:(const GURL&)url { | 1446 - (id<CRWNativeContent>)controllerForUnhandledContentAtURL:(const GURL&)url { |
| 1447 StoreKitTabHelper* helper = StoreKitTabHelper::FromWebState(self.webState); |
| 1448 if (!helper) |
| 1449 return nil; |
| 1450 id<StoreKitLauncher> storeKitLauncher = helper->GetLauncher(); |
| 1451 if (!storeKitLauncher) |
| 1452 return nil; |
| 1458 DownloadManagerController* downloadController = | 1453 DownloadManagerController* downloadController = |
| 1459 [[[DownloadManagerController alloc] | 1454 [[[DownloadManagerController alloc] |
| 1460 initWithURL:url | 1455 initWithURL:url |
| 1461 requestContextGetter:browserState_->GetRequestContext() | 1456 requestContextGetter:browserState_->GetRequestContext() |
| 1462 storeKitLauncher:self.storeKitLauncher] autorelease]; | 1457 storeKitLauncher:storeKitLauncher] autorelease]; |
| 1463 [downloadController start]; | 1458 [downloadController start]; |
| 1464 return downloadController; | 1459 return downloadController; |
| 1465 } | 1460 } |
| 1466 | 1461 |
| 1467 - (void)handleExportableFile:(net::HttpResponseHeaders*)headers { | 1462 - (void)handleExportableFile:(net::HttpResponseHeaders*)headers { |
| 1468 // Only "application/pdf" is supported for now. | 1463 // Only "application/pdf" is supported for now. |
| 1469 if (self.webState->GetContentsMimeType() != "application/pdf") | 1464 if (self.webState->GetContentsMimeType() != "application/pdf") |
| 1470 return; | 1465 return; |
| 1471 | 1466 |
| 1472 [[NSNotificationCenter defaultCenter] | 1467 [[NSNotificationCenter defaultCenter] |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1553 // if the page does a late redirect itself or if the user tapped on a link and | 1548 // if the page does a late redirect itself or if the user tapped on a link and |
| 1554 // triggered reader mode before the page load is detected by webState. | 1549 // triggered reader mode before the page load is detected by webState. |
| 1555 if (url == self.url) | 1550 if (url == self.url) |
| 1556 [self.webController loadHTMLForCurrentURL:html]; | 1551 [self.webController loadHTMLForCurrentURL:html]; |
| 1557 | 1552 |
| 1558 [self.readerModeController exitReaderMode]; | 1553 [self.readerModeController exitReaderMode]; |
| 1559 } | 1554 } |
| 1560 | 1555 |
| 1561 #pragma mark - | 1556 #pragma mark - |
| 1562 | 1557 |
| 1563 - (void)openAppStore:(NSString*)appId { | |
| 1564 [storeKitLauncher_ openAppStore:appId]; | |
| 1565 } | |
| 1566 | |
| 1567 - (BOOL)usesDesktopUserAgent { | 1558 - (BOOL)usesDesktopUserAgent { |
| 1568 if (!self.navigationManager) | 1559 if (!self.navigationManager) |
| 1569 return NO; | 1560 return NO; |
| 1570 | 1561 |
| 1571 web::NavigationItem* visibleItem = self.navigationManager->GetVisibleItem(); | 1562 web::NavigationItem* visibleItem = self.navigationManager->GetVisibleItem(); |
| 1572 return visibleItem && | 1563 return visibleItem && |
| 1573 visibleItem->GetUserAgentType() == web::UserAgentType::DESKTOP; | 1564 visibleItem->GetUserAgentType() == web::UserAgentType::DESKTOP; |
| 1574 } | 1565 } |
| 1575 | 1566 |
| 1576 - (void)enableDesktopUserAgent { | 1567 - (void)enableDesktopUserAgent { |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2187 } | 2178 } |
| 2188 | 2179 |
| 2189 - (NativeAppNavigationController*)nativeAppNavigationController { | 2180 - (NativeAppNavigationController*)nativeAppNavigationController { |
| 2190 return nativeAppNavigationController_; | 2181 return nativeAppNavigationController_; |
| 2191 } | 2182 } |
| 2192 | 2183 |
| 2193 - (void)initNativeAppNavigationController { | 2184 - (void)initNativeAppNavigationController { |
| 2194 if (browserState_->IsOffTheRecord()) | 2185 if (browserState_->IsOffTheRecord()) |
| 2195 return; | 2186 return; |
| 2196 DCHECK(!nativeAppNavigationController_); | 2187 DCHECK(!nativeAppNavigationController_); |
| 2197 nativeAppNavigationController_.reset([[NativeAppNavigationController alloc] | 2188 nativeAppNavigationController_.reset( |
| 2198 initWithWebState:self.webState | 2189 [[NativeAppNavigationController alloc] initWithWebState:self.webState]); |
| 2199 requestContextGetter:browserState_->GetRequestContext() | |
| 2200 tab:self]); | |
| 2201 DCHECK(nativeAppNavigationController_); | 2190 DCHECK(nativeAppNavigationController_); |
| 2202 } | 2191 } |
| 2203 | 2192 |
| 2204 - (id<PassKitDialogProvider>)passKitDialogProvider { | 2193 - (id<PassKitDialogProvider>)passKitDialogProvider { |
| 2205 return passKitDialogProvider_.get(); | 2194 return passKitDialogProvider_.get(); |
| 2206 } | 2195 } |
| 2207 | 2196 |
| 2208 - (void)setPassKitDialogProvider:(id<PassKitDialogProvider>)provider { | 2197 - (void)setPassKitDialogProvider:(id<PassKitDialogProvider>)provider { |
| 2209 passKitDialogProvider_.reset(provider); | 2198 passKitDialogProvider_.reset(provider); |
| 2210 } | 2199 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2235 | 2224 |
| 2236 - (TabModel*)parentTabModel { | 2225 - (TabModel*)parentTabModel { |
| 2237 return parentTabModel_; | 2226 return parentTabModel_; |
| 2238 } | 2227 } |
| 2239 | 2228 |
| 2240 - (FormInputAccessoryViewController*)inputAccessoryViewController { | 2229 - (FormInputAccessoryViewController*)inputAccessoryViewController { |
| 2241 return inputAccessoryViewController_.get(); | 2230 return inputAccessoryViewController_.get(); |
| 2242 } | 2231 } |
| 2243 | 2232 |
| 2244 @end | 2233 @end |
| OLD | NEW |