No dual_mode on Win10+ shortcuts.
[chromium-blink-merge.git] / chrome / browser / plugins / plugin_prefs_factory.cc
blob4bba9ad3239fe013d365f521d061f35e012f5aae
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.
5 #include "chrome/browser/plugins/plugin_prefs_factory.h"
7 #include "base/path_service.h"
8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/plugins/plugin_prefs.h"
10 #include "chrome/browser/profiles/incognito_helpers.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/common/chrome_paths.h"
13 #include "chrome/common/pref_names.h"
14 #include "components/keyed_service/content/browser_context_dependency_manager.h"
15 #include "components/keyed_service/core/keyed_service.h"
16 #include "components/pref_registry/pref_registry_syncable.h"
18 // static
19 PluginPrefsFactory* PluginPrefsFactory::GetInstance() {
20 return Singleton<PluginPrefsFactory>::get();
23 // static
24 scoped_refptr<PluginPrefs> PluginPrefsFactory::GetPrefsForProfile(
25 Profile* profile) {
26 return static_cast<PluginPrefs*>(
27 GetInstance()->GetServiceForBrowserContext(profile, true).get());
30 // static
31 scoped_refptr<RefcountedKeyedService>
32 PluginPrefsFactory::CreateForTestingProfile(content::BrowserContext* profile) {
33 return static_cast<PluginPrefs*>(
34 GetInstance()->BuildServiceInstanceFor(profile).get());
37 PluginPrefsFactory::PluginPrefsFactory()
38 : RefcountedBrowserContextKeyedServiceFactory(
39 "PluginPrefs", BrowserContextDependencyManager::GetInstance()) {
42 PluginPrefsFactory::~PluginPrefsFactory() {}
44 scoped_refptr<RefcountedKeyedService>
45 PluginPrefsFactory::BuildServiceInstanceFor(
46 content::BrowserContext* context) const {
47 Profile* profile = static_cast<Profile*>(context);
48 scoped_refptr<PluginPrefs> plugin_prefs(new PluginPrefs());
49 plugin_prefs->set_profile(profile->GetOriginalProfile());
50 plugin_prefs->SetPrefs(profile->GetPrefs());
51 return plugin_prefs;
54 void PluginPrefsFactory::RegisterProfilePrefs(
55 user_prefs::PrefRegistrySyncable* registry) {
56 base::FilePath internal_dir;
57 PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir);
58 registry->RegisterFilePathPref(prefs::kPluginsLastInternalDirectory,
59 internal_dir);
60 registry->RegisterBooleanPref(prefs::kPluginsMigratedToPepperFlash, false);
61 registry->RegisterBooleanPref(
62 prefs::kPluginsRemovedOldComponentPepperFlashSettings, false);
63 registry->RegisterListPref(prefs::kPluginsPluginsList);
64 registry->RegisterListPref(prefs::kPluginsDisabledPlugins);
65 registry->RegisterListPref(prefs::kPluginsDisabledPluginsExceptions);
66 registry->RegisterListPref(prefs::kPluginsEnabledPlugins);
69 content::BrowserContext* PluginPrefsFactory::GetBrowserContextToUse(
70 content::BrowserContext* context) const {
71 return chrome::GetBrowserContextRedirectedInIncognito(context);
74 bool PluginPrefsFactory::ServiceIsNULLWhileTesting() const {
75 return true;
78 bool PluginPrefsFactory::ServiceIsCreatedWithBrowserContext() const {
79 return true;