| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/android/blimp/blimp_client_context_factory.h" | |
| 6 | |
| 7 #include "base/memory/ptr_util.h" | |
| 8 #include "base/memory/singleton.h" | |
| 9 #include "base/supports_user_data.h" | |
| 10 #include "blimp/client/public/blimp_client_context.h" | |
| 11 #include "blimp/client/public/compositor/compositor_dependencies.h" | |
| 12 #include "chrome/browser/android/blimp/chrome_compositor_dependencies.h" | |
| 13 #include "chrome/browser/profiles/profile.h" | |
| 14 #include "components/keyed_service/content/browser_context_dependency_manager.h" | |
| 15 #include "content/public/browser/browser_context.h" | |
| 16 #include "content/public/browser/browser_thread.h" | |
| 17 #include "ui/android/context_provider_factory.h" | |
| 18 | |
| 19 // static | |
| 20 BlimpClientContextFactory* BlimpClientContextFactory::GetInstance() { | |
| 21 return base::Singleton<BlimpClientContextFactory>::get(); | |
| 22 } | |
| 23 | |
| 24 // static | |
| 25 blimp::client::BlimpClientContext* | |
| 26 BlimpClientContextFactory::GetForBrowserContext( | |
| 27 content::BrowserContext* context) { | |
| 28 DCHECK(!context->IsOffTheRecord()); | |
| 29 return static_cast<blimp::client::BlimpClientContext*>( | |
| 30 GetInstance()->GetServiceForBrowserContext(context, true)); | |
| 31 } | |
| 32 | |
| 33 BlimpClientContextFactory::BlimpClientContextFactory() | |
| 34 : BrowserContextKeyedServiceFactory( | |
| 35 "blimp::client::BlimpClientContext", | |
| 36 BrowserContextDependencyManager::GetInstance()) {} | |
| 37 | |
| 38 BlimpClientContextFactory::~BlimpClientContextFactory() {} | |
| 39 | |
| 40 KeyedService* BlimpClientContextFactory::BuildServiceInstanceFor( | |
| 41 content::BrowserContext* context) const { | |
| 42 return blimp::client::BlimpClientContext::Create( | |
| 43 content::BrowserThread::GetTaskRunnerForThread( | |
| 44 content::BrowserThread::IO), | |
| 45 content::BrowserThread::GetTaskRunnerForThread( | |
| 46 content::BrowserThread::FILE), | |
| 47 base::MakeUnique<ChromeCompositorDependencies>( | |
| 48 ui::ContextProviderFactory::GetInstance()), | |
| 49 Profile::FromBrowserContext(context)->GetPrefs()); | |
| 50 } | |
| 51 | |
| 52 content::BrowserContext* BlimpClientContextFactory::GetBrowserContextToUse( | |
| 53 content::BrowserContext* context) const { | |
| 54 return context; | |
| 55 } | |
| OLD | NEW |