| 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_SEARCH_HOTWORD_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_HOTWORD_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SEARCH_HOTWORD_SERVICE_H_ | 6 #define CHROME_BROWSER_SEARCH_HOTWORD_SERVICE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/prefs/pref_change_registrar.h" | 10 #include "base/prefs/pref_change_registrar.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 namespace extensions { | 23 namespace extensions { |
| 24 class Extension; | 24 class Extension; |
| 25 class WebstoreStandaloneInstaller; | 25 class WebstoreStandaloneInstaller; |
| 26 } // namespace extensions | 26 } // namespace extensions |
| 27 | 27 |
| 28 namespace hotword_internal { | 28 namespace hotword_internal { |
| 29 // Constants for the hotword field trial. | 29 // Constants for the hotword field trial. |
| 30 extern const char kHotwordFieldTrialName[]; | 30 extern const char kHotwordFieldTrialName[]; |
| 31 extern const char kHotwordFieldTrialDisabledGroupName[]; | 31 extern const char kHotwordFieldTrialDisabledGroupName[]; |
| 32 // String passed to indicate the training state has changed. |
| 33 extern const char kHotwordTrainingEnabled[]; |
| 32 } // namespace hotword_internal | 34 } // namespace hotword_internal |
| 33 | 35 |
| 34 // Provides an interface for the Hotword component that does voice triggered | 36 // Provides an interface for the Hotword component that does voice triggered |
| 35 // search. | 37 // search. |
| 36 class HotwordService : public extensions::ExtensionRegistryObserver, | 38 class HotwordService : public extensions::ExtensionRegistryObserver, |
| 37 public KeyedService { | 39 public KeyedService { |
| 38 public: | 40 public: |
| 39 // Returns true if the hotword supports the current system language. | 41 // Returns true if the hotword supports the current system language. |
| 40 static bool DoesHotwordSupportLanguage(Profile* profile); | 42 static bool DoesHotwordSupportLanguage(Profile* profile); |
| 41 | 43 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 int error_message() { return error_message_; } | 105 int error_message() { return error_message_; } |
| 104 | 106 |
| 105 // These methods are for launching, and getting and setting the launch mode of | 107 // These methods are for launching, and getting and setting the launch mode of |
| 106 // the Hotword Audio Verification App. | 108 // the Hotword Audio Verification App. |
| 107 // | 109 // |
| 108 // TODO(kcarattini): Remove this when | 110 // TODO(kcarattini): Remove this when |
| 109 // https://code.google.com/p/chromium/issues/detail?id=165573 is fixed, | 111 // https://code.google.com/p/chromium/issues/detail?id=165573 is fixed, |
| 110 // at which time we can simply launch the app in the given mode instead of | 112 // at which time we can simply launch the app in the given mode instead of |
| 111 // having to check for it here. | 113 // having to check for it here. |
| 112 enum LaunchMode { | 114 enum LaunchMode { |
| 113 AUDIO_HISTORY_ONLY, | |
| 114 HOTWORD_ONLY, | 115 HOTWORD_ONLY, |
| 115 HOTWORD_AND_AUDIO_HISTORY, | 116 HOTWORD_AND_AUDIO_HISTORY, |
| 116 SPEECH_TRAINING | 117 RETRAIN |
| 117 }; | 118 }; |
| 118 void LaunchHotwordAudioVerificationApp(const LaunchMode& launch_mode); | 119 void LaunchHotwordAudioVerificationApp(const LaunchMode& launch_mode); |
| 119 virtual LaunchMode GetHotwordAudioVerificationLaunchMode(); | 120 virtual LaunchMode GetHotwordAudioVerificationLaunchMode(); |
| 120 | 121 |
| 122 // These methods control the speaker training communication between |
| 123 // the Hotword Audio Verification App and the Hotword Extension that |
| 124 // contains the NaCl module. |
| 125 void StartTraining(); |
| 126 void FinalizeSpeakerModel(); |
| 127 void StopTraining(); |
| 128 void NotifyHotwordTriggered(); |
| 129 |
| 130 // Returns true if speaker training is currently in progress. |
| 131 bool IsTraining(); |
| 132 |
| 121 private: | 133 private: |
| 122 // Returns the ID of the extension that may need to be reinstalled. | 134 // Returns the ID of the extension that may need to be reinstalled. |
| 123 std::string ReinstalledExtensionId(); | 135 std::string ReinstalledExtensionId(); |
| 124 | 136 |
| 125 Profile* profile_; | 137 Profile* profile_; |
| 126 | 138 |
| 127 PrefChangeRegistrar pref_registrar_; | 139 PrefChangeRegistrar pref_registrar_; |
| 128 | 140 |
| 129 content::NotificationRegistrar registrar_; | 141 content::NotificationRegistrar registrar_; |
| 130 | 142 |
| 131 // For observing the ExtensionRegistry. | 143 // For observing the ExtensionRegistry. |
| 132 ScopedObserver<extensions::ExtensionRegistry, | 144 ScopedObserver<extensions::ExtensionRegistry, |
| 133 extensions::ExtensionRegistryObserver> | 145 extensions::ExtensionRegistryObserver> |
| 134 extension_registry_observer_; | 146 extension_registry_observer_; |
| 135 | 147 |
| 136 scoped_refptr<extensions::WebstoreStandaloneInstaller> installer_; | 148 scoped_refptr<extensions::WebstoreStandaloneInstaller> installer_; |
| 137 | 149 |
| 138 scoped_ptr<HotwordAudioHistoryHandler> audio_history_handler_; | 150 scoped_ptr<HotwordAudioHistoryHandler> audio_history_handler_; |
| 139 | 151 |
| 140 HotwordClient* client_; | 152 HotwordClient* client_; |
| 141 int error_message_; | 153 int error_message_; |
| 142 bool reinstall_pending_; | 154 bool reinstall_pending_; |
| 155 // Whether we are currently in the process of training the speaker model. |
| 156 bool training_; |
| 143 | 157 |
| 144 base::WeakPtrFactory<HotwordService> weak_factory_; | 158 base::WeakPtrFactory<HotwordService> weak_factory_; |
| 145 | 159 |
| 146 // Stores the launch mode for the Hotword Audio Verification App. | 160 // Stores the launch mode for the Hotword Audio Verification App. |
| 147 LaunchMode hotword_audio_verification_launch_mode_; | 161 LaunchMode hotword_audio_verification_launch_mode_; |
| 148 | 162 |
| 149 DISALLOW_COPY_AND_ASSIGN(HotwordService); | 163 DISALLOW_COPY_AND_ASSIGN(HotwordService); |
| 150 }; | 164 }; |
| 151 | 165 |
| 152 #endif // CHROME_BROWSER_SEARCH_HOTWORD_SERVICE_H_ | 166 #endif // CHROME_BROWSER_SEARCH_HOTWORD_SERVICE_H_ |
| OLD | NEW |