Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: chrome/browser/plugin_prefs_factory.cc

Issue 9703038: Profiles: Really fix refcounted services. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Forgot to save a file. >_< Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/plugin_prefs_factory.h" 5 #include "chrome/browser/plugin_prefs_factory.h"
6 6
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "chrome/browser/plugin_prefs.h" 8 #include "chrome/browser/plugin_prefs.h"
9 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/profiles/profile_dependency_manager.h" 11 #include "chrome/browser/profiles/profile_dependency_manager.h"
12 #include "chrome/browser/profiles/profile_keyed_service.h" 12 #include "chrome/browser/profiles/profile_keyed_service.h"
13 #include "chrome/common/chrome_paths.h" 13 #include "chrome/common/chrome_paths.h"
14 #include "chrome/common/pref_names.h" 14 #include "chrome/common/pref_names.h"
15 15
16 // static 16 // static
17 PluginPrefsFactory* PluginPrefsFactory::GetInstance() { 17 PluginPrefsFactory* PluginPrefsFactory::GetInstance() {
18 return Singleton<PluginPrefsFactory>::get(); 18 return Singleton<PluginPrefsFactory>::get();
19 } 19 }
20 20
21 // static 21 // static
22 ProfileKeyedBase* PluginPrefsFactory::CreatePrefsForProfile( 22 scoped_refptr<PluginPrefs> PluginPrefsFactory::GetPrefsForProfile(
23 Profile* profile) { 23 Profile* profile) {
24 return GetInstance()->BuildServiceInstanceFor(profile); 24 return static_cast<PluginPrefs*>(
25 GetInstance()->GetServiceForProfile(profile, true).get());
25 } 26 }
26 27
27 PluginPrefs* PluginPrefsFactory::GetPrefsForProfile(Profile* profile) { 28 // static
28 return static_cast<PluginPrefs*>(GetBaseForProfile(profile, true)); 29 scoped_refptr<RefcountedProfileKeyedService>
30 PluginPrefsFactory::CreateForTestingProfile(Profile* profile) {
31 return static_cast<PluginPrefs*>(
32 GetInstance()->BuildServiceInstanceFor(profile).get());
29 } 33 }
30 34
31 PluginPrefsFactory::PluginPrefsFactory() 35 PluginPrefsFactory::PluginPrefsFactory()
32 : RefcountedProfileKeyedServiceFactory( 36 : RefcountedProfileKeyedServiceFactory(
33 "PluginPrefs", ProfileDependencyManager::GetInstance()) { 37 "PluginPrefs", ProfileDependencyManager::GetInstance()) {
34 } 38 }
35 39
36 PluginPrefsFactory::~PluginPrefsFactory() {} 40 PluginPrefsFactory::~PluginPrefsFactory() {}
37 41
38 RefcountedProfileKeyedService* PluginPrefsFactory::BuildServiceInstanceFor( 42 scoped_refptr<RefcountedProfileKeyedService>
39 Profile* profile) const { 43 PluginPrefsFactory::BuildServiceInstanceFor(Profile* profile) const {
40 PluginPrefs* plugin_prefs = new PluginPrefs(); 44 scoped_refptr<PluginPrefs> plugin_prefs(new PluginPrefs());
41 plugin_prefs->set_profile(profile->GetOriginalProfile()); 45 plugin_prefs->set_profile(profile->GetOriginalProfile());
42 plugin_prefs->SetPrefs(profile->GetPrefs()); 46 plugin_prefs->SetPrefs(profile->GetPrefs());
43 return plugin_prefs; 47 return plugin_prefs;
44 } 48 }
45 49
46 void PluginPrefsFactory::RegisterUserPrefs(PrefService* prefs) { 50 void PluginPrefsFactory::RegisterUserPrefs(PrefService* prefs) {
47 FilePath internal_dir; 51 FilePath internal_dir;
48 PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir); 52 PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir);
49 prefs->RegisterFilePathPref(prefs::kPluginsLastInternalDirectory, 53 prefs->RegisterFilePathPref(prefs::kPluginsLastInternalDirectory,
50 internal_dir, 54 internal_dir,
(...skipping 18 matching lines...) Expand all
69 return true; 73 return true;
70 } 74 }
71 75
72 bool PluginPrefsFactory::ServiceIsNULLWhileTesting() { 76 bool PluginPrefsFactory::ServiceIsNULLWhileTesting() {
73 return true; 77 return true;
74 } 78 }
75 79
76 bool PluginPrefsFactory::ServiceIsCreatedWithProfile() { 80 bool PluginPrefsFactory::ServiceIsCreatedWithProfile() {
77 return true; 81 return true;
78 } 82 }
OLDNEW
« no previous file with comments | « chrome/browser/plugin_prefs_factory.h ('k') | chrome/browser/printing/cloud_print/cloud_print_proxy_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698