Chromium Code Reviews| Index: chrome/browser/ui/desktop_ios_promotion/sms_service_factory.cc |
| diff --git a/chrome/browser/ui/desktop_ios_promotion/sms_service_factory.cc b/chrome/browser/ui/desktop_ios_promotion/sms_service_factory.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..933451097ffdcf4cfe0c3e2041a57c73468ab737 |
| --- /dev/null |
| +++ b/chrome/browser/ui/desktop_ios_promotion/sms_service_factory.cc |
| @@ -0,0 +1,49 @@ |
| +// Copyright 2017 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/desktop_ios_promotion/sms_service_factory.h" |
| + |
| +#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| +#include "chrome/browser/signin/signin_manager_factory.h" |
| +#include "chrome/browser/sync/profile_sync_service_factory.h" |
| +#include "chrome/browser/ui/desktop_ios_promotion/sms_service.h" |
| +#include "components/browser_sync/profile_sync_service.h" |
| +#include "components/keyed_service/content/browser_context_dependency_manager.h" |
| +#include "components/signin/core/browser/profile_oauth2_token_service.h" |
| +#include "components/signin/core/browser/signin_manager.h" |
| +#include "net/url_request/url_request_context_getter.h" |
| + |
| +namespace DesktopIOSPromotion { |
| + |
| +// static |
| +SMSServiceFactory* SMSServiceFactory::GetInstance() { |
| + return base::Singleton<SMSServiceFactory>::get(); |
| +} |
| + |
| +// static |
| +SMSService* SMSServiceFactory::GetForProfile(Profile* profile) { |
| + return static_cast<SMSService*>( |
| + GetInstance()->GetServiceForBrowserContext(profile, true)); |
| +} |
| + |
| +KeyedService* SMSServiceFactory::BuildServiceInstanceFor( |
| + content::BrowserContext* context) const { |
| + Profile* profile = static_cast<Profile*>(context); |
|
msramek
2017/01/27 16:38:57
nit: Profile::FromBrowserContext()
justincohen
2017/01/27 23:06:46
Done.
|
| + return new SMSService( |
| + ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
| + SigninManagerFactory::GetForProfile(profile), |
| + profile->GetRequestContext()); |
| +} |
| + |
| +SMSServiceFactory::SMSServiceFactory() |
| + : BrowserContextKeyedServiceFactory( |
| + "SMSServiceFactory", |
| + BrowserContextDependencyManager::GetInstance()) { |
| + DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); |
| + DependsOn(SigninManagerFactory::GetInstance()); |
| +} |
| + |
| +SMSServiceFactory::~SMSServiceFactory() {} |
| + |
| +} // namespace DesktopIOSPromotion |