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

Unified Diff: ios/chrome/browser/native_app_launcher/native_app_navigation_controller.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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/native_app_launcher/native_app_navigation_controller.mm
diff --git a/ios/chrome/browser/native_app_launcher/native_app_navigation_controller.mm b/ios/chrome/browser/native_app_launcher/native_app_navigation_controller.mm
index 0db27591e80d3465e02be101b2109f4cb758f71a..bc3312af7185a04cee46bedd3adab0dfb09457b9 100644
--- a/ios/chrome/browser/native_app_launcher/native_app_navigation_controller.mm
+++ b/ios/chrome/browser/native_app_launcher/native_app_navigation_controller.mm
@@ -17,6 +17,8 @@
#include "ios/chrome/browser/native_app_launcher/native_app_infobar_delegate.h"
#include "ios/chrome/browser/native_app_launcher/native_app_navigation_util.h"
#import "ios/chrome/browser/open_url_util.h"
+#import "ios/chrome/browser/store_kit/store_kit_tab_helper.h"
+#import "ios/chrome/browser/tabs/legacy_tab_helper.h"
#import "ios/chrome/browser/tabs/tab.h"
#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
#import "ios/public/provider/chrome/browser/native_app_launcher/native_app_metadata.h"
@@ -48,15 +50,10 @@ using base::UserMetricsAction;
@end
@implementation NativeAppNavigationController {
- // WebState provides access to the *TabHelper objects. This will eventually
- // replace the need to have |_tab| in this object.
+ // WebState provides access to the *TabHelper objects.
web::WebState* _webState;
// ImageFetcher needed to fetch the icons.
std::unique_ptr<image_fetcher::IOSImageDataFetcherWrapper> _imageFetcher;
- // DEPRECATED: Tab hosting the infobar and is also used for accessing Tab
- // states such as navigation manager and whether it is a pre-rendered tab.
- // Use |webState| whenever possible.
- __weak Tab* _tab;
id<NativeAppMetadata> _metadata;
// A set of appIds encoded as NSStrings.
NSMutableSet* _appsPossiblyBeingInstalled;
@@ -64,8 +61,7 @@ using base::UserMetricsAction;
// Designated initializer. Use this instead of -init.
- (instancetype)initWithWebState:(web::WebState*)webState
- requestContextGetter:(net::URLRequestContextGetter*)context
- tab:(Tab*)tab {
+ requestContextGetter:(net::URLRequestContextGetter*)context {
self = [super init];
if (self) {
DCHECK(context);
@@ -73,10 +69,6 @@ using base::UserMetricsAction;
context, web::WebThread::GetBlockingPool());
DCHECK(webState);
_webState = webState;
- // Allows |tab| to be nil for unit testing. If not nil, it should have the
- // same webState.
- DCHECK(!tab || [tab webState] == webState);
- _tab = tab;
_appsPossiblyBeingInstalled = [[NSMutableSet alloc] init];
}
return self;
@@ -188,9 +180,9 @@ using base::UserMetricsAction;
return;
DCHECK(![_appsPossiblyBeingInstalled containsObject:appIdString]);
[_appsPossiblyBeingInstalled addObject:appIdString];
- // TODO(crbug.com/684063): Preferred method is to add a helper object to
- // WebState and use the helper object to launch Store Kit.
- [_tab openAppStore:appIdString];
+ StoreKitTabHelper* tab_helper = StoreKitTabHelper::FromWebState(_webState);
+ if (tab_helper)
+ tab_helper->OpenAppStore(appIdString);
}
- (void)launchApp:(const GURL&)URL {
@@ -210,7 +202,8 @@ using base::UserMetricsAction;
#pragma mark CRWWebControllerObserver methods
- (void)pageLoaded:(CRWWebController*)webController {
- if (![_tab isPrerenderTab])
+ Tab* tab = LegacyTabHelper::GetTabForWebState(_webState);
+ if (![tab isPrerenderTab])
[self showInfoBarIfNecessary];
}

Powered by Google App Engine
This is Rietveld 408576698