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/profile.h"
11 #include "chrome/browser/profiles/profile_dependency_manager.h"
12 #include "chrome/browser/profiles/profile_keyed_service.h"
13 #include "chrome/common/chrome_paths.h"
14 #include "chrome/common/pref_names.h"
15 #include "components/user_prefs/pref_registry_syncable.h"
18 PluginPrefsFactory
* PluginPrefsFactory::GetInstance() {
19 return Singleton
<PluginPrefsFactory
>::get();
23 scoped_refptr
<PluginPrefs
> PluginPrefsFactory::GetPrefsForProfile(
25 return static_cast<PluginPrefs
*>(
26 GetInstance()->GetServiceForProfile(profile
, true).get());
30 scoped_refptr
<RefcountedProfileKeyedService
>
31 PluginPrefsFactory::CreateForTestingProfile(Profile
* profile
) {
32 return static_cast<PluginPrefs
*>(
33 GetInstance()->BuildServiceInstanceFor(profile
).get());
36 PluginPrefsFactory::PluginPrefsFactory()
37 : RefcountedProfileKeyedServiceFactory(
38 "PluginPrefs", ProfileDependencyManager::GetInstance()) {
41 PluginPrefsFactory::~PluginPrefsFactory() {}
43 scoped_refptr
<RefcountedProfileKeyedService
>
44 PluginPrefsFactory::BuildServiceInstanceFor(Profile
* profile
) const {
45 scoped_refptr
<PluginPrefs
> plugin_prefs(new PluginPrefs());
46 plugin_prefs
->set_profile(profile
->GetOriginalProfile());
47 plugin_prefs
->SetPrefs(profile
->GetPrefs());
51 void PluginPrefsFactory::RegisterUserPrefs(PrefRegistrySyncable
* registry
) {
52 base::FilePath internal_dir
;
53 PathService::Get(chrome::DIR_INTERNAL_PLUGINS
, &internal_dir
);
54 registry
->RegisterFilePathPref(prefs::kPluginsLastInternalDirectory
,
56 PrefRegistrySyncable::UNSYNCABLE_PREF
);
57 registry
->RegisterBooleanPref(prefs::kPluginsEnabledInternalPDF
,
59 PrefRegistrySyncable::UNSYNCABLE_PREF
);
60 registry
->RegisterBooleanPref(prefs::kPluginsEnabledNaCl
,
62 PrefRegistrySyncable::UNSYNCABLE_PREF
);
63 registry
->RegisterBooleanPref(prefs::kPluginsMigratedToPepperFlash
,
65 PrefRegistrySyncable::UNSYNCABLE_PREF
);
66 registry
->RegisterBooleanPref(
67 prefs::kPluginsRemovedOldComponentPepperFlashSettings
,
69 PrefRegistrySyncable::UNSYNCABLE_PREF
);
70 registry
->RegisterListPref(prefs::kPluginsPluginsList
,
71 PrefRegistrySyncable::UNSYNCABLE_PREF
);
72 registry
->RegisterListPref(prefs::kPluginsDisabledPlugins
,
73 PrefRegistrySyncable::UNSYNCABLE_PREF
);
74 registry
->RegisterListPref(prefs::kPluginsDisabledPluginsExceptions
,
75 PrefRegistrySyncable::UNSYNCABLE_PREF
);
76 registry
->RegisterListPref(prefs::kPluginsEnabledPlugins
,
77 PrefRegistrySyncable::UNSYNCABLE_PREF
);
80 bool PluginPrefsFactory::ServiceRedirectedInIncognito() const {
84 bool PluginPrefsFactory::ServiceIsNULLWhileTesting() const {
88 bool PluginPrefsFactory::ServiceIsCreatedWithProfile() const {