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

Side by Side Diff: chrome/browser/extensions/api/preference/chrome_direct_setting_api.h

Issue 166053003: Move ProfileKeyedAPI implementations to take BrowserContext in the constructor (part 2). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: | Created 6 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_EXTENSIONS_API_PREFERENCE_CHROME_DIRECT_SETTING_API_H__ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_CHROME_DIRECT_SETTING_API_H__
6 #define CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_CHROME_DIRECT_SETTING_API_H__ 6 #define CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_CHROME_DIRECT_SETTING_API_H__
7 7
8 #include "base/prefs/pref_change_registrar.h" 8 #include "base/prefs/pref_change_registrar.h"
9 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" 9 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
10 #include "extensions/browser/event_router.h" 10 #include "extensions/browser/event_router.h"
11 11
12 class Profile; 12 class Profile;
13 13
14 namespace content {
15 class BrowserContext;
16 }
17
14 namespace extensions { 18 namespace extensions {
15 namespace chromedirectsetting { 19 namespace chromedirectsetting {
16 20
17 class ChromeDirectSettingAPI : public ProfileKeyedAPI, 21 class ChromeDirectSettingAPI : public ProfileKeyedAPI,
18 public EventRouter::Observer { 22 public EventRouter::Observer {
19 public: 23 public:
20 explicit ChromeDirectSettingAPI(Profile* profile); 24 explicit ChromeDirectSettingAPI(content::BrowserContext* context);
21 25
22 virtual ~ChromeDirectSettingAPI(); 26 virtual ~ChromeDirectSettingAPI();
23 27
24 // BrowserContextKeyedService implementation. 28 // BrowserContextKeyedService implementation.
25 virtual void Shutdown() OVERRIDE; 29 virtual void Shutdown() OVERRIDE;
26 30
27 // ProfileKeyedAPI implementation. 31 // ProfileKeyedAPI implementation.
28 static ProfileKeyedAPIFactory<ChromeDirectSettingAPI>* GetFactoryInstance(); 32 static ProfileKeyedAPIFactory<ChromeDirectSettingAPI>* GetFactoryInstance();
29 33
30 // EventRouter::Observer implementation. 34 // EventRouter::Observer implementation.
31 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; 35 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE;
32 36
33 // Returns true if the preference is on the whitelist. 37 // Returns true if the preference is on the whitelist.
34 bool IsPreferenceOnWhitelist(const std::string& pref_key); 38 bool IsPreferenceOnWhitelist(const std::string& pref_key);
35 39
36 // Convenience method to get the ChromeDirectSettingAPI for a profile. 40 // Convenience method to get the ChromeDirectSettingAPI for a profile.
37 static ChromeDirectSettingAPI* Get(Profile* profile); 41 static ChromeDirectSettingAPI* Get(content::BrowserContext* context);
38 42
39 private: 43 private:
40 friend class ProfileKeyedAPIFactory<ChromeDirectSettingAPI>; 44 friend class ProfileKeyedAPIFactory<ChromeDirectSettingAPI>;
41 45
42 // ProfileKeyedAPI implementation. 46 // ProfileKeyedAPI implementation.
43 static const char* service_name(); 47 static const char* service_name();
44 48
45 void OnPrefChanged(PrefService* pref_service, const std::string& pref_key); 49 void OnPrefChanged(PrefService* pref_service, const std::string& pref_key);
46 50
47 static const bool kServiceIsNULLWhileTesting = true; 51 static const bool kServiceIsNULLWhileTesting = true;
48 static const bool kServiceRedirectedInIncognito = false; 52 static const bool kServiceRedirectedInIncognito = false;
49 53
50 PrefChangeRegistrar registrar_; 54 PrefChangeRegistrar registrar_;
51 Profile* profile_; 55 Profile* profile_;
52 56
53 DISALLOW_COPY_AND_ASSIGN(ChromeDirectSettingAPI); 57 DISALLOW_COPY_AND_ASSIGN(ChromeDirectSettingAPI);
54 }; 58 };
55 59
56 } // namespace chromedirectsetting 60 } // namespace chromedirectsetting
57 } // namespace extensions 61 } // namespace extensions
58 62
59 #endif // CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_CHROME_DIRECT_SETTING_API_H_ _ 63 #endif // CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_CHROME_DIRECT_SETTING_API_H_ _
60
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698