Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / extensions / api / hotword_private / hotword_private_api.h
blobbf2d0a8678a64b7e7a7f7569292c3b30bce0d2c1
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_HOTWORD_PRIVATE_HOTWORD_PRIVATE_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_HOTWORD_PRIVATE_HOTWORD_PRIVATE_API_H_
8 #include "base/prefs/pref_change_registrar.h"
9 #include "base/values.h"
10 #include "chrome/browser/extensions/chrome_extension_function.h"
11 #include "chrome/common/extensions/api/hotword_private.h"
12 #include "extensions/browser/browser_context_keyed_api_factory.h"
13 #include "extensions/browser/extension_event_histogram_value.h"
15 class Profile;
17 namespace extensions {
19 // Listens for changes in disable/enabled state and forwards as an extension
20 // event.
21 class HotwordPrivateEventService : public BrowserContextKeyedAPI {
22 public:
23 explicit HotwordPrivateEventService(content::BrowserContext* context);
24 ~HotwordPrivateEventService() override;
26 // BrowserContextKeyedAPI implementation.
27 void Shutdown() override;
28 static BrowserContextKeyedAPIFactory<HotwordPrivateEventService>*
29 GetFactoryInstance();
30 static const char* service_name();
32 void OnEnabledChanged(const std::string& pref_name);
34 void OnHotwordSessionRequested();
36 void OnHotwordSessionStopped();
38 void OnHotwordTriggered();
40 void OnFinalizeSpeakerModel();
42 void OnSpeakerModelSaved();
44 void OnDeleteSpeakerModel();
46 void OnSpeakerModelExists();
48 void OnMicrophoneStateChanged(bool enabled);
50 private:
51 friend class BrowserContextKeyedAPIFactory<HotwordPrivateEventService>;
53 void SignalEvent(events::HistogramValue histogram_value,
54 const std::string& event_name);
55 void SignalEvent(events::HistogramValue histogram_value,
56 const std::string& event_name,
57 scoped_ptr<base::ListValue> args);
59 Profile* profile_;
60 PrefChangeRegistrar pref_change_registrar_;
64 class HotwordPrivateSetEnabledFunction : public ChromeSyncExtensionFunction {
65 public:
66 DECLARE_EXTENSION_FUNCTION("hotwordPrivate.setEnabled",
67 HOTWORDPRIVATE_SETENABLED)
69 protected:
70 ~HotwordPrivateSetEnabledFunction() override {}
72 // ExtensionFunction:
73 bool RunSync() override;
76 class HotwordPrivateSetAudioLoggingEnabledFunction
77 : public ChromeSyncExtensionFunction {
78 public:
79 DECLARE_EXTENSION_FUNCTION("hotwordPrivate.setAudioLoggingEnabled",
80 HOTWORDPRIVATE_SETAUDIOLOGGINGENABLED)
82 protected:
83 ~HotwordPrivateSetAudioLoggingEnabledFunction() override {}
85 // ExtensionFunction:
86 bool RunSync() override;
89 class HotwordPrivateSetHotwordAlwaysOnSearchEnabledFunction
90 : public ChromeSyncExtensionFunction {
91 public:
92 DECLARE_EXTENSION_FUNCTION("hotwordPrivate.setHotwordAlwaysOnSearchEnabled",
93 HOTWORDPRIVATE_SETHOTWORDALWAYSONSEARCHENABLED)
95 protected:
96 ~HotwordPrivateSetHotwordAlwaysOnSearchEnabledFunction() override {}
98 // ExtensionFunction:
99 bool RunSync() override;
102 class HotwordPrivateGetStatusFunction : public ChromeSyncExtensionFunction {
103 public:
104 DECLARE_EXTENSION_FUNCTION("hotwordPrivate.getStatus",
105 HOTWORDPRIVATE_GETSTATUS)
107 protected:
108 ~HotwordPrivateGetStatusFunction() override {}
110 // ExtensionFunction:
111 bool RunSync() override;
114 class HotwordPrivateSetHotwordSessionStateFunction
115 : public ChromeSyncExtensionFunction {
116 public:
117 DECLARE_EXTENSION_FUNCTION("hotwordPrivate.setHotwordSessionState",
118 HOTWORDPRIVATE_SETHOTWORDSESSIONSTATE);
120 protected:
121 ~HotwordPrivateSetHotwordSessionStateFunction() override {}
123 // ExtensionFunction:
124 bool RunSync() override;
127 class HotwordPrivateNotifyHotwordRecognitionFunction
128 : public ChromeSyncExtensionFunction {
129 public:
130 DECLARE_EXTENSION_FUNCTION("hotwordPrivate.notifyHotwordRecognition",
131 HOTWORDPRIVATE_NOTIFYHOTWORDRECOGNITION);
133 protected:
134 ~HotwordPrivateNotifyHotwordRecognitionFunction() override {}
136 // ExtensionFunction:
137 bool RunSync() override;
140 class HotwordPrivateGetLaunchStateFunction :
141 public ChromeSyncExtensionFunction {
142 public:
143 DECLARE_EXTENSION_FUNCTION("hotwordPrivate.getLaunchState",
144 HOTWORDPRIVATE_GETLAUNCHSTATE)
146 protected:
147 ~HotwordPrivateGetLaunchStateFunction() override {}
149 // ExtensionFunction:
150 bool RunSync() override;
153 class HotwordPrivateStartTrainingFunction :
154 public ChromeSyncExtensionFunction {
155 public:
156 DECLARE_EXTENSION_FUNCTION("hotwordPrivate.startTraining",
157 HOTWORDPRIVATE_STARTTRAINING)
159 protected:
160 ~HotwordPrivateStartTrainingFunction() override {}
162 // ExtensionFunction:
163 bool RunSync() override;
166 class HotwordPrivateFinalizeSpeakerModelFunction :
167 public ChromeSyncExtensionFunction {
168 public:
169 DECLARE_EXTENSION_FUNCTION("hotwordPrivate.finalizeSpeakerModel",
170 HOTWORDPRIVATE_FINALIZESPEAKERMODEL)
172 protected:
173 ~HotwordPrivateFinalizeSpeakerModelFunction() override {}
175 // ExtensionFunction:
176 bool RunSync() override;
179 class HotwordPrivateNotifySpeakerModelSavedFunction :
180 public ChromeSyncExtensionFunction {
181 public:
182 DECLARE_EXTENSION_FUNCTION("hotwordPrivate.notifySpeakerModelSaved",
183 HOTWORDPRIVATE_NOTIFYSPEAKERMODELSAVED)
185 protected:
186 ~HotwordPrivateNotifySpeakerModelSavedFunction() override {}
188 // ExtensionFunction:
189 bool RunSync() override;
192 class HotwordPrivateStopTrainingFunction :
193 public ChromeSyncExtensionFunction {
194 public:
195 DECLARE_EXTENSION_FUNCTION("hotwordPrivate.stopTraining",
196 HOTWORDPRIVATE_STOPTRAINING)
198 protected:
199 ~HotwordPrivateStopTrainingFunction() override {}
201 // ExtensionFunction:
202 bool RunSync() override;
205 class HotwordPrivateGetLocalizedStringsFunction
206 : public ChromeSyncExtensionFunction {
207 public:
208 DECLARE_EXTENSION_FUNCTION("hotwordPrivate.getLocalizedStrings",
209 HOTWORDPRIVATE_GETLOCALIZEDSTRINGS)
211 protected:
212 ~HotwordPrivateGetLocalizedStringsFunction() override {}
214 // ExtensionFunction:
215 bool RunSync() override;
218 class HotwordPrivateSetAudioHistoryEnabledFunction
219 : public ChromeAsyncExtensionFunction {
220 public:
221 DECLARE_EXTENSION_FUNCTION("hotwordPrivate.setAudioHistoryEnabled",
222 HOTWORDPRIVATE_SETAUDIOHISTORYENABLED)
224 protected:
225 ~HotwordPrivateSetAudioHistoryEnabledFunction() override {}
227 // ExtensionFunction:
228 bool RunAsync() override;
230 void SetResultAndSendResponse(bool success, bool new_enabled_value);
233 class HotwordPrivateGetAudioHistoryEnabledFunction
234 : public ChromeAsyncExtensionFunction {
235 public:
236 DECLARE_EXTENSION_FUNCTION("hotwordPrivate.getAudioHistoryEnabled",
237 HOTWORDPRIVATE_GETAUDIOHISTORYENABLED)
239 protected:
240 ~HotwordPrivateGetAudioHistoryEnabledFunction() override {}
242 // ExtensionFunction:
243 bool RunAsync() override;
245 void SetResultAndSendResponse(bool success, bool new_enabled_value);
248 class HotwordPrivateSpeakerModelExistsResultFunction :
249 public ChromeSyncExtensionFunction {
250 public:
251 DECLARE_EXTENSION_FUNCTION("hotwordPrivate.speakerModelExistsResult",
252 HOTWORDPRIVATE_SPEAKERMODELEXISTSRESULT)
254 protected:
255 ~HotwordPrivateSpeakerModelExistsResultFunction() override {}
257 // ExtensionFunction:
258 bool RunSync() override;
261 } // namespace extensions
263 #endif // CHROME_BROWSER_EXTENSIONS_API_HOTWORD_PRIVATE_HOTWORD_PRIVATE_API_H_