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

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: 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: BrowserContextKeyedServiceFact ory".
56 56
57 // Singleton that manages instantiation of ChromeSpeechRecognitionPreferences 57 // Singleton that manages instantiation of ChromeSpeechRecognitionPreferences
58 // handling its association with Profiles. 58 // handling its association with Profiles.
59 class Factory : public ProfileKeyedServiceFactory { 59 class Factory : public BrowserContextKeyedServiceFactory {
60 public: 60 public:
61 static Factory* GetInstance(); 61 static Factory* GetInstance();
62 scoped_refptr<ChromeSpeechRecognitionPreferences> GetForProfile( 62 scoped_refptr<ChromeSpeechRecognitionPreferences> GetForProfile(
63 Profile* profile); 63 Profile* profile);
64 64
65 private: 65 private:
66 friend struct DefaultSingletonTraits<Factory>; 66 friend struct DefaultSingletonTraits<Factory>;
67 67
68 Factory(); 68 Factory();
69 virtual ~Factory(); 69 virtual ~Factory();
70 70
71 // ProfileKeyedServiceFactory methods: 71 // BrowserContextKeyedServiceFactory methods:
72 virtual ProfileKeyedService* BuildServiceInstanceFor( 72 virtual BrowserContextKeyedService* BuildServiceInstanceFor(
73 content::BrowserContext* profile) const OVERRIDE; 73 content::BrowserContext* profile) const OVERRIDE;
74 virtual void RegisterUserPrefs( 74 virtual void RegisterUserPrefs(
75 user_prefs::PrefRegistrySyncable* registry) OVERRIDE; 75 user_prefs::PrefRegistrySyncable* registry) OVERRIDE;
76 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE; 76 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE;
77 virtual bool ServiceIsCreatedWithProfile() const OVERRIDE; 77 virtual bool ServiceIsCreatedWithBrowserContext() const OVERRIDE;
78 78
79 DISALLOW_COPY_AND_ASSIGN(Factory); 79 DISALLOW_COPY_AND_ASSIGN(Factory);
80 }; 80 };
81 81
82 // This wrapper handles the binding between ChromeSpeechRecognitionPreferences 82 // This wrapper handles the binding between ChromeSpeechRecognitionPreferences
83 // instances (which can have a longer lifetime, since they are refcounted) and 83 // instances (which can have a longer lifetime, since they are refcounted) and
84 // ProfileKeyedService (which lifetime depends on the Profile service). Upon 84 // BrowserContextKeyedService (which lifetime depends on the Profile service). Upon
85 // profile shutdown, the ChromeSpeechRecognitionPreferences instance is 85 // profile shutdown, the ChromeSpeechRecognitionPreferences instance is
86 // detached from profile, meaning that after that point its clients can still 86 // 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. 87 // use it, but preferences will no longer be kept in sync with the profile.
88 class Service : public ProfileKeyedService { 88 class Service : public BrowserContextKeyedService {
89 public: 89 public:
90 explicit Service(Profile* profile); 90 explicit Service(Profile* profile);
91 virtual ~Service(); 91 virtual ~Service();
92 92
93 // ProfileKeyedService implementation. 93 // BrowserContextKeyedService implementation.
94 virtual void Shutdown() OVERRIDE; 94 virtual void Shutdown() OVERRIDE;
95 95
96 scoped_refptr<ChromeSpeechRecognitionPreferences> GetPreferences() const; 96 scoped_refptr<ChromeSpeechRecognitionPreferences> GetPreferences() const;
97 97
98 private: 98 private:
99 scoped_refptr<ChromeSpeechRecognitionPreferences> preferences_; 99 scoped_refptr<ChromeSpeechRecognitionPreferences> preferences_;
100 100
101 DISALLOW_COPY_AND_ASSIGN(Service); 101 DISALLOW_COPY_AND_ASSIGN(Service);
102 }; 102 };
103 103
(...skipping 10 matching lines...) Expand all
114 scoped_ptr<base::ListValue> notifications_shown_; 114 scoped_ptr<base::ListValue> notifications_shown_;
115 115
116 // Lock used to ensure exclusive access to preference variables that are 116 // Lock used to ensure exclusive access to preference variables that are
117 // accessed by both threads (note: mutable is required to keep getters const). 117 // accessed by both threads (note: mutable is required to keep getters const).
118 mutable base::Lock preferences_lock_; 118 mutable base::Lock preferences_lock_;
119 119
120 DISALLOW_COPY_AND_ASSIGN(ChromeSpeechRecognitionPreferences); 120 DISALLOW_COPY_AND_ASSIGN(ChromeSpeechRecognitionPreferences);
121 }; 121 };
122 122
123 #endif // CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_PREFERENCES_H_ 123 #endif // CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_PREFERENCES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698