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

Unified Diff: chrome/browser/ui/search/new_tab_page_interceptor_service_factory.cc

Issue 845973005: [New Tab Page] Change the mechanism to intercept online NTP errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moved to profile_io_data Created 5 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: chrome/browser/ui/search/new_tab_page_interceptor_service_factory.cc
diff --git a/chrome/browser/ui/search/new_tab_page_interceptor_service_factory.cc b/chrome/browser/ui/search/new_tab_page_interceptor_service_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f78caa835fd096fa1ae94bc656ae981e5dc8b8ad
--- /dev/null
+++ b/chrome/browser/ui/search/new_tab_page_interceptor_service_factory.cc
@@ -0,0 +1,48 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/search/new_tab_page_interceptor_service_factory.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/search/instant_service_factory.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
+#include "chrome/browser/ui/search/new_tab_page_interceptor_service.h"
+#include "components/keyed_service/content/browser_context_dependency_manager.h"
+#include "content/public/browser/browser_thread.h"
+
+// static
+NewTabPageInterceptorServiceFactory*
+NewTabPageInterceptorServiceFactory::GetInstance() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ return Singleton<NewTabPageInterceptorServiceFactory>::get();
+}
+
+// static
+NewTabPageInterceptorService*
+NewTabPageInterceptorServiceFactory::GetForProfile(Profile* profile) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ if (profile->IsOffTheRecord())
+ return nullptr;
+
+ return static_cast<NewTabPageInterceptorService*>(
+ GetInstance()->GetServiceForBrowserContext(profile, true));
+}
+
+NewTabPageInterceptorServiceFactory::NewTabPageInterceptorServiceFactory()
+ : BrowserContextKeyedServiceFactory(
+ "NTP Request Interceptor Service Factory",
+ BrowserContextDependencyManager::GetInstance()) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ DependsOn(TemplateURLServiceFactory::GetInstance());
+}
+
+NewTabPageInterceptorServiceFactory::~NewTabPageInterceptorServiceFactory() {
+}
+
+KeyedService* NewTabPageInterceptorServiceFactory::BuildServiceInstanceFor(
+ content::BrowserContext* context) const {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ Profile* profile = Profile::FromBrowserContext(context);
+ return new NewTabPageInterceptorService(profile);
+}
« no previous file with comments | « chrome/browser/ui/search/new_tab_page_interceptor_service_factory.h ('k') | chrome/browser/ui/search/search_tab_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698