| 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 3e6a784b7d86d6ff5c46482598878a4e73c33692..e9fac9ddbf3b48404d01bb6905c248494f5c5d2b 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
|
| @@ -18,11 +18,14 @@
|
| #import "ios/chrome/browser/native_app_launcher/native_app_navigation_controller_protocol.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"
|
| #import "ios/web/public/web_state/web_state_observer_bridge.h"
|
| #include "ios/web/public/web_thread.h"
|
| @@ -51,15 +54,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;
|
| @@ -68,20 +66,14 @@ using base::UserMetricsAction;
|
| }
|
|
|
| // 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];
|
| _webStateObserver =
|
| base::MakeUnique<web::WebStateObserverBridge>(webState, self);
|
| @@ -194,9 +186,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 {
|
| @@ -215,7 +207,8 @@ using base::UserMetricsAction;
|
| #pragma mark - CRWWebStateObserver methods
|
|
|
| - (void)webState:(web::WebState*)webState didLoadPageWithSuccess:(BOOL)success {
|
| - if (success && ![_tab isPrerenderTab])
|
| + Tab* tab = LegacyTabHelper::GetTabForWebState(_webState);
|
| + if (success && ![tab isPrerenderTab])
|
| [self showInfoBarIfNecessary];
|
| }
|
|
|
|
|