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

Side by Side Diff: chrome/browser/extensions/api/braille_display_private/braille_display_private_api.h

Issue 178193030: Rename ProfileKeyedAPI to BrowserContextKeyedAPI and GetProfile to Get. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 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_BRAILLE_DISPLAY_PRIVATE_BRAILLE_DISPLAY_PR IVATE_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_BRAILLE_DISPLAY_PRIVATE_BRAILLE_DISPLAY_PR IVATE_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_BRAILLE_DISPLAY_PRIVATE_BRAILLE_DISPLAY_PR IVATE_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_BRAILLE_DISPLAY_PRIVATE_BRAILLE_DISPLAY_PR IVATE_API_H_
7 7
8 #include "base/scoped_observer.h" 8 #include "base/scoped_observer.h"
9 #include "chrome/browser/extensions/api/braille_display_private/braille_controll er.h" 9 #include "chrome/browser/extensions/api/braille_display_private/braille_controll er.h"
10 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
11 #include "chrome/common/extensions/api/braille_display_private.h" 10 #include "chrome/common/extensions/api/braille_display_private.h"
12 #include "extensions/browser/api/async_api_function.h" 11 #include "extensions/browser/api/async_api_function.h"
12 #include "extensions/browser/browser_context_keyed_api_factory.h"
13 #include "extensions/browser/event_router.h" 13 #include "extensions/browser/event_router.h"
14 14
15 class Profile; 15 class Profile;
16 16
17 namespace extensions { 17 namespace extensions {
18 namespace api { 18 namespace api {
19 namespace braille_display_private { 19 namespace braille_display_private {
20 class BrailleDisplayPrivateAPIUserTest; 20 class BrailleDisplayPrivateAPIUserTest;
21 } // namespace braille_display_private 21 } // namespace braille_display_private
22 } // namespace api 22 } // namespace api
23 23
24 // Implementation of the chrome.brailleDisplayPrivate API. 24 // Implementation of the chrome.brailleDisplayPrivate API.
25 class BrailleDisplayPrivateAPI 25 class BrailleDisplayPrivateAPI : public BrowserContextKeyedAPI,
26 : public ProfileKeyedAPI, 26 api::braille_display_private::BrailleObserver,
27 api::braille_display_private::BrailleObserver, 27 EventRouter::Observer {
28 EventRouter::Observer {
29 public: 28 public:
30 explicit BrailleDisplayPrivateAPI(content::BrowserContext* context); 29 explicit BrailleDisplayPrivateAPI(content::BrowserContext* context);
31 virtual ~BrailleDisplayPrivateAPI(); 30 virtual ~BrailleDisplayPrivateAPI();
32 31
33 // ProfileKeyedService implementation. 32 // ProfileKeyedService implementation.
34 virtual void Shutdown() OVERRIDE; 33 virtual void Shutdown() OVERRIDE;
35 34
36 // ProfileKeyedAPI implementation. 35 // BrowserContextKeyedAPI implementation.
37 static ProfileKeyedAPIFactory<BrailleDisplayPrivateAPI>* GetFactoryInstance(); 36 static BrowserContextKeyedAPIFactory<BrailleDisplayPrivateAPI>*
37 GetFactoryInstance();
38 38
39 // BrailleObserver implementation. 39 // BrailleObserver implementation.
40 virtual void OnDisplayStateChanged( 40 virtual void OnDisplayStateChanged(
41 const api::braille_display_private::DisplayState& display_state) OVERRIDE; 41 const api::braille_display_private::DisplayState& display_state) OVERRIDE;
42 virtual void OnKeyEvent( 42 virtual void OnKeyEvent(
43 const api::braille_display_private::KeyEvent& keyEvent) OVERRIDE; 43 const api::braille_display_private::KeyEvent& keyEvent) OVERRIDE;
44 44
45 // EventRouter::Observer implementation. 45 // EventRouter::Observer implementation.
46 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; 46 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE;
47 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE; 47 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE;
48 48
49 49
50 private: 50 private:
51 friend class ProfileKeyedAPIFactory<BrailleDisplayPrivateAPI>; 51 friend class BrowserContextKeyedAPIFactory<BrailleDisplayPrivateAPI>;
52 friend class api::braille_display_private::BrailleDisplayPrivateAPIUserTest; 52 friend class api::braille_display_private::BrailleDisplayPrivateAPIUserTest;
53 53
54 class EventDelegate { 54 class EventDelegate {
55 public: 55 public:
56 virtual ~EventDelegate() {} 56 virtual ~EventDelegate() {}
57 virtual void BroadcastEvent(scoped_ptr<Event> event) = 0; 57 virtual void BroadcastEvent(scoped_ptr<Event> event) = 0;
58 virtual bool HasListener() = 0; 58 virtual bool HasListener() = 0;
59 }; 59 };
60 60
61 class DefaultEventDelegate; 61 class DefaultEventDelegate;
62 62
63 // Returns whether the profile that this API was created for is currently 63 // Returns whether the profile that this API was created for is currently
64 // the active profile. 64 // the active profile.
65 bool IsProfileActive(); 65 bool IsProfileActive();
66 66
67 void SetEventDelegateForTest(scoped_ptr<EventDelegate> delegate); 67 void SetEventDelegateForTest(scoped_ptr<EventDelegate> delegate);
68 68
69 Profile* profile_; 69 Profile* profile_;
70 ScopedObserver<api::braille_display_private::BrailleController, 70 ScopedObserver<api::braille_display_private::BrailleController,
71 BrailleObserver> scoped_observer_; 71 BrailleObserver> scoped_observer_;
72 scoped_ptr<EventDelegate> event_delegate_; 72 scoped_ptr<EventDelegate> event_delegate_;
73 73
74 // ProfileKeyedAPI implementation. 74 // BrowserContextKeyedAPI implementation.
75 static const char* service_name() { 75 static const char* service_name() {
76 return "BrailleDisplayPrivateAPI"; 76 return "BrailleDisplayPrivateAPI";
77 } 77 }
78 // Override the default so the service is not created in tests. 78 // Override the default so the service is not created in tests.
79 static const bool kServiceIsNULLWhileTesting = true; 79 static const bool kServiceIsNULLWhileTesting = true;
80 }; 80 };
81 81
82 namespace api { 82 namespace api {
83 83
84 class BrailleDisplayPrivateGetDisplayStateFunction : public AsyncApiFunction { 84 class BrailleDisplayPrivateGetDisplayStateFunction : public AsyncApiFunction {
(...skipping 19 matching lines...) Expand all
104 virtual bool Respond() OVERRIDE; 104 virtual bool Respond() OVERRIDE;
105 105
106 private: 106 private:
107 scoped_ptr<braille_display_private::WriteDots::Params> params_; 107 scoped_ptr<braille_display_private::WriteDots::Params> params_;
108 }; 108 };
109 109
110 } // namespace api 110 } // namespace api
111 } // namespace extensions 111 } // namespace extensions
112 112
113 #endif // CHROME_BROWSER_EXTENSIONS_API_BRAILLE_DISPLAY_PRIVATE_BRAILLE_DISPLAY _PRIVATE_API_H_ 113 #endif // CHROME_BROWSER_EXTENSIONS_API_BRAILLE_DISPLAY_PRIVATE_BRAILLE_DISPLAY _PRIVATE_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698