Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: chrome/browser/favicon/fallback_icon_service_factory.cc

Issue 996253002: [Fallback Icons] Refactor FallbackIconService to be a BrowserContext-level singleton (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup; moving defensive code into FallbackIconSource and LargeIconSource. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698