OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/app_list/app_list_view_delegate.h" | 5 #include "chrome/browser/ui/app_list/app_list_view_delegate.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/metrics/user_metrics.h" | 11 #include "base/metrics/user_metrics.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
16 #include "chrome/browser/feedback/feedback_util.h" | 16 #include "chrome/browser/feedback/feedback_util.h" |
17 #include "chrome/browser/profiles/profile_info_cache.h" | 17 #include "chrome/browser/profiles/profile_info_cache.h" |
18 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
19 #include "chrome/browser/search/hotword_service.h" | |
20 #include "chrome/browser/search/hotword_service_factory.h" | |
19 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" | 21 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" |
20 #include "chrome/browser/ui/app_list/app_list_service.h" | 22 #include "chrome/browser/ui/app_list/app_list_service.h" |
21 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" | 23 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" |
22 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" | 24 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" |
23 #include "chrome/browser/ui/app_list/search/search_controller.h" | 25 #include "chrome/browser/ui/app_list/search/search_controller.h" |
24 #include "chrome/browser/ui/app_list/start_page_service.h" | 26 #include "chrome/browser/ui/app_list/start_page_service.h" |
25 #include "chrome/browser/ui/browser_finder.h" | 27 #include "chrome/browser/ui/browser_finder.h" |
26 #include "chrome/browser/ui/chrome_pages.h" | 28 #include "chrome/browser/ui/chrome_pages.h" |
27 #include "chrome/browser/ui/host_desktop.h" | 29 #include "chrome/browser/ui/host_desktop.h" |
28 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 30 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 profile_manager()->GetProfileInfoCache().RemoveObserver(this); | 138 profile_manager()->GetProfileInfoCache().RemoveObserver(this); |
137 | 139 |
138 SigninManagerFactory* factory = SigninManagerFactory::GetInstance(); | 140 SigninManagerFactory* factory = SigninManagerFactory::GetInstance(); |
139 if (factory) | 141 if (factory) |
140 factory->RemoveObserver(this); | 142 factory->RemoveObserver(this); |
141 | 143 |
142 // Ensure search controller is released prior to speech_ui_. | 144 // Ensure search controller is released prior to speech_ui_. |
143 search_controller_.reset(); | 145 search_controller_.reset(); |
144 } | 146 } |
145 | 147 |
148 void AppListViewDelegate::OnHotwordStateChanged(bool enabled) { | |
149 if (enabled) { | |
150 if (speech_ui_->state() == app_list::SPEECH_RECOGNITION_READY) { | |
151 OnSpeechRecognitionStateChanged( | |
152 app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING); | |
153 } | |
154 } else { | |
155 if (speech_ui_->state() == app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING) | |
rpetterson
2014/05/05 19:43:36
I'm confused by what the "enabled" parameter is re
Jun Mukai
2014/05/05 20:00:55
good catch. changed to use 'started' everywhere
| |
156 OnSpeechRecognitionStateChanged(app_list::SPEECH_RECOGNITION_READY); | |
157 } | |
158 } | |
159 | |
160 void AppListViewDelegate::OnHotwordRecognized() { | |
161 DCHECK_EQ(app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING, | |
162 speech_ui_->state()); | |
163 ToggleSpeechRecognition(); | |
164 } | |
165 | |
146 void AppListViewDelegate::SigninManagerCreated(SigninManagerBase* manager) { | 166 void AppListViewDelegate::SigninManagerCreated(SigninManagerBase* manager) { |
147 scoped_observer_.Add(manager); | 167 scoped_observer_.Add(manager); |
148 } | 168 } |
149 | 169 |
150 void AppListViewDelegate::SigninManagerShutdown(SigninManagerBase* manager) { | 170 void AppListViewDelegate::SigninManagerShutdown(SigninManagerBase* manager) { |
151 if (scoped_observer_.IsObserving(manager)) | 171 if (scoped_observer_.IsObserving(manager)) |
152 scoped_observer_.Remove(manager); | 172 scoped_observer_.Remove(manager); |
153 } | 173 } |
154 | 174 |
155 void AppListViewDelegate::GoogleSigninFailed( | 175 void AppListViewDelegate::GoogleSigninFailed( |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 } | 303 } |
284 | 304 |
285 void AppListViewDelegate::AutoLaunchCanceled() { | 305 void AppListViewDelegate::AutoLaunchCanceled() { |
286 base::RecordAction(base::UserMetricsAction("AppList_AutoLaunchCanceled")); | 306 base::RecordAction(base::UserMetricsAction("AppList_AutoLaunchCanceled")); |
287 auto_launch_timeout_ = base::TimeDelta(); | 307 auto_launch_timeout_ = base::TimeDelta(); |
288 } | 308 } |
289 | 309 |
290 void AppListViewDelegate::ViewInitialized() { | 310 void AppListViewDelegate::ViewInitialized() { |
291 app_list::StartPageService* service = | 311 app_list::StartPageService* service = |
292 app_list::StartPageService::Get(profile_); | 312 app_list::StartPageService::Get(profile_); |
293 if (service) | 313 if (service) { |
294 service->AppListShown(); | 314 service->AppListShown(); |
315 if (service->HotwordEnabled()) { | |
316 HotwordService* hotword_service = | |
317 HotwordServiceFactory::GetForProfile(profile_); | |
318 if (hotword_service) | |
319 hotword_service->RequestHotwordSession(this); | |
320 } | |
321 } | |
295 } | 322 } |
296 | 323 |
297 void AppListViewDelegate::Dismiss() { | 324 void AppListViewDelegate::Dismiss() { |
298 controller_->DismissView(); | 325 controller_->DismissView(); |
299 } | 326 } |
300 | 327 |
301 void AppListViewDelegate::ViewClosing() { | 328 void AppListViewDelegate::ViewClosing() { |
302 controller_->ViewClosing(); | 329 controller_->ViewClosing(); |
303 | 330 |
304 app_list::StartPageService* service = | 331 app_list::StartPageService* service = |
305 app_list::StartPageService::Get(profile_); | 332 app_list::StartPageService::Get(profile_); |
306 if (service) | 333 if (service) { |
307 service->AppListHidden(); | 334 service->AppListHidden(); |
335 if (service->HotwordEnabled()) { | |
336 HotwordService* hotword_service = | |
337 HotwordServiceFactory::GetForProfile(profile_); | |
338 if (hotword_service) | |
339 hotword_service->StopHotwordSession(this); | |
340 } | |
341 } | |
308 } | 342 } |
309 | 343 |
310 gfx::ImageSkia AppListViewDelegate::GetWindowIcon() { | 344 gfx::ImageSkia AppListViewDelegate::GetWindowIcon() { |
311 return controller_->GetWindowIcon(); | 345 return controller_->GetWindowIcon(); |
312 } | 346 } |
313 | 347 |
314 void AppListViewDelegate::OpenSettings() { | 348 void AppListViewDelegate::OpenSettings() { |
315 ExtensionService* service = profile_->GetExtensionService(); | 349 ExtensionService* service = profile_->GetExtensionService(); |
316 DCHECK(service); | 350 DCHECK(service); |
317 const extensions::Extension* extension = service->GetInstalledExtension( | 351 const extensions::Extension* extension = service->GetInstalledExtension( |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 | 448 |
415 void AppListViewDelegate::AddObserver( | 449 void AppListViewDelegate::AddObserver( |
416 app_list::AppListViewDelegateObserver* observer) { | 450 app_list::AppListViewDelegateObserver* observer) { |
417 observers_.AddObserver(observer); | 451 observers_.AddObserver(observer); |
418 } | 452 } |
419 | 453 |
420 void AppListViewDelegate::RemoveObserver( | 454 void AppListViewDelegate::RemoveObserver( |
421 app_list::AppListViewDelegateObserver* observer) { | 455 app_list::AppListViewDelegateObserver* observer) { |
422 observers_.RemoveObserver(observer); | 456 observers_.RemoveObserver(observer); |
423 } | 457 } |
OLD | NEW |