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

Side by Side Diff: chrome/browser/speech/chrome_speech_recognition_preferences.cc

Issue 15517005: Remove references to Profile from browser_context_keyed_service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase & style Created 7 years, 7 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/speech/chrome_speech_recognition_preferences.h" 5 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 17 matching lines...) Expand all
28 return Singleton<ChromeSpeechRecognitionPreferences::Factory>::get(); 28 return Singleton<ChromeSpeechRecognitionPreferences::Factory>::get();
29 } 29 }
30 30
31 void ChromeSpeechRecognitionPreferences::InitializeFactory() { 31 void ChromeSpeechRecognitionPreferences::InitializeFactory() {
32 ChromeSpeechRecognitionPreferences::Factory::GetInstance(); 32 ChromeSpeechRecognitionPreferences::Factory::GetInstance();
33 } 33 }
34 34
35 scoped_refptr<ChromeSpeechRecognitionPreferences> 35 scoped_refptr<ChromeSpeechRecognitionPreferences>
36 ChromeSpeechRecognitionPreferences::Factory::GetForProfile(Profile* profile) { 36 ChromeSpeechRecognitionPreferences::Factory::GetForProfile(Profile* profile) {
37 DCHECK(profile); 37 DCHECK(profile);
38 // GetServiceForProfile will let us instantiate a new (if not already cached 38 // GetServiceForBrowserContext will let us instantiate a new (if not already
39 // for the profile) Service through BuildServiceInstanceFor method. 39 // cached for the profile) Service through BuildServiceInstanceFor method.
40 ChromeSpeechRecognitionPreferences::Service* service = 40 ChromeSpeechRecognitionPreferences::Service* service =
41 static_cast<ChromeSpeechRecognitionPreferences::Service*>( 41 static_cast<ChromeSpeechRecognitionPreferences::Service*>(
42 GetServiceForProfile(profile, true)); 42 GetServiceForBrowserContext(profile, true));
43 43
44 if (!service) { 44 if (!service) {
45 // Incognito won't have this service. 45 // Incognito won't have this service.
46 return NULL; 46 return NULL;
47 } 47 }
48 48
49 return service->GetPreferences(); 49 return service->GetPreferences();
50 } 50 }
51 51
52 ChromeSpeechRecognitionPreferences::Factory::Factory() 52 ChromeSpeechRecognitionPreferences::Factory::Factory()
53 : ProfileKeyedServiceFactory( 53 : BrowserContextKeyedServiceFactory(
54 "ChromeSpeechRecognitionPreferences", 54 "ChromeSpeechRecognitionPreferences",
55 ProfileDependencyManager::GetInstance()) { 55 BrowserContextDependencyManager::GetInstance()) {
56 } 56 }
57 57
58 ChromeSpeechRecognitionPreferences::Factory::~Factory() { 58 ChromeSpeechRecognitionPreferences::Factory::~Factory() {
59 } 59 }
60 60
61 ProfileKeyedService* 61 BrowserContextKeyedService*
62 ChromeSpeechRecognitionPreferences::Factory::BuildServiceInstanceFor( 62 ChromeSpeechRecognitionPreferences::Factory::BuildServiceInstanceFor(
63 content::BrowserContext* profile) const { 63 content::BrowserContext* profile) const {
64 DCHECK(profile); 64 DCHECK(profile);
65 return new ChromeSpeechRecognitionPreferences::Service( 65 return new ChromeSpeechRecognitionPreferences::Service(
66 static_cast<Profile*>(profile)); 66 static_cast<Profile*>(profile));
67 } 67 }
68 68
69 void ChromeSpeechRecognitionPreferences::Factory::RegisterUserPrefs( 69 void ChromeSpeechRecognitionPreferences::Factory::RegisterUserPrefs(
70 user_prefs::PrefRegistrySyncable* prefs) { 70 user_prefs::PrefRegistrySyncable* prefs) {
71 prefs->RegisterBooleanPref( 71 prefs->RegisterBooleanPref(
72 prefs::kSpeechRecognitionFilterProfanities, 72 prefs::kSpeechRecognitionFilterProfanities,
73 kDefaultFilterProfanities, 73 kDefaultFilterProfanities,
74 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 74 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
75 75
76 prefs->RegisterListPref( 76 prefs->RegisterListPref(
77 prefs::kSpeechRecognitionTrayNotificationShownContexts, 77 prefs::kSpeechRecognitionTrayNotificationShownContexts,
78 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 78 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
79 } 79 }
80 80
81 bool ChromeSpeechRecognitionPreferences::Factory:: 81 bool ChromeSpeechRecognitionPreferences::Factory::
82 ServiceIsNULLWhileTesting() const { 82 ServiceIsNULLWhileTesting() const {
83 return true; 83 return true;
84 } 84 }
85 85
86 bool ChromeSpeechRecognitionPreferences::Factory:: 86 bool ChromeSpeechRecognitionPreferences::Factory::
87 ServiceIsCreatedWithProfile() const { 87 ServiceIsCreatedWithBrowserContext() const {
88 return false; 88 return false;
89 } 89 }
90 90
91 ChromeSpeechRecognitionPreferences::Service::Service( 91 ChromeSpeechRecognitionPreferences::Service::Service(
92 Profile* profile) 92 Profile* profile)
93 : preferences_(new ChromeSpeechRecognitionPreferences(profile)) { 93 : preferences_(new ChromeSpeechRecognitionPreferences(profile)) {
94 } 94 }
95 95
96 ChromeSpeechRecognitionPreferences::Service::~Service() { 96 ChromeSpeechRecognitionPreferences::Service::~Service() {
97 } 97 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 prefs::kSpeechRecognitionFilterProfanities); 210 prefs::kSpeechRecognitionFilterProfanities);
211 } 211 }
212 212
213 void ChromeSpeechRecognitionPreferences::ReloadNotificationsShown() { 213 void ChromeSpeechRecognitionPreferences::ReloadNotificationsShown() {
214 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 214 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
215 base::AutoLock write_lock(preferences_lock_); 215 base::AutoLock write_lock(preferences_lock_);
216 const base::ListValue* pref_list = profile_->GetPrefs()->GetList( 216 const base::ListValue* pref_list = profile_->GetPrefs()->GetList(
217 prefs::kSpeechRecognitionTrayNotificationShownContexts); 217 prefs::kSpeechRecognitionTrayNotificationShownContexts);
218 notifications_shown_.reset(pref_list->DeepCopy()); 218 notifications_shown_.reset(pref_list->DeepCopy());
219 } 219 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698