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

Unified Diff: ios/chrome/browser/ntp_snippets/ios_chrome_ntp_snippets_service_factory.cc

Issue 1677073002: Fetch snippets from ChromeReader and show them on the NTP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR comments, modified iOS NTPSnippetServiceFactory Created 4 years, 10 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/ntp_snippets/ios_chrome_ntp_snippets_service_factory.cc
diff --git a/ios/chrome/browser/ntp_snippets/ios_chrome_ntp_snippets_service_factory.cc b/ios/chrome/browser/ntp_snippets/ios_chrome_ntp_snippets_service_factory.cc
index 4fa922ed35899f24b898302fd7e520d70d8b54f1..8a134afa8875ef45b950d1f94b402a20e60735c5 100644
--- a/ios/chrome/browser/ntp_snippets/ios_chrome_ntp_snippets_service_factory.cc
+++ b/ios/chrome/browser/ntp_snippets/ios_chrome_ntp_snippets_service_factory.cc
@@ -8,8 +8,14 @@
#include "base/memory/singleton.h"
#include "components/keyed_service/ios/browser_state_dependency_manager.h"
#include "components/ntp_snippets/ntp_snippets_service.h"
+#include "components/signin/core/browser/profile_oauth2_token_service.h"
+#include "google_apis/gaia/oauth2_token_service.h"
#include "ios/chrome/browser/application_context.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
+#include "ios/chrome/browser/signin/oauth2_token_service_factory.h"
+#include "ios/chrome/browser/signin/signin_manager_factory.h"
+#include "ios/web/public/web_thread.h"
+#include "net/url_request/url_request_context_getter.h"
// static
IOSChromeNTPSnippetsServiceFactory*
@@ -40,3 +46,26 @@ IOSChromeNTPSnippetsServiceFactory::BuildServiceInstanceFor(
return make_scoped_ptr(new ntp_snippets::NTPSnippetsService(
GetApplicationContext()->GetApplicationLocale()));
}
noyau (Ping after 24h) 2016/02/17 20:19:48 You should probably remove this implementation, no
May 2016/02/19 14:49:02 Saw it after I uploaded.. done.
+
+scoped_ptr<KeyedService>
+IOSChromeNTPSnippetsServiceFactory::BuildServiceInstanceFor(
+ web::BrowserState* browser_state) const {
+ ios::ChromeBrowserState* chrome_browser_state =
+ ios::ChromeBrowserState::FromBrowserState(browser_state);
+ DCHECK(!browser_state->IsOffTheRecord());
+ SigninManager* signin_manager =
+ ios::SigninManagerFactory::GetForBrowserState(chrome_browser_state);
+ OAuth2TokenService* token_service =
+ OAuth2TokenServiceFactory::GetForBrowserState(chrome_browser_state);
+ scoped_refptr<net::URLRequestContextGetter> request_context =
+ browser_state->GetRequestContext();
+ scoped_refptr<base::SequencedTaskRunner> task_runner =
+ web::WebThread::GetBlockingPool()
+ ->GetSequencedTaskRunnerWithShutdownBehavior(
+ base::SequencedWorkerPool::GetSequenceToken(),
+ base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
+ return new ntp_snippets::NTPSnippetsService(
+ task_runner, GetApplicationContext()->GetApplicationLocale(),
+ make_scoped_ptr(new ntp_snippets::NTPSnippetsFetcher(
+ task_runner, signin_manager, token_service, request_context.get())));
+}

Powered by Google App Engine
This is Rietveld 408576698