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

Side by Side Diff: chrome/browser/android/blimp/blimp_client_context_factory.cc

Issue 2204223005: Blimp OAuth2 token retreival on application start up. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build config. Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/blimp/blimp_client_context_factory.h" 5 #include "chrome/browser/android/blimp/blimp_client_context_factory.h"
6 6
7 #include "base/memory/ptr_util.h"
7 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
8 #include "base/supports_user_data.h" 9 #include "base/supports_user_data.h"
9 #include "blimp/client/public/blimp_client_context.h" 10 #include "blimp/client/public/blimp_client_context.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
13 #include "chrome/browser/signin/signin_manager_factory.h"
10 #include "components/keyed_service/content/browser_context_dependency_manager.h" 14 #include "components/keyed_service/content/browser_context_dependency_manager.h"
15 #include "components/signin/core/browser/profile_identity_provider.h"
16 #include "components/signin/core/browser/signin_manager.h"
11 #include "content/public/browser/browser_context.h" 17 #include "content/public/browser/browser_context.h"
12 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
13 19
14 // static 20 // static
15 BlimpClientContextFactory* BlimpClientContextFactory::GetInstance() { 21 BlimpClientContextFactory* BlimpClientContextFactory::GetInstance() {
16 return base::Singleton<BlimpClientContextFactory>::get(); 22 return base::Singleton<BlimpClientContextFactory>::get();
17 } 23 }
18 24
19 // static 25 // static
20 blimp::client::BlimpClientContext* 26 blimp::client::BlimpClientContext*
21 BlimpClientContextFactory::GetForBrowserContext( 27 BlimpClientContextFactory::GetForBrowserContext(
22 content::BrowserContext* context) { 28 content::BrowserContext* context) {
23 return static_cast<blimp::client::BlimpClientContext*>( 29 return static_cast<blimp::client::BlimpClientContext*>(
24 GetInstance()->GetServiceForBrowserContext(context, true)); 30 GetInstance()->GetServiceForBrowserContext(context, true));
25 } 31 }
26 32
27 BlimpClientContextFactory::BlimpClientContextFactory() 33 BlimpClientContextFactory::BlimpClientContextFactory()
28 : BrowserContextKeyedServiceFactory( 34 : BrowserContextKeyedServiceFactory(
29 "blimp::client::BlimpClientContext", 35 "blimp::client::BlimpClientContext",
30 BrowserContextDependencyManager::GetInstance()) {} 36 BrowserContextDependencyManager::GetInstance()) {
37 }
31 38
32 BlimpClientContextFactory::~BlimpClientContextFactory() {} 39 BlimpClientContextFactory::~BlimpClientContextFactory() {}
33 40
34 KeyedService* BlimpClientContextFactory::BuildServiceInstanceFor( 41 KeyedService* BlimpClientContextFactory::BuildServiceInstanceFor(
35 content::BrowserContext* context) const { 42 content::BrowserContext* context) const {
36 return blimp::client::BlimpClientContext::Create( 43 Profile* profile = static_cast<Profile*>(context);
44
45 KeyedService* blimp_context = blimp::client::BlimpClientContext::Create(
37 content::BrowserThread::GetTaskRunnerForThread( 46 content::BrowserThread::GetTaskRunnerForThread(
38 content::BrowserThread::IO)); 47 content::BrowserThread::IO));
48
49 // Create OAuth2 token authenticator.
50 std::unique_ptr<IdentityProvider> identity_provider =
51 base::WrapUnique<IdentityProvider>(new ProfileIdentityProvider(
52 SigninManagerFactory::GetForProfile(profile),
53 ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
54 base::Closure()));
55
56 static_cast<blimp::client::BlimpClientContext*>(blimp_context)
57 ->CreateAuthenticator(std::move(identity_provider));
58
59 return blimp_context;
39 } 60 }
40 61
41 content::BrowserContext* BlimpClientContextFactory::GetBrowserContextToUse( 62 content::BrowserContext* BlimpClientContextFactory::GetBrowserContextToUse(
42 content::BrowserContext* context) const { 63 content::BrowserContext* context) const {
43 return context; 64 return context;
44 } 65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698