Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 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/favicon/fallback_icon_service_factory.h" | |
| 6 | |
| 7 #include "base/memory/singleton.h" | |
| 8 #include "base/prefs/pref_service.h" | |
| 9 #include "chrome/browser/favicon/chrome_fallback_icon_client_factory.h" | |
| 10 #include "chrome/browser/history/history_service.h" | |
| 11 #include "chrome/browser/history/history_service_factory.h" | |
| 12 #include "chrome/browser/profiles/profile.h" | |
| 13 #include "components/favicon_base/fallback_icon_service.h" | |
| 14 #include "components/keyed_service/content/browser_context_dependency_manager.h" | |
| 15 | |
| 16 // static | |
| 17 favicon_base::FallbackIconService* FallbackIconServiceFactory::GetForProfile( | |
| 18 Profile* profile, ServiceAccessType sat) { | |
| 19 if (!profile->IsOffTheRecord()) { | |
| 20 return static_cast<favicon_base::FallbackIconService*>( | |
| 21 GetInstance()->GetServiceForBrowserContext(profile, true)); | |
| 22 } else if (sat == ServiceAccessType::EXPLICIT_ACCESS) { | |
| 23 // Profile must be OffTheRecord in this case. | |
| 24 return static_cast<favicon_base::FallbackIconService*>( | |
| 25 GetInstance()->GetServiceForBrowserContext( | |
| 26 profile->GetOriginalProfile(), true)); | |
| 27 } | |
| 28 | |
| 29 // Profile is OffTheRecord without access. | |
| 30 NOTREACHED() << "This profile is OffTheRecord"; | |
| 31 return NULL; | |
|
sdefresne
2015/03/16 09:11:29
nit: s/NULL/nullptr/ everywhere (except in comment
huangs
2015/03/16 22:06:11
Done. Doing this for new code (rather than global
| |
| 32 } | |
| 33 | |
| 34 // static | |
| 35 FallbackIconServiceFactory* FallbackIconServiceFactory::GetInstance() { | |
| 36 return Singleton<FallbackIconServiceFactory>::get(); | |
| 37 } | |
| 38 | |
| 39 FallbackIconServiceFactory::FallbackIconServiceFactory() | |
| 40 : BrowserContextKeyedServiceFactory( | |
| 41 "FallbackIconService", | |
| 42 BrowserContextDependencyManager::GetInstance()) { | |
| 43 DependsOn(HistoryServiceFactory::GetInstance()); | |
| 44 DependsOn(ChromeFallbackIconClientFactory::GetInstance()); | |
| 45 } | |
| 46 | |
| 47 FallbackIconServiceFactory::~FallbackIconServiceFactory() {} | |
| 48 | |
| 49 KeyedService* FallbackIconServiceFactory::BuildServiceInstanceFor( | |
| 50 content::BrowserContext* profile) const { | |
| 51 FallbackIconClient* fallback_icon_client = | |
| 52 ChromeFallbackIconClientFactory::GetForProfile( | |
| 53 static_cast<Profile*>(profile)); | |
| 54 return new favicon_base::FallbackIconService(fallback_icon_client); | |
| 55 } | |
| 56 | |
| 57 bool FallbackIconServiceFactory::ServiceIsNULLWhileTesting() const { | |
| 58 return true; | |
| 59 } | |
| OLD | NEW |