font_pref_change_notifier_factory.cc 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright 2017 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/font_pref_change_notifier_factory.h"
  5. #include "chrome/browser/font_pref_change_notifier.h"
  6. #include "chrome/browser/profiles/incognito_helpers.h"
  7. #include "chrome/browser/profiles/profile.h"
  8. #include "components/keyed_service/content/browser_context_dependency_manager.h"
  9. FontPrefChangeNotifierFactory::FontPrefChangeNotifierFactory()
  10. : BrowserContextKeyedServiceFactory(
  11. "FontPrefChangeNotifier",
  12. BrowserContextDependencyManager::GetInstance()) {}
  13. FontPrefChangeNotifierFactory::~FontPrefChangeNotifierFactory() = default;
  14. // static
  15. FontPrefChangeNotifier* FontPrefChangeNotifierFactory::GetForProfile(
  16. Profile* profile) {
  17. return static_cast<FontPrefChangeNotifier*>(
  18. GetInstance()->GetServiceForBrowserContext(profile, true));
  19. }
  20. // static
  21. FontPrefChangeNotifierFactory* FontPrefChangeNotifierFactory::GetInstance() {
  22. return base::Singleton<FontPrefChangeNotifierFactory>::get();
  23. }
  24. KeyedService* FontPrefChangeNotifierFactory::BuildServiceInstanceFor(
  25. content::BrowserContext* context) const {
  26. return new FontPrefChangeNotifier(
  27. Profile::FromBrowserContext(context)->GetPrefs());
  28. }
  29. content::BrowserContext* FontPrefChangeNotifierFactory::GetBrowserContextToUse(
  30. content::BrowserContext* context) const {
  31. return chrome::GetBrowserContextRedirectedInIncognito(context);
  32. }