OLD | NEW |
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/common/extensions/api/braille_display_private.h" | 10 #include "chrome/common/extensions/api/braille_display_private.h" |
11 #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" | 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 : public BrowserContextKeyedAPI, | 25 class BrailleDisplayPrivateAPI : public BrowserContextKeyedAPI, |
26 api::braille_display_private::BrailleObserver, | 26 api::braille_display_private::BrailleObserver, |
27 EventRouter::Observer { | 27 EventRouter::Observer { |
28 public: | 28 public: |
29 explicit BrailleDisplayPrivateAPI(content::BrowserContext* context); | 29 explicit BrailleDisplayPrivateAPI(content::BrowserContext* context); |
30 virtual ~BrailleDisplayPrivateAPI(); | 30 ~BrailleDisplayPrivateAPI() override; |
31 | 31 |
32 // ProfileKeyedService implementation. | 32 // ProfileKeyedService implementation. |
33 virtual void Shutdown() override; | 33 void Shutdown() override; |
34 | 34 |
35 // BrowserContextKeyedAPI implementation. | 35 // BrowserContextKeyedAPI implementation. |
36 static BrowserContextKeyedAPIFactory<BrailleDisplayPrivateAPI>* | 36 static BrowserContextKeyedAPIFactory<BrailleDisplayPrivateAPI>* |
37 GetFactoryInstance(); | 37 GetFactoryInstance(); |
38 | 38 |
39 // BrailleObserver implementation. | 39 // BrailleObserver implementation. |
40 virtual void OnBrailleDisplayStateChanged( | 40 void OnBrailleDisplayStateChanged( |
41 const api::braille_display_private::DisplayState& display_state) override; | 41 const api::braille_display_private::DisplayState& display_state) override; |
42 virtual void OnBrailleKeyEvent( | 42 void OnBrailleKeyEvent( |
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 void OnListenerAdded(const EventListenerInfo& details) override; |
47 virtual void OnListenerRemoved(const EventListenerInfo& details) override; | 47 void OnListenerRemoved(const EventListenerInfo& details) override; |
48 | |
49 | 48 |
50 private: | 49 private: |
51 friend class BrowserContextKeyedAPIFactory<BrailleDisplayPrivateAPI>; | 50 friend class BrowserContextKeyedAPIFactory<BrailleDisplayPrivateAPI>; |
52 friend class api::braille_display_private::BrailleDisplayPrivateAPIUserTest; | 51 friend class api::braille_display_private::BrailleDisplayPrivateAPIUserTest; |
53 | 52 |
54 class EventDelegate { | 53 class EventDelegate { |
55 public: | 54 public: |
56 virtual ~EventDelegate() {} | 55 virtual ~EventDelegate() {} |
57 virtual void BroadcastEvent(scoped_ptr<Event> event) = 0; | 56 virtual void BroadcastEvent(scoped_ptr<Event> event) = 0; |
58 virtual bool HasListener() = 0; | 57 virtual bool HasListener() = 0; |
(...skipping 19 matching lines...) Expand all Loading... |
78 // Override the default so the service is not created in tests. | 77 // Override the default so the service is not created in tests. |
79 static const bool kServiceIsNULLWhileTesting = true; | 78 static const bool kServiceIsNULLWhileTesting = true; |
80 }; | 79 }; |
81 | 80 |
82 namespace api { | 81 namespace api { |
83 | 82 |
84 class BrailleDisplayPrivateGetDisplayStateFunction : public AsyncApiFunction { | 83 class BrailleDisplayPrivateGetDisplayStateFunction : public AsyncApiFunction { |
85 DECLARE_EXTENSION_FUNCTION("brailleDisplayPrivate.getDisplayState", | 84 DECLARE_EXTENSION_FUNCTION("brailleDisplayPrivate.getDisplayState", |
86 BRAILLEDISPLAYPRIVATE_GETDISPLAYSTATE) | 85 BRAILLEDISPLAYPRIVATE_GETDISPLAYSTATE) |
87 protected: | 86 protected: |
88 virtual ~BrailleDisplayPrivateGetDisplayStateFunction() {} | 87 ~BrailleDisplayPrivateGetDisplayStateFunction() override {} |
89 virtual bool Prepare() override; | 88 bool Prepare() override; |
90 virtual void Work() override; | 89 void Work() override; |
91 virtual bool Respond() override; | 90 bool Respond() override; |
92 }; | 91 }; |
93 | 92 |
94 class BrailleDisplayPrivateWriteDotsFunction : public AsyncApiFunction { | 93 class BrailleDisplayPrivateWriteDotsFunction : public AsyncApiFunction { |
95 DECLARE_EXTENSION_FUNCTION("brailleDisplayPrivate.writeDots", | 94 DECLARE_EXTENSION_FUNCTION("brailleDisplayPrivate.writeDots", |
96 BRAILLEDISPLAYPRIVATE_WRITEDOTS); | 95 BRAILLEDISPLAYPRIVATE_WRITEDOTS); |
97 public: | 96 public: |
98 BrailleDisplayPrivateWriteDotsFunction(); | 97 BrailleDisplayPrivateWriteDotsFunction(); |
99 | 98 |
100 protected: | 99 protected: |
101 virtual ~BrailleDisplayPrivateWriteDotsFunction(); | 100 ~BrailleDisplayPrivateWriteDotsFunction() override; |
102 virtual bool Prepare() override; | 101 bool Prepare() override; |
103 virtual void Work() override; | 102 void Work() override; |
104 virtual bool Respond() override; | 103 bool Respond() override; |
105 | 104 |
106 private: | 105 private: |
107 scoped_ptr<braille_display_private::WriteDots::Params> params_; | 106 scoped_ptr<braille_display_private::WriteDots::Params> params_; |
108 }; | 107 }; |
109 | 108 |
110 } // namespace api | 109 } // namespace api |
111 } // namespace extensions | 110 } // namespace extensions |
112 | 111 |
113 #endif // CHROME_BROWSER_EXTENSIONS_API_BRAILLE_DISPLAY_PRIVATE_BRAILLE_DISPLAY
_PRIVATE_API_H_ | 112 #endif // CHROME_BROWSER_EXTENSIONS_API_BRAILLE_DISPLAY_PRIVATE_BRAILLE_DISPLAY
_PRIVATE_API_H_ |
OLD | NEW |