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

Unified Diff: ios/chrome/browser/content_suggestions/content_suggestions_coordinator.mm

Issue 2638413006: Add ContentSuggestionsMediator (Closed)
Patch Set: Fix Created 3 years, 11 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/content_suggestions/content_suggestions_coordinator.mm
diff --git a/ios/chrome/browser/content_suggestions/content_suggestions_coordinator.mm b/ios/chrome/browser/content_suggestions/content_suggestions_coordinator.mm
index 0df1af28a4f22c989c334b1f7d501acc80fb752e..add8b361a455ec12127a6cc9bc3f992615e3f6f1 100644
--- a/ios/chrome/browser/content_suggestions/content_suggestions_coordinator.mm
+++ b/ios/chrome/browser/content_suggestions/content_suggestions_coordinator.mm
@@ -5,6 +5,8 @@
#import "ios/chrome/browser/content_suggestions/content_suggestions_coordinator.h"
#include "base/mac/scoped_nsobject.h"
+#import "ios/chrome/browser/content_suggestions/content_suggestions_mediator.h"
+#include "ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service_factory.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_commands.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_view_controller.h"
#include "ios/chrome/grit/ios_strings.h"
@@ -22,19 +24,27 @@
@implementation ContentSuggestionsCoordinator
+@synthesize browserState = _browserState;
@synthesize visible = _visible;
- (void)start {
- if (self.visible) {
- // Prevent this coordinator from being started twice in a row.
+ if (self.visible || !self.browserState) {
+ // Prevent this coordinator from being started twice in a row or without a
+ // browser state.
return;
}
_visible = YES;
+ ContentSuggestionsMediator* contentSuggestionsMediator =
+ [[ContentSuggestionsMediator alloc]
+ initWithContentService:IOSChromeContentSuggestionsServiceFactory::
lpromero 2017/01/26 10:10:20 Should you just pass the ContentService to this co
marq (ping after 24h) 2017/01/27 12:44:55 Globally the idea was that coordinators would mani
gambard 2017/01/30 15:19:17 Acknowledged. I keep the browserState.
+ GetForBrowserState(self.browserState)];
+
ContentSuggestionsViewController* suggestionsViewController =
[[ContentSuggestionsViewController alloc]
- initWithStyle:CollectionViewControllerStyleDefault];
+ initWithStyle:CollectionViewControllerStyleDefault
+ dataSource:contentSuggestionsMediator];
suggestionsViewController.suggestionCommandHandler = self;
_navigationController = [[UINavigationController alloc]

Powered by Google App Engine
This is Rietveld 408576698