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 #include "chrome/browser/ui/webui/app_list/start_page_handler.h" | 5 #include "chrome/browser/ui/webui/app_list/start_page_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 DCHECK_EQ(Profile::FromWebUI(web_ui()), | 105 DCHECK_EQ(Profile::FromWebUI(web_ui()), |
106 content::Source<Profile>(source).ptr()); | 106 content::Source<Profile>(source).ptr()); |
107 switch (type) { | 107 switch (type) { |
108 case chrome::NOTIFICATION_EXTENSION_LOADED: { | 108 case chrome::NOTIFICATION_EXTENSION_LOADED: { |
109 extensions::Extension* extension = | 109 extensions::Extension* extension = |
110 content::Details<extensions::Extension>(details).ptr(); | 110 content::Details<extensions::Extension>(details).ptr(); |
111 if (extension->id() == extension_misc::kHotwordExtensionId) | 111 if (extension->id() == extension_misc::kHotwordExtensionId) |
112 OnHotwordEnabledChanged(); | 112 OnHotwordEnabledChanged(); |
113 break; | 113 break; |
114 } | 114 } |
115 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { | 115 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { |
116 extensions::UnloadedExtensionInfo* info = | 116 extensions::UnloadedExtensionInfo* info = |
117 content::Details<extensions::UnloadedExtensionInfo>(details).ptr(); | 117 content::Details<extensions::UnloadedExtensionInfo>(details).ptr(); |
118 if (info->extension->id() == extension_misc::kHotwordExtensionId) | 118 if (info->extension->id() == extension_misc::kHotwordExtensionId) |
119 OnHotwordEnabledChanged(); | 119 OnHotwordEnabledChanged(); |
120 break; | 120 break; |
121 } | 121 } |
122 default: | 122 default: |
123 NOTREACHED(); | 123 NOTREACHED(); |
124 break; | 124 break; |
125 } | 125 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 if (app_list::switches::IsVoiceSearchEnabled() && | 206 if (app_list::switches::IsVoiceSearchEnabled() && |
207 HotwordService::DoesHotwordSupportLanguage(profile)) { | 207 HotwordService::DoesHotwordSupportLanguage(profile)) { |
208 OnHotwordEnabledChanged(); | 208 OnHotwordEnabledChanged(); |
209 pref_change_registrar_.Init(profile->GetPrefs()); | 209 pref_change_registrar_.Init(profile->GetPrefs()); |
210 pref_change_registrar_.Add( | 210 pref_change_registrar_.Add( |
211 prefs::kHotwordSearchEnabled, | 211 prefs::kHotwordSearchEnabled, |
212 base::Bind(&StartPageHandler::OnHotwordEnabledChanged, | 212 base::Bind(&StartPageHandler::OnHotwordEnabledChanged, |
213 base::Unretained(this))); | 213 base::Unretained(this))); |
214 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 214 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
215 content::Source<Profile>(profile)); | 215 content::Source<Profile>(profile)); |
216 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 216 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
217 content::Source<Profile>(profile)); | 217 content::Source<Profile>(profile)); |
218 hotword_monitor_.reset(new HotwordBackgroundActivityMonitor(this)); | 218 hotword_monitor_.reset(new HotwordBackgroundActivityMonitor(this)); |
219 } | 219 } |
220 #endif | 220 #endif |
221 } | 221 } |
222 | 222 |
223 bool StartPageHandler::ShouldRunHotwordBackground() { | 223 bool StartPageHandler::ShouldRunHotwordBackground() { |
224 return has_hotword_recognizer_ && switches::IsHotwordAlwaysOnEnabled() && | 224 return has_hotword_recognizer_ && switches::IsHotwordAlwaysOnEnabled() && |
225 hotword_monitor_ && hotword_monitor_->IsHotwordBackgroundActive(); | 225 hotword_monitor_ && hotword_monitor_->IsHotwordBackgroundActive(); |
226 } | 226 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 if (service) | 299 if (service) |
300 service->OnSpeechRecognitionStateChanged(new_state); | 300 service->OnSpeechRecognitionStateChanged(new_state); |
301 | 301 |
302 if (new_state == SPEECH_RECOGNITION_READY && ShouldRunHotwordBackground()) { | 302 if (new_state == SPEECH_RECOGNITION_READY && ShouldRunHotwordBackground()) { |
303 web_ui()->CallJavascriptFunction( | 303 web_ui()->CallJavascriptFunction( |
304 "appList.startPage.startHotwordRecognition"); | 304 "appList.startPage.startHotwordRecognition"); |
305 } | 305 } |
306 } | 306 } |
307 | 307 |
308 } // namespace app_list | 308 } // namespace app_list |
OLD | NEW |