Chromium Code Reviews| 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..70fb194edf1e54c8e059613d935aed506b29ee68 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 |
| @@ -23,8 +23,8 @@ |
| #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/web_state/web_state.h" |
| +#import "ios/web/public/web_state/web_state_observer_bridge.h" |
| #include "ios/web/public/web_thread.h" |
| -#import "ios/web/web_state/ui/crw_web_controller.h" |
| #import "net/base/mac/url_conversions.h" |
| #if !defined(__has_feature) || !__has_feature(objc_arc) |
| @@ -33,7 +33,9 @@ |
| using base::UserMetricsAction; |
| -@interface NativeAppNavigationController () |
| +@interface NativeAppNavigationController ()< |
| + CRWWebStateObserver, |
| + NativeAppNavigationControllerProtocol> |
| // Shows a native app infobar by looking at the page's URL and by checking |
| // wheter that infobar should be bypassed or not. |
| - (void)showInfoBarIfNecessary; |
| @@ -60,6 +62,8 @@ using base::UserMetricsAction; |
| id<NativeAppMetadata> _metadata; |
| // A set of appIds encoded as NSStrings. |
| NSMutableSet* _appsPossiblyBeingInstalled; |
| + // Allows this class to subscribe for CRWWebStateObserver callbacks. |
| + std::unique_ptr<web::WebStateObserverBridge> _webStateObserver; |
| } |
| // Designated initializer. Use this instead of -init. |
| @@ -78,6 +82,7 @@ using base::UserMetricsAction; |
| DCHECK(!tab || [tab webState] == webState); |
| _tab = tab; |
| _appsPossiblyBeingInstalled = [[NSMutableSet alloc] init]; |
| + _webStateObserver.reset(new web::WebStateObserverBridge(webState, self)); |
|
michaeldo
2017/03/04 00:35:38
Use base::MakeUnique here instead of new?
_webSta
Eugene But (OOO till 7-30)
2017/03/04 01:01:50
Done.
|
| } |
| return self; |
| } |
| @@ -159,8 +164,7 @@ using base::UserMetricsAction; |
| } |
| } |
| -#pragma mark - |
| -#pragma mark NativeAppNavigationControllerProtocol methods |
| +#pragma mark - NativeAppNavigationControllerProtocol methods |
| - (NSString*)appId { |
| return [_metadata appId]; |
| @@ -206,18 +210,19 @@ using base::UserMetricsAction; |
| [_metadata updateWithUserAction:userAction]; |
| } |
| -#pragma mark - |
| -#pragma mark CRWWebControllerObserver methods |
| +#pragma mark - CRWWebStateObserver methods |
| -- (void)pageLoaded:(CRWWebController*)webController { |
| - if (![_tab isPrerenderTab]) |
| +- (void)webState:(web::WebState*)webState didLoadPageWithSuccess:(BOOL)success { |
| + if (success && ![_tab isPrerenderTab]) |
| [self showInfoBarIfNecessary]; |
| } |
| -- (void)webControllerWillClose:(CRWWebController*)webController { |
| - [webController removeObserver:self]; |
| +- (void)webStateDestroyed:(web::WebState*)webState { |
| + _webState = nullptr; |
|
michaeldo
2017/03/04 00:35:38
Shouldn't we also cleanup/reset |_webStateObserver
Eugene But (OOO till 7-30)
2017/03/04 01:01:50
Added _webStateObserver.reset(). I don't really wa
michaeldo
2017/03/04 01:26:40
good call :)
|
| } |
| +#pragma mark - Private methods |
| + |
| - (void)appDidInstall:(NSNotification*)notification { |
| [self removeAppFromNotification:notification]; |
| [self showInfoBarIfNecessary]; |