OLD | NEW |
| (Empty) |
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 | |
5 #include "chrome/browser/plugin_prefs_factory.h" | |
6 | |
7 #include "base/path_service.h" | |
8 #include "chrome/browser/plugin_prefs.h" | |
9 #include "chrome/browser/prefs/pref_service.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 | |
16 // static | |
17 PluginPrefsFactory* PluginPrefsFactory::GetInstance() { | |
18 return Singleton<PluginPrefsFactory>::get(); | |
19 } | |
20 | |
21 // static | |
22 scoped_refptr<PluginPrefs> PluginPrefsFactory::GetPrefsForProfile( | |
23 Profile* profile) { | |
24 return static_cast<PluginPrefs*>( | |
25 GetInstance()->GetServiceForProfile(profile, true).get()); | |
26 } | |
27 | |
28 // static | |
29 scoped_refptr<RefcountedProfileKeyedService> | |
30 PluginPrefsFactory::CreateForTestingProfile(Profile* profile) { | |
31 return static_cast<PluginPrefs*>( | |
32 GetInstance()->BuildServiceInstanceFor(profile).get()); | |
33 } | |
34 | |
35 PluginPrefsFactory::PluginPrefsFactory() | |
36 : RefcountedProfileKeyedServiceFactory( | |
37 "PluginPrefs", ProfileDependencyManager::GetInstance()) { | |
38 } | |
39 | |
40 PluginPrefsFactory::~PluginPrefsFactory() {} | |
41 | |
42 scoped_refptr<RefcountedProfileKeyedService> | |
43 PluginPrefsFactory::BuildServiceInstanceFor(Profile* profile) const { | |
44 scoped_refptr<PluginPrefs> plugin_prefs(new PluginPrefs()); | |
45 plugin_prefs->set_profile(profile->GetOriginalProfile()); | |
46 plugin_prefs->SetPrefs(profile->GetPrefs()); | |
47 return plugin_prefs; | |
48 } | |
49 | |
50 void PluginPrefsFactory::RegisterUserPrefs(PrefService* prefs) { | |
51 FilePath internal_dir; | |
52 PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir); | |
53 prefs->RegisterFilePathPref(prefs::kPluginsLastInternalDirectory, | |
54 internal_dir, | |
55 PrefService::UNSYNCABLE_PREF); | |
56 prefs->RegisterBooleanPref(prefs::kPluginsEnabledInternalPDF, | |
57 false, | |
58 PrefService::UNSYNCABLE_PREF); | |
59 prefs->RegisterBooleanPref(prefs::kPluginsEnabledNaCl, | |
60 false, | |
61 PrefService::UNSYNCABLE_PREF); | |
62 prefs->RegisterBooleanPref(prefs::kPluginsMigratedToPepperFlash, | |
63 false, | |
64 PrefService::UNSYNCABLE_PREF); | |
65 prefs->RegisterListPref(prefs::kPluginsPluginsList, | |
66 PrefService::UNSYNCABLE_PREF); | |
67 prefs->RegisterListPref(prefs::kPluginsDisabledPlugins, | |
68 PrefService::UNSYNCABLE_PREF); | |
69 prefs->RegisterListPref(prefs::kPluginsDisabledPluginsExceptions, | |
70 PrefService::UNSYNCABLE_PREF); | |
71 prefs->RegisterListPref(prefs::kPluginsEnabledPlugins, | |
72 PrefService::UNSYNCABLE_PREF); | |
73 } | |
74 | |
75 bool PluginPrefsFactory::ServiceRedirectedInIncognito() const { | |
76 return true; | |
77 } | |
78 | |
79 bool PluginPrefsFactory::ServiceIsNULLWhileTesting() const { | |
80 return true; | |
81 } | |
82 | |
83 bool PluginPrefsFactory::ServiceIsCreatedWithProfile() const { | |
84 return true; | |
85 } | |
OLD | NEW |