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

Unified Diff: ios/chrome/browser/native_app_launcher/native_app_navigation_controller.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/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..8f0b4792447f38febcf58dd71445292ac0a77c9e 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,11 +17,14 @@
#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"
#import "ios/public/provider/chrome/browser/native_app_launcher/native_app_types.h"
#import "ios/public/provider/chrome/browser/native_app_launcher/native_app_whitelist_manager.h"
+#include "ios/web/public/browser_state.h"
#include "ios/web/public/web_state/web_state.h"
#include "ios/web/public/web_thread.h"
#import "ios/web/web_state/ui/crw_web_controller.h"
@@ -48,35 +51,24 @@ 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;
}
// Designated initializer. Use this instead of -init.
-- (instancetype)initWithWebState:(web::WebState*)webState
- requestContextGetter:(net::URLRequestContextGetter*)context
- tab:(Tab*)tab {
+- (instancetype)initWithWebState:(web::WebState*)webState {
self = [super init];
if (self) {
- DCHECK(context);
- _imageFetcher = base::MakeUnique<image_fetcher::IOSImageDataFetcherWrapper>(
- 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;
+ _imageFetcher = base::MakeUnique<image_fetcher::IOSImageDataFetcherWrapper>(
+ _webState->GetBrowserState()->GetRequestContext(),
+ web::WebThread::GetBlockingPool());
_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* tabHelper = StoreKitTabHelper::FromWebState(_webState);
+ if (tabHelper)
+ tabHelper->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