Chromium Code Reviews| Index: ios/chrome/browser/ui/ntp/google_landing_mediator.mm |
| diff --git a/ios/chrome/browser/ui/ntp/google_landing_mediator.mm b/ios/chrome/browser/ui/ntp/google_landing_mediator.mm |
| index 70297c09b0cc80eb88085a480018b9b1c7aba6d3..5dfa2c379cae5256d8907e7b147f4b4517212b6a 100644 |
| --- a/ios/chrome/browser/ui/ntp/google_landing_mediator.mm |
| +++ b/ios/chrome/browser/ui/ntp/google_landing_mediator.mm |
| @@ -35,6 +35,7 @@ |
| #import "ios/chrome/browser/web_state_list/web_state_list_observer_bridge.h" |
| #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
| #include "ios/public/provider/chrome/browser/voice/voice_search_provider.h" |
| +#include "ios/web/public/web_state/web_state.h" |
| using base::UserMetricsAction; |
| @@ -175,6 +176,12 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() { |
| [_consumer |
| setMaximumMostVisitedSitesShown:[GoogleLandingMediator maxSitesShown]]; |
| [_consumer setTabCount:self.webStateList->count()]; |
| + web::WebState* webState = _webStateList->GetActiveWebState(); |
| + if (webState) { |
|
rohitrao (ping after 24h)
2017/04/28 10:39:59
Should we forcibly disable the buttons if there is
justincohen
2017/04/28 13:23:04
No, it means this NTP is about to be destroyed.
|
| + web::NavigationManager* nav = webState->GetNavigationManager(); |
| + [_consumer setCanGoForward:nav->CanGoForward()]; |
| + [_consumer setCanGoBack:nav->CanGoBack()]; |
| + } |
| // Set up template URL service to listen for default search engine changes. |
| _templateURLService = |
| @@ -278,6 +285,22 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() { |
| [self.consumer setTabCount:self.webStateList->count()]; |
| } |
| +// If the actual webState associated with this mediator were passed in, this |
| +// would not be necessary. However, since the active webstate can change when |
| +// the new tab page is created (and animated in), listen for changes here and |
| +// always display what's active. |
| +- (void)webStateList:(WebStateList*)webStateList |
| + didChangeActiveWebState:(web::WebState*)newWebState |
| + oldWebState:(web::WebState*)oldWebState |
| + atIndex:(int)atIndex |
| + userAction:(BOOL)userAction { |
| + if (newWebState) { |
|
rohitrao (ping after 24h)
2017/04/28 10:39:59
Same question -- if newWebState is nil, should we
justincohen
2017/04/28 13:23:04
No, it means this NTP is about to go away.
|
| + web::NavigationManager* nav = newWebState->GetNavigationManager(); |
| + [self.consumer setCanGoForward:nav->CanGoForward()]; |
| + [self.consumer setCanGoBack:nav->CanGoBack()]; |
| + } |
| +} |
| + |
| #pragma mark - GoogleLandingDataSource |
| - (void)addBlacklistedURL:(const GURL&)url { |
| @@ -317,10 +340,6 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() { |
| return IOSChromeLargeIconServiceFactory::GetForBrowserState(_browserState); |
| } |
| -- (id<WebToolbarDelegate>)toolbarDelegate { |
| - return _webToolbarDelegate; |
| -} |
| - |
| - (void)promoViewed { |
| DCHECK(_notification_promo); |
| _notification_promo->HandleViewed(); |
| @@ -350,6 +369,10 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() { |
| NOTREACHED(); |
| } |
| +- (void)prepareToEnterTabSwitcher:(id)sender { |
|
rohitrao (ping after 24h)
2017/04/28 10:39:59
Can you document why this call is necessary?
justincohen
2017/04/28 13:23:04
Done.
|
| + [_webToolbarDelegate prepareToEnterTabSwitcher:sender]; |
|
rohitrao (ping after 24h)
2017/04/28 10:39:59
I thought you added this method to the DataSource
justincohen
2017/04/28 13:23:04
This is the data source protocol -- note that this
|
| +} |
| + |
| #pragma mark - UrlLoader |
| - (void)loadURL:(const GURL&)url |