summaryrefslogtreecommitdiffstats
path: root/chrome/browser/plugin_prefs_factory.cc
blob: f43d26157cc3e3072877308e146da103c5dd5b7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/plugin_prefs_factory.h"

#include "base/path_service.h"
#include "chrome/browser/plugin_prefs.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_dependency_manager.h"
#include "chrome/browser/profiles/profile_keyed_service.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/pref_names.h"

namespace {

}  // namespace

PluginPrefsWrapper::PluginPrefsWrapper(scoped_refptr<PluginPrefs> plugin_prefs)
    : plugin_prefs_(plugin_prefs) {
}

PluginPrefsWrapper::~PluginPrefsWrapper() {}

void PluginPrefsWrapper::Shutdown() {
  plugin_prefs_->ShutdownOnUIThread();
}

// static
PluginPrefsFactory* PluginPrefsFactory::GetInstance() {
  return Singleton<PluginPrefsFactory>::get();
}

PluginPrefsWrapper* PluginPrefsFactory::GetWrapperForProfile(
    Profile* profile) {
  return static_cast<PluginPrefsWrapper*>(GetServiceForProfile(profile, true));
}

// static
ProfileKeyedService* PluginPrefsFactory::CreateWrapperForProfile(
    Profile* profile) {
  return GetInstance()->BuildServiceInstanceFor(profile);
}

void PluginPrefsFactory::ForceRegisterPrefsForTest(PrefService* prefs) {
  RegisterUserPrefs(prefs);
}

PluginPrefsFactory::PluginPrefsFactory()
    : ProfileKeyedServiceFactory(ProfileDependencyManager::GetInstance()) {
}

PluginPrefsFactory::~PluginPrefsFactory() {}

ProfileKeyedService* PluginPrefsFactory::BuildServiceInstanceFor(
    Profile* profile) const {
  scoped_refptr<PluginPrefs> plugin_prefs(new PluginPrefs());
  plugin_prefs->set_profile(profile->GetOriginalProfile());
  plugin_prefs->SetPrefs(profile->GetPrefs());
  return new PluginPrefsWrapper(plugin_prefs);
}

void PluginPrefsFactory::RegisterUserPrefs(PrefService* prefs) {
  FilePath internal_dir;
  PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir);
  prefs->RegisterFilePathPref(prefs::kPluginsLastInternalDirectory,
                              internal_dir,
                              PrefService::UNSYNCABLE_PREF);
  prefs->RegisterBooleanPref(prefs::kPluginsEnabledInternalPDF,
                             false,
                             PrefService::UNSYNCABLE_PREF);
  prefs->RegisterBooleanPref(prefs::kPluginsEnabledNaCl,
                             false,
                             PrefService::UNSYNCABLE_PREF);
  prefs->RegisterListPref(prefs::kPluginsPluginsList,
                          PrefService::UNSYNCABLE_PREF);
  prefs->RegisterListPref(prefs::kPluginsDisabledPlugins,
                          PrefService::UNSYNCABLE_PREF);
  prefs->RegisterListPref(prefs::kPluginsDisabledPluginsExceptions,
                          PrefService::UNSYNCABLE_PREF);
  prefs->RegisterListPref(prefs::kPluginsEnabledPlugins,
                          PrefService::UNSYNCABLE_PREF);
}

bool PluginPrefsFactory::ServiceRedirectedInIncognito() {
  return true;
}

bool PluginPrefsFactory::ServiceIsNULLWhileTesting() {
  return true;
}

bool PluginPrefsFactory::ServiceIsCreatedWithProfile() {
  return true;
}