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

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

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 #ifndef CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_PREFERENCES_H_ 5 #ifndef CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_PREFERENCES_H_
6 #define CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_PREFERENCES_H_ 6 #define CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_PREFERENCES_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 // Called only by Chrome (on UI thread). 46 // Called only by Chrome (on UI thread).
47 void SetFilterProfanities(bool filter_profanities); 47 void SetFilterProfanities(bool filter_profanities);
48 void ToggleFilterProfanities(); 48 void ToggleFilterProfanities();
49 bool ShouldShowSecurityNotification(const std::string& context_name) const; 49 bool ShouldShowSecurityNotification(const std::string& context_name) const;
50 void SetHasShownSecurityNotification(const std::string& context_name); 50 void SetHasShownSecurityNotification(const std::string& context_name);
51 51
52 private: 52 private:
53 // The two classes below are needed to handle storage of speech recognition 53 // The two classes below are needed to handle storage of speech recognition
54 // preferences in profile preferences, according to the Chromium Profile 54 // preferences in profile preferences, according to the Chromium Profile
55 // Architecture document entitled "The New Way: ProfileKeyedServiceFactory". 55 // Architecture document entitled "The New Way:
56 // BrowserContextKeyedServiceFactory".
56 57
57 // Singleton that manages instantiation of ChromeSpeechRecognitionPreferences 58 // Singleton that manages instantiation of ChromeSpeechRecognitionPreferences
58 // handling its association with Profiles. 59 // handling its association with Profiles.
59 class Factory : public ProfileKeyedServiceFactory { 60 class Factory : public BrowserContextKeyedServiceFactory {
60 public: 61 public:
61 static Factory* GetInstance(); 62 static Factory* GetInstance();
62 scoped_refptr<ChromeSpeechRecognitionPreferences> GetForProfile( 63 scoped_refptr<ChromeSpeechRecognitionPreferences> GetForProfile(
63 Profile* profile); 64 Profile* profile);
64 65
65 private: 66 private:
66 friend struct DefaultSingletonTraits<Factory>; 67 friend struct DefaultSingletonTraits<Factory>;
67 68
68 Factory(); 69 Factory();
69 virtual ~Factory(); 70 virtual ~Factory();
70 71
71 // ProfileKeyedServiceFactory methods: 72 // BrowserContextKeyedServiceFactory methods:
72 virtual ProfileKeyedService* BuildServiceInstanceFor( 73 virtual BrowserContextKeyedService* BuildServiceInstanceFor(
73 content::BrowserContext* profile) const OVERRIDE; 74 content::BrowserContext* profile) const OVERRIDE;
74 virtual void RegisterUserPrefs( 75 virtual void RegisterUserPrefs(
75 user_prefs::PrefRegistrySyncable* registry) OVERRIDE; 76 user_prefs::PrefRegistrySyncable* registry) OVERRIDE;
76 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE; 77 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE;
77 virtual bool ServiceIsCreatedWithProfile() const OVERRIDE; 78 virtual bool ServiceIsCreatedWithBrowserContext() const OVERRIDE;
78 79
79 DISALLOW_COPY_AND_ASSIGN(Factory); 80 DISALLOW_COPY_AND_ASSIGN(Factory);
80 }; 81 };
81 82
82 // This wrapper handles the binding between ChromeSpeechRecognitionPreferences 83 // This wrapper handles the binding between ChromeSpeechRecognitionPreferences
83 // instances (which can have a longer lifetime, since they are refcounted) and 84 // instances (which can have a longer lifetime, since they are refcounted) and
84 // ProfileKeyedService (which lifetime depends on the Profile service). Upon 85 // BrowserContextKeyedService (which lifetime depends on the Profile service).
85 // profile shutdown, the ChromeSpeechRecognitionPreferences instance is 86 // Upon profile shutdown, the ChromeSpeechRecognitionPreferences instance is
86 // detached from profile, meaning that after that point its clients can still 87 // detached from profile, meaning that after that point its clients can still
87 // use it, but preferences will no longer be kept in sync with the profile. 88 // use it, but preferences will no longer be kept in sync with the profile.
88 class Service : public ProfileKeyedService { 89 class Service : public BrowserContextKeyedService {
89 public: 90 public:
90 explicit Service(Profile* profile); 91 explicit Service(Profile* profile);
91 virtual ~Service(); 92 virtual ~Service();
92 93
93 // ProfileKeyedService implementation. 94 // BrowserContextKeyedService implementation.
94 virtual void Shutdown() OVERRIDE; 95 virtual void Shutdown() OVERRIDE;
95 96
96 scoped_refptr<ChromeSpeechRecognitionPreferences> GetPreferences() const; 97 scoped_refptr<ChromeSpeechRecognitionPreferences> GetPreferences() const;
97 98
98 private: 99 private:
99 scoped_refptr<ChromeSpeechRecognitionPreferences> preferences_; 100 scoped_refptr<ChromeSpeechRecognitionPreferences> preferences_;
100 101
101 DISALLOW_COPY_AND_ASSIGN(Service); 102 DISALLOW_COPY_AND_ASSIGN(Service);
102 }; 103 };
103 104
(...skipping 10 matching lines...) Expand all
114 scoped_ptr<base::ListValue> notifications_shown_; 115 scoped_ptr<base::ListValue> notifications_shown_;
115 116
116 // Lock used to ensure exclusive access to preference variables that are 117 // Lock used to ensure exclusive access to preference variables that are
117 // accessed by both threads (note: mutable is required to keep getters const). 118 // accessed by both threads (note: mutable is required to keep getters const).
118 mutable base::Lock preferences_lock_; 119 mutable base::Lock preferences_lock_;
119 120
120 DISALLOW_COPY_AND_ASSIGN(ChromeSpeechRecognitionPreferences); 121 DISALLOW_COPY_AND_ASSIGN(ChromeSpeechRecognitionPreferences);
121 }; 122 };
122 123
123 #endif // CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_PREFERENCES_H_ 124 #endif // CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_PREFERENCES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698