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