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" | |
|
pkotwicz
2015/03/27 03:52:09
Is this include necessary?
huangs
2015/03/27 17:33:07
Removed.
| |
| 9 #include "chrome/browser/favicon/chrome_fallback_icon_client_factory.h" | |
| 10 #include "chrome/browser/profiles/profile.h" | |
| 11 #include "components/favicon/core/fallback_icon_service.h" | |
| 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" | |
| 13 | |
| 14 // static | |
| 15 FallbackIconService* FallbackIconServiceFactory::GetForProfile( | |
| 16 Profile* profile, ServiceAccessType sat) { | |
| 17 if (!profile->IsOffTheRecord()) { | |
| 18 return static_cast<FallbackIconService*>( | |
| 19 GetInstance()->GetServiceForBrowserContext(profile, true)); | |
| 20 } else if (sat == ServiceAccessType::EXPLICIT_ACCESS) { | |
| 21 // Profile must be OffTheRecord in this case. | |
| 22 return static_cast<FallbackIconService*>( | |
| 23 GetInstance()->GetServiceForBrowserContext( | |
| 24 profile->GetOriginalProfile(), true)); | |
| 25 } | |
| 26 | |
| 27 // Profile is OffTheRecord without access. | |
| 28 NOTREACHED() << "This profile is OffTheRecord"; | |
| 29 return nullptr; | |
|
pkotwicz
2015/03/27 03:52:09
Is there a reason that you are passing in the |sat
huangs
2015/03/27 17:33:07
FallbackIconServiceFactory was forked from Favicon
| |
| 30 } | |
| 31 | |
| 32 // static | |
| 33 FallbackIconServiceFactory* FallbackIconServiceFactory::GetInstance() { | |
| 34 return Singleton<FallbackIconServiceFactory>::get(); | |
| 35 } | |
| 36 | |
| 37 FallbackIconServiceFactory::FallbackIconServiceFactory() | |
| 38 : BrowserContextKeyedServiceFactory( | |
| 39 "FallbackIconService", | |
| 40 BrowserContextDependencyManager::GetInstance()) { | |
| 41 DependsOn(ChromeFallbackIconClientFactory::GetInstance()); | |
| 42 } | |
| 43 | |
| 44 FallbackIconServiceFactory::~FallbackIconServiceFactory() {} | |
| 45 | |
| 46 KeyedService* FallbackIconServiceFactory::BuildServiceInstanceFor( | |
| 47 content::BrowserContext* profile) const { | |
| 48 FallbackIconClient* fallback_icon_client = | |
| 49 ChromeFallbackIconClientFactory::GetForProfile( | |
| 50 static_cast<Profile*>(profile)); | |
| 51 return new FallbackIconService(fallback_icon_client); | |
| 52 } | |
| 53 | |
| 54 bool FallbackIconServiceFactory::ServiceIsNULLWhileTesting() const { | |
| 55 return true; | |
| 56 } | |
| OLD | NEW |