| Index: chrome/browser/ntp_content/ntp_content_service_factory.cc
|
| diff --git a/chrome/browser/ntp_content/ntp_content_service_factory.cc b/chrome/browser/ntp_content/ntp_content_service_factory.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b46e6ddfa66f8be384c275654032a7745e98e365
|
| --- /dev/null
|
| +++ b/chrome/browser/ntp_content/ntp_content_service_factory.cc
|
| @@ -0,0 +1,49 @@
|
| +// 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/ntp_content/ntp_content_service_factory.h"
|
| +
|
| +#include "base/logging.h"
|
| +#include "base/memory/singleton.h"
|
| +#include "chrome/browser/browser_process.h"
|
| +#include "chrome/browser/profiles/incognito_helpers.h"
|
| +#include "components/keyed_service/content/browser_context_dependency_manager.h"
|
| +#include "components/ntp_content/ntp_content_service.h"
|
| +#include "content/public/browser/browser_context.h"
|
| +
|
| +namespace ntp_content {
|
| +
|
| +// static
|
| +NTPContentServiceFactory* NTPContentServiceFactory::GetInstance() {
|
| + return base::Singleton<NTPContentServiceFactory>::get();
|
| +}
|
| +
|
| +// static
|
| +NTPContentService*
|
| +NTPContentServiceFactory::GetForBrowserContext(
|
| + content::BrowserContext* context) {
|
| + DCHECK(!context->IsOffTheRecord());
|
| + return static_cast<NTPContentService*>(
|
| + GetInstance()->GetServiceForBrowserContext(context, true));
|
| +}
|
| +
|
| +NTPContentServiceFactory::NTPContentServiceFactory()
|
| + : BrowserContextKeyedServiceFactory(
|
| + "NTPContentService",
|
| + BrowserContextDependencyManager::GetInstance()) {}
|
| +
|
| +NTPContentServiceFactory::~NTPContentServiceFactory() {}
|
| +
|
| +KeyedService* NTPContentServiceFactory::BuildServiceInstanceFor(
|
| + content::BrowserContext* context) const {
|
| + DCHECK(!context->IsOffTheRecord());
|
| + return new NTPContentService(g_browser_process->GetApplicationLocale());
|
| +}
|
| +
|
| +content::BrowserContext* NTPContentServiceFactory::GetBrowserContextToUse(
|
| + content::BrowserContext* context) const {
|
| + return chrome::GetBrowserContextRedirectedInIncognito(context);
|
| +}
|
| +
|
| +} // namespace ntp_content
|
|
|