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

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

Issue 2731553005: Introduced StoreKitTabHelper class (Closed)
Patch Set: fixed variable naming 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 5b589354d00f43ddc78e40eb691844cddb3d69dd..87a134fd802ffe6721ac7624af83e6b268d5272b 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 {
- return storeKitLauncher_.get();
+ StoreKitTabHelper* tabHelper = StoreKitTabHelper::FromWebState(self.webState);
+ return tabHelper ? tabHelper->GetLauncher() : nil;
}
- (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;
[[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 {
- [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]);
[self.webController addObserver:nativeAppNavigationController_];
DCHECK(nativeAppNavigationController_);
}

Powered by Google App Engine
This is Rietveld 408576698