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. 4 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_HOTWORD_PRIVATE_HOTWORD_PRIVATE_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_HOTWORD_PRIVATE_HOTWORD_PRIVATE_API_H_ 7 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 14 class Profile; 15 16 namespace extensions { 17 18 // Listens for changes in disable/enabled state and forwards as an extension 19 // event. 20 class HotwordPrivateEventService : public BrowserContextKeyedAPI { 21 public: 22 explicit HotwordPrivateEventService(content::BrowserContext* context); 23 virtual ~HotwordPrivateEventService(); 24 25 // BrowserContextKeyedAPI implementation. 26 virtual void Shutdown() OVERRIDE; 27 static BrowserContextKeyedAPIFactory<HotwordPrivateEventService>* 28 GetFactoryInstance(); 29 static const char* service_name(); 30 31 void OnEnabledChanged(const std::string& pref_name); 32 33 void OnHotwordSessionRequested(); 34 35 void OnHotwordSessionStopped(); 36 37 private: 38 friend class BrowserContextKeyedAPIFactory<HotwordPrivateEventService>; 39 40 void SignalEvent(const std::string& event_name); 41 42 Profile* profile_; 43 PrefChangeRegistrar pref_change_registrar_; 44 }; 45 46 47 class HotwordPrivateSetEnabledFunction : public ChromeSyncExtensionFunction { 48 public: 49 DECLARE_EXTENSION_FUNCTION("hotwordPrivate.setEnabled", 50 HOTWORDPRIVATE_SETENABLED) 51 52 protected: ~HotwordPrivateSetEnabledFunction()53 virtual ~HotwordPrivateSetEnabledFunction() {} 54 55 // ExtensionFunction: 56 virtual bool RunSync() OVERRIDE; 57 }; 58 59 class HotwordPrivateSetAudioLoggingEnabledFunction 60 : public ChromeSyncExtensionFunction { 61 public: 62 DECLARE_EXTENSION_FUNCTION("hotwordPrivate.setAudioLoggingEnabled", 63 HOTWORDPRIVATE_SETAUDIOLOGGINGENABLED) 64 65 protected: ~HotwordPrivateSetAudioLoggingEnabledFunction()66 virtual ~HotwordPrivateSetAudioLoggingEnabledFunction() {} 67 68 // ExtensionFunction: 69 virtual bool RunSync() OVERRIDE; 70 }; 71 72 class HotwordPrivateGetStatusFunction : public ChromeSyncExtensionFunction { 73 public: 74 DECLARE_EXTENSION_FUNCTION("hotwordPrivate.getStatus", 75 HOTWORDPRIVATE_GETSTATUS) 76 77 protected: ~HotwordPrivateGetStatusFunction()78 virtual ~HotwordPrivateGetStatusFunction() {} 79 80 // ExtensionFunction: 81 virtual bool RunSync() OVERRIDE; 82 }; 83 84 class HotwordPrivateSetHotwordSessionStateFunction 85 : public ChromeSyncExtensionFunction { 86 public: 87 DECLARE_EXTENSION_FUNCTION("hotwordPrivate.setHotwordSessionState", 88 HOTWORDPRIVATE_SETHOTWORDSESSIONSTATE); 89 90 protected: ~HotwordPrivateSetHotwordSessionStateFunction()91 virtual ~HotwordPrivateSetHotwordSessionStateFunction() {} 92 93 // ExtensionFunction: 94 virtual bool RunSync() OVERRIDE; 95 }; 96 97 class HotwordPrivateNotifyHotwordRecognitionFunction 98 : public ChromeSyncExtensionFunction { 99 public: 100 DECLARE_EXTENSION_FUNCTION("hotwordPrivate.notifyHotwordRecognition", 101 HOTWORDPRIVATE_NOTIFYHOTWORDRECOGNITION); 102 103 protected: ~HotwordPrivateNotifyHotwordRecognitionFunction()104 virtual ~HotwordPrivateNotifyHotwordRecognitionFunction() {} 105 106 // ExtensionFunction: 107 virtual bool RunSync() OVERRIDE; 108 }; 109 110 } // namespace extensions 111 112 #endif // CHROME_BROWSER_EXTENSIONS_API_HOTWORD_PRIVATE_HOTWORD_PRIVATE_API_H_ 113