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/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. | |
beaudoin
2015/03/26 12:53:55
Not sure I like the phrasing, I'd go with:
// Prof
huangs
2015/03/26 18:26:06
The file is branched from favicon_service_factory.
| |
22 return static_cast<FallbackIconService*>( | |
23 GetInstance()->GetServiceForBrowserContext( | |
24 profile->GetOriginalProfile(), true)); | |
25 } | |
26 | |
27 // Profile is OffTheRecord without access. | |
beaudoin
2015/03/26 12:53:55
Explain in the comment why this should never happe
huangs
2015/03/26 18:26:06
Will continue discussion once I uploaded with lowe
| |
28 NOTREACHED() << "This profile is OffTheRecord"; | |
29 return nullptr; | |
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 |