Chromium Code Reviews| Index: chrome/browser/favicon/fallback_icon_service_factory.cc |
| diff --git a/chrome/browser/favicon/fallback_icon_service_factory.cc b/chrome/browser/favicon/fallback_icon_service_factory.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..17c762c9c563ec664b9e941650ef2704ea649058 |
| --- /dev/null |
| +++ b/chrome/browser/favicon/fallback_icon_service_factory.cc |
| @@ -0,0 +1,56 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/favicon/fallback_icon_service_factory.h" |
| + |
| +#include "base/memory/singleton.h" |
| +#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.
|
| +#include "chrome/browser/favicon/chrome_fallback_icon_client_factory.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "components/favicon/core/fallback_icon_service.h" |
| +#include "components/keyed_service/content/browser_context_dependency_manager.h" |
| + |
| +// static |
| +FallbackIconService* FallbackIconServiceFactory::GetForProfile( |
| + Profile* profile, ServiceAccessType sat) { |
| + if (!profile->IsOffTheRecord()) { |
| + return static_cast<FallbackIconService*>( |
| + GetInstance()->GetServiceForBrowserContext(profile, true)); |
| + } else if (sat == ServiceAccessType::EXPLICIT_ACCESS) { |
| + // Profile must be OffTheRecord in this case. |
| + return static_cast<FallbackIconService*>( |
| + GetInstance()->GetServiceForBrowserContext( |
| + profile->GetOriginalProfile(), true)); |
| + } |
| + |
| + // Profile is OffTheRecord without access. |
| + NOTREACHED() << "This profile is OffTheRecord"; |
| + 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
|
| +} |
| + |
| +// static |
| +FallbackIconServiceFactory* FallbackIconServiceFactory::GetInstance() { |
| + return Singleton<FallbackIconServiceFactory>::get(); |
| +} |
| + |
| +FallbackIconServiceFactory::FallbackIconServiceFactory() |
| + : BrowserContextKeyedServiceFactory( |
| + "FallbackIconService", |
| + BrowserContextDependencyManager::GetInstance()) { |
| + DependsOn(ChromeFallbackIconClientFactory::GetInstance()); |
| +} |
| + |
| +FallbackIconServiceFactory::~FallbackIconServiceFactory() {} |
| + |
| +KeyedService* FallbackIconServiceFactory::BuildServiceInstanceFor( |
| + content::BrowserContext* profile) const { |
| + FallbackIconClient* fallback_icon_client = |
| + ChromeFallbackIconClientFactory::GetForProfile( |
| + static_cast<Profile*>(profile)); |
| + return new FallbackIconService(fallback_icon_client); |
| +} |
| + |
| +bool FallbackIconServiceFactory::ServiceIsNULLWhileTesting() const { |
| + return true; |
| +} |