/chromium-webcl/src/chrome/browser/favicon/favicon_service_factory.cc

https://bitbucket.org/peixuan/chromium_r197479_base · C++ · 55 lines · 39 code · 9 blank · 7 comment · 4 complexity · 6cdc6fa86de975da4879ca934d94d98c MD5 · raw file

  1. // Copyright (c) 2012 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. #include "chrome/browser/favicon/favicon_service_factory.h"
  5. #include "base/memory/singleton.h"
  6. #include "base/prefs/pref_service.h"
  7. #include "chrome/browser/favicon/favicon_service.h"
  8. #include "chrome/browser/history/history_service.h"
  9. #include "chrome/browser/history/history_service_factory.h"
  10. #include "chrome/browser/profiles/profile_dependency_manager.h"
  11. #include "chrome/common/pref_names.h"
  12. // static
  13. FaviconService* FaviconServiceFactory::GetForProfile(
  14. Profile* profile, Profile::ServiceAccessType sat) {
  15. if (!profile->IsOffTheRecord()) {
  16. return static_cast<FaviconService*>(
  17. GetInstance()->GetServiceForProfile(profile, true));
  18. } else if (sat == Profile::EXPLICIT_ACCESS) {
  19. // Profile must be OffTheRecord in this case.
  20. return static_cast<FaviconService*>(
  21. GetInstance()->GetServiceForProfile(
  22. profile->GetOriginalProfile(), true));
  23. }
  24. // Profile is OffTheRecord without access.
  25. NOTREACHED() << "This profile is OffTheRecord";
  26. return NULL;
  27. }
  28. // static
  29. FaviconServiceFactory* FaviconServiceFactory::GetInstance() {
  30. return Singleton<FaviconServiceFactory>::get();
  31. }
  32. FaviconServiceFactory::FaviconServiceFactory()
  33. : ProfileKeyedServiceFactory("FaviconService",
  34. ProfileDependencyManager::GetInstance()) {
  35. DependsOn(HistoryServiceFactory::GetInstance());
  36. }
  37. FaviconServiceFactory::~FaviconServiceFactory() {}
  38. ProfileKeyedService* FaviconServiceFactory::BuildServiceInstanceFor(
  39. content::BrowserContext* profile) const {
  40. HistoryService* history_service = HistoryServiceFactory::GetForProfile(
  41. static_cast<Profile*>(profile), Profile::EXPLICIT_ACCESS);
  42. return new FaviconService(history_service);
  43. }
  44. bool FaviconServiceFactory::ServiceIsNULLWhileTesting() const {
  45. return true;
  46. }