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/translate/translate_ranker_factory.h" |
| 6 |
| 7 #include "chrome/browser/profiles/incognito_helpers.h" |
| 8 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 9 #include "components/keyed_service/core/keyed_service.h" |
| 10 #include "components/translate/core/browser/translate_ranker_impl.h" |
| 11 #include "components/translate/core/common/translate_switches.h" |
| 12 #include "components/variations/variations_associated_data.h" |
| 13 #include "content/public/browser/browser_context.h" |
| 14 |
| 15 namespace translate { |
| 16 |
| 17 // static |
| 18 TranslateRankerFactory* TranslateRankerFactory::GetInstance() { |
| 19 return base::Singleton<TranslateRankerFactory>::get(); |
| 20 } |
| 21 |
| 22 // static |
| 23 translate::TranslateRanker* TranslateRankerFactory::GetForBrowserContext( |
| 24 content::BrowserContext* browser_context) { |
| 25 return static_cast<translate::TranslateRanker*>( |
| 26 GetInstance()->GetServiceForBrowserContext(browser_context, true)); |
| 27 } |
| 28 |
| 29 TranslateRankerFactory::TranslateRankerFactory() |
| 30 : BrowserContextKeyedServiceFactory( |
| 31 "TranslateRanker", |
| 32 BrowserContextDependencyManager::GetInstance()) {} |
| 33 |
| 34 TranslateRankerFactory::~TranslateRankerFactory() {} |
| 35 |
| 36 KeyedService* TranslateRankerFactory::BuildServiceInstanceFor( |
| 37 content::BrowserContext* browser_context) const { |
| 38 return new TranslateRankerImpl( |
| 39 TranslateRankerImpl::GetModelPath(browser_context->GetPath()), |
| 40 TranslateRankerImpl::GetModelURL()); |
| 41 } |
| 42 |
| 43 content::BrowserContext* TranslateRankerFactory::GetBrowserContextToUse( |
| 44 content::BrowserContext* context) const { |
| 45 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 46 } |
| 47 |
| 48 } // namespace translate |
OLD | NEW |