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

Unified Diff: ios/chrome/browser/tabs/tab.mm

Issue 2731553005: Introduced StoreKitTabHelper class (Closed)
Patch Set: rebased and address sdefresne's 2nd round comments 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/tabs/tab.mm
diff --git a/ios/chrome/browser/tabs/tab.mm b/ios/chrome/browser/tabs/tab.mm
index 7d91c95341b789c32f64aca09e4026dc68e685ea..bb7f69a41d35c8f56349c2158c41943304301f82 100644
--- a/ios/chrome/browser/tabs/tab.mm
+++ b/ios/chrome/browser/tabs/tab.mm
@@ -85,7 +85,7 @@
#import "ios/chrome/browser/snapshots/snapshot_overlay_provider.h"
#import "ios/chrome/browser/snapshots/web_controller_snapshot_helper.h"
#include "ios/chrome/browser/ssl/ios_security_state_tab_helper.h"
-#import "ios/chrome/browser/storekit_launcher.h"
+#import "ios/chrome/browser/store_kit/store_kit_tab_helper.h"
#include "ios/chrome/browser/sync/ios_chrome_synced_tab_delegate.h"
#import "ios/chrome/browser/tabs/legacy_tab_helper.h"
#import "ios/chrome/browser/tabs/tab_delegate.h"
@@ -222,9 +222,6 @@ enum class RendererTerminationTabState {
base::scoped_nsobject<OpenInController> openInController_;
base::WeakNSProtocol<id<PassKitDialogProvider>> passKitDialogProvider_;
- // TODO(crbug.com/546213): Move this out of Tab, probably to native app
- // launcher since that's the only thing that uses it.
- base::WeakNSProtocol<id<StoreKitLauncher>> storeKitLauncher_;
// Whether or not this tab is currently being displayed.
BOOL visible_;
@@ -571,6 +568,7 @@ void TabInfoBarObserver::OnInfoBarReplaced(infobars::InfoBar* old_infobar,
RepostFormTabHelper::CreateForWebState(self.webState);
BlockedPopupTabHelper::CreateForWebState(self.webState);
FindTabHelper::CreateForWebState(self.webState, self);
+ StoreKitTabHelper::CreateForWebState(self.webState);
if (reading_list::switches::IsReadingListEnabled()) {
ReadingListModel* model =
@@ -886,11 +884,14 @@ void TabInfoBarObserver::OnInfoBarReplaced(infobars::InfoBar* old_infobar,
}
- (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.
- return storeKitLauncher_.get();
+ StoreKitTabHelper* tabHelper = StoreKitTabHelper::FromWebState(self.webState);
+ 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.
}
- (void)setStoreKitLauncher:(id<StoreKitLauncher>)storeKitLauncher {
- storeKitLauncher_.reset(storeKitLauncher);
+ StoreKitTabHelper* tabHelper = StoreKitTabHelper::FromWebState(self.webState);
+ if (tabHelper)
+ tabHelper->SetLauncher(storeKitLauncher);
}
// Swap out the existing session history with a new list of navigations. Forces
@@ -1212,7 +1213,6 @@ void TabInfoBarObserver::OnInfoBarReplaced(infobars::InfoBar* old_infobar,
self.overscrollActionsControllerDelegate = nil;
self.passKitDialogProvider = nil;
self.snapshotOverlayProvider = nil;
- 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.
[[NSNotificationCenter defaultCenter] removeObserver:self];
@@ -1451,11 +1451,17 @@ void TabInfoBarObserver::OnInfoBarReplaced(infobars::InfoBar* old_infobar,
}
- (id<CRWNativeContent>)controllerForUnhandledContentAtURL:(const GURL&)url {
+ StoreKitTabHelper* helper = StoreKitTabHelper::FromWebState(self.webState);
+ if (!helper)
+ return nil;
+ id<StoreKitLauncher> storeKitLauncher = helper->GetLauncher();
+ if (!storeKitLauncher)
+ return nil;
DownloadManagerController* downloadController =
[[[DownloadManagerController alloc]
initWithURL:url
requestContextGetter:browserState_->GetRequestContext()
- storeKitLauncher:self.storeKitLauncher] autorelease];
+ storeKitLauncher:storeKitLauncher] autorelease];
[downloadController start];
return downloadController;
}
@@ -1557,7 +1563,9 @@ void TabInfoBarObserver::OnInfoBarReplaced(infobars::InfoBar* old_infobar,
#pragma mark -
- (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.
- [storeKitLauncher_ openAppStore:appId];
+ StoreKitTabHelper* tabHelper = StoreKitTabHelper::FromWebState(self.webState);
+ if (tabHelper)
+ tabHelper->OpenAppStore(appId);
}
- (BOOL)usesDesktopUserAgent {
@@ -2195,10 +2203,8 @@ void TabInfoBarObserver::OnInfoBarReplaced(infobars::InfoBar* old_infobar,
if (browserState_->IsOffTheRecord())
return;
DCHECK(!nativeAppNavigationController_);
- nativeAppNavigationController_.reset([[NativeAppNavigationController alloc]
- initWithWebState:self.webState
- requestContextGetter:browserState_->GetRequestContext()
- tab:self]);
+ nativeAppNavigationController_.reset(
+ [[NativeAppNavigationController alloc] initWithWebState:self.webState]);
DCHECK(nativeAppNavigationController_);
}

Powered by Google App Engine
This is Rietveld 408576698