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

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

Issue 2731553005: Introduced StoreKitTabHelper class (Closed)
Patch Set: line break for 80 columns 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
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 {
889 return storeKitLauncher_.get(); 887 StoreKitTabHelper* tab_helper =
888 StoreKitTabHelper::FromWebState(self.webState);
889 return tab_helper ? tab_helper->GetLauncher() : nil;
890 } 890 }
891 891
892 - (void)setStoreKitLauncher:(id<StoreKitLauncher>)storeKitLauncher { 892 - (void)setStoreKitLauncher:(id<StoreKitLauncher>)storeKitLauncher {
893 storeKitLauncher_.reset(storeKitLauncher); 893 StoreKitTabHelper* tab_helper =
894 StoreKitTabHelper::FromWebState(self.webState);
895 if (tab_helper)
896 tab_helper->SetLauncher(storeKitLauncher);
894 } 897 }
895 898
896 // Swap out the existing session history with a new list of navigations. Forces 899 // 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 900 // 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 901 // the session history is stored in the tab; it's always fetched through the
899 // navigation manager. 902 // navigation manager.
900 - (void)replaceHistoryWithNavigations: 903 - (void)replaceHistoryWithNavigations:
901 (const std::vector<sessions::SerializedNavigationEntry>&)navigations 904 (const std::vector<sessions::SerializedNavigationEntry>&)navigations
902 currentIndex:(NSInteger)currentIndex { 905 currentIndex:(NSInteger)currentIndex {
903 std::vector<std::unique_ptr<web::NavigationItem>> items = 906 std::vector<std::unique_ptr<web::NavigationItem>> items =
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 } 1208 }
1206 1209
1207 // This can't be done in dealloc in case someone holds an extra strong 1210 // 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 1211 // reference to the Tab, which would cause the close sequence to fire at a
1209 // random time. 1212 // random time.
1210 - (void)close { 1213 - (void)close {
1211 self.fullScreenControllerDelegate = nil; 1214 self.fullScreenControllerDelegate = nil;
1212 self.overscrollActionsControllerDelegate = nil; 1215 self.overscrollActionsControllerDelegate = nil;
1213 self.passKitDialogProvider = nil; 1216 self.passKitDialogProvider = nil;
1214 self.snapshotOverlayProvider = nil; 1217 self.snapshotOverlayProvider = nil;
1215 self.storeKitLauncher = nil;
1216 1218
1217 [[NSNotificationCenter defaultCenter] removeObserver:self]; 1219 [[NSNotificationCenter defaultCenter] removeObserver:self];
1218 1220
1219 [passwordController_ detach]; 1221 [passwordController_ detach];
1220 passwordController_.reset(); 1222 passwordController_.reset();
1221 tabInfoBarObserver_.reset(); 1223 tabInfoBarObserver_.reset();
1222 1224
1223 faviconDriverObserverBridge_.reset(); 1225 faviconDriverObserverBridge_.reset();
1224 [openInController_ detachFromWebController]; 1226 [openInController_ detachFromWebController];
1225 openInController_.reset(); 1227 openInController_.reset();
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 - (void)closeThisTab { 1446 - (void)closeThisTab {
1445 if (!parentTabModel_) 1447 if (!parentTabModel_)
1446 return; 1448 return;
1447 1449
1448 NSUInteger index = [parentTabModel_ indexOfTab:self]; 1450 NSUInteger index = [parentTabModel_ indexOfTab:self];
1449 if (index != NSNotFound) 1451 if (index != NSNotFound)
1450 [parentTabModel_ closeTabAtIndex:index]; 1452 [parentTabModel_ closeTabAtIndex:index];
1451 } 1453 }
1452 1454
1453 - (id<CRWNativeContent>)controllerForUnhandledContentAtURL:(const GURL&)url { 1455 - (id<CRWNativeContent>)controllerForUnhandledContentAtURL:(const GURL&)url {
1456 id<StoreKitLauncher> storeKitLauncher =
sdefresne 2017/03/06 19:44:03 The tab helper may be null during tests, can you c
pkl (ping after 24h if needed) 2017/03/07 01:17:54 Done.
1457 StoreKitTabHelper::FromWebState(self.webState)->GetLauncher();
1454 DownloadManagerController* downloadController = 1458 DownloadManagerController* downloadController =
1455 [[[DownloadManagerController alloc] 1459 [[[DownloadManagerController alloc]
1456 initWithURL:url 1460 initWithURL:url
1457 requestContextGetter:browserState_->GetRequestContext() 1461 requestContextGetter:browserState_->GetRequestContext()
1458 storeKitLauncher:self.storeKitLauncher] autorelease]; 1462 storeKitLauncher:storeKitLauncher] autorelease];
1459 [downloadController start]; 1463 [downloadController start];
1460 return downloadController; 1464 return downloadController;
1461 } 1465 }
1462 1466
1463 - (void)handleExportableFile:(net::HttpResponseHeaders*)headers { 1467 - (void)handleExportableFile:(net::HttpResponseHeaders*)headers {
1464 // Only "application/pdf" is supported for now. 1468 // Only "application/pdf" is supported for now.
1465 if (self.webState->GetContentsMimeType() != "application/pdf") 1469 if (self.webState->GetContentsMimeType() != "application/pdf")
1466 return; 1470 return;
1467 1471
1468 [[NSNotificationCenter defaultCenter] 1472 [[NSNotificationCenter defaultCenter]
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1550 // triggered reader mode before the page load is detected by webState. 1554 // triggered reader mode before the page load is detected by webState.
1551 if (url == self.url) 1555 if (url == self.url)
1552 [self.webController loadHTMLForCurrentURL:html]; 1556 [self.webController loadHTMLForCurrentURL:html];
1553 1557
1554 [self.readerModeController exitReaderMode]; 1558 [self.readerModeController exitReaderMode];
1555 } 1559 }
1556 1560
1557 #pragma mark - 1561 #pragma mark -
1558 1562
1559 - (void)openAppStore:(NSString*)appId { 1563 - (void)openAppStore:(NSString*)appId {
1560 [storeKitLauncher_ openAppStore:appId]; 1564 StoreKitTabHelper::FromWebState(self.webState)->OpenAppStore(appId);
sdefresne 2017/03/06 19:44:03 The tab helper may be null during tests, can you c
pkl (ping after 24h if needed) 2017/03/07 01:17:54 Done.
1561 } 1565 }
1562 1566
1563 - (BOOL)usesDesktopUserAgent { 1567 - (BOOL)usesDesktopUserAgent {
1564 if (!self.navigationManager) 1568 if (!self.navigationManager)
1565 return NO; 1569 return NO;
1566 1570
1567 web::NavigationItem* visibleItem = self.navigationManager->GetVisibleItem(); 1571 web::NavigationItem* visibleItem = self.navigationManager->GetVisibleItem();
1568 return visibleItem && 1572 return visibleItem &&
1569 visibleItem->GetUserAgentType() == web::UserAgentType::DESKTOP; 1573 visibleItem->GetUserAgentType() == web::UserAgentType::DESKTOP;
1570 } 1574 }
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
2190 - (NativeAppNavigationController*)nativeAppNavigationController { 2194 - (NativeAppNavigationController*)nativeAppNavigationController {
2191 return nativeAppNavigationController_; 2195 return nativeAppNavigationController_;
2192 } 2196 }
2193 2197
2194 - (void)initNativeAppNavigationController { 2198 - (void)initNativeAppNavigationController {
2195 if (browserState_->IsOffTheRecord()) 2199 if (browserState_->IsOffTheRecord())
2196 return; 2200 return;
2197 DCHECK(!nativeAppNavigationController_); 2201 DCHECK(!nativeAppNavigationController_);
2198 nativeAppNavigationController_.reset([[NativeAppNavigationController alloc] 2202 nativeAppNavigationController_.reset([[NativeAppNavigationController alloc]
2199 initWithWebState:self.webState 2203 initWithWebState:self.webState
2200 requestContextGetter:browserState_->GetRequestContext() 2204 requestContextGetter:browserState_->GetRequestContext()]);
2201 tab:self]);
2202 [self.webController addObserver:nativeAppNavigationController_]; 2205 [self.webController addObserver:nativeAppNavigationController_];
2203 DCHECK(nativeAppNavigationController_); 2206 DCHECK(nativeAppNavigationController_);
2204 } 2207 }
2205 2208
2206 - (id<PassKitDialogProvider>)passKitDialogProvider { 2209 - (id<PassKitDialogProvider>)passKitDialogProvider {
2207 return passKitDialogProvider_.get(); 2210 return passKitDialogProvider_.get();
2208 } 2211 }
2209 2212
2210 - (void)setPassKitDialogProvider:(id<PassKitDialogProvider>)provider { 2213 - (void)setPassKitDialogProvider:(id<PassKitDialogProvider>)provider {
2211 passKitDialogProvider_.reset(provider); 2214 passKitDialogProvider_.reset(provider);
(...skipping 25 matching lines...) Expand all
2237 2240
2238 - (TabModel*)parentTabModel { 2241 - (TabModel*)parentTabModel {
2239 return parentTabModel_; 2242 return parentTabModel_;
2240 } 2243 }
2241 2244
2242 - (FormInputAccessoryViewController*)inputAccessoryViewController { 2245 - (FormInputAccessoryViewController*)inputAccessoryViewController {
2243 return inputAccessoryViewController_.get(); 2246 return inputAccessoryViewController_.get();
2244 } 2247 }
2245 2248
2246 @end 2249 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698