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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 profile_manager()->GetProfileInfoCache().RemoveObserver(this); | 143 profile_manager()->GetProfileInfoCache().RemoveObserver(this); |
142 | 144 |
143 SigninManagerFactory* factory = SigninManagerFactory::GetInstance(); | 145 SigninManagerFactory* factory = SigninManagerFactory::GetInstance(); |
144 if (factory) | 146 if (factory) |
145 factory->RemoveObserver(this); | 147 factory->RemoveObserver(this); |
146 | 148 |
147 // Ensure search controller is released prior to speech_ui_. | 149 // Ensure search controller is released prior to speech_ui_. |
148 search_controller_.reset(); | 150 search_controller_.reset(); |
149 } | 151 } |
150 | 152 |
| 153 void AppListViewDelegate::OnHotwordStateChanged(bool started) { |
| 154 if (started) { |
| 155 if (speech_ui_->state() == app_list::SPEECH_RECOGNITION_READY) { |
| 156 OnSpeechRecognitionStateChanged( |
| 157 app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING); |
| 158 } |
| 159 } else { |
| 160 if (speech_ui_->state() == app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING) |
| 161 OnSpeechRecognitionStateChanged(app_list::SPEECH_RECOGNITION_READY); |
| 162 } |
| 163 } |
| 164 |
| 165 void AppListViewDelegate::OnHotwordRecognized() { |
| 166 DCHECK_EQ(app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING, |
| 167 speech_ui_->state()); |
| 168 ToggleSpeechRecognition(); |
| 169 } |
| 170 |
151 void AppListViewDelegate::SigninManagerCreated(SigninManagerBase* manager) { | 171 void AppListViewDelegate::SigninManagerCreated(SigninManagerBase* manager) { |
152 scoped_observer_.Add(manager); | 172 scoped_observer_.Add(manager); |
153 } | 173 } |
154 | 174 |
155 void AppListViewDelegate::SigninManagerShutdown(SigninManagerBase* manager) { | 175 void AppListViewDelegate::SigninManagerShutdown(SigninManagerBase* manager) { |
156 if (scoped_observer_.IsObserving(manager)) | 176 if (scoped_observer_.IsObserving(manager)) |
157 scoped_observer_.Remove(manager); | 177 scoped_observer_.Remove(manager); |
158 } | 178 } |
159 | 179 |
160 void AppListViewDelegate::GoogleSigninFailed( | 180 void AppListViewDelegate::GoogleSigninFailed( |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 } | 308 } |
289 | 309 |
290 void AppListViewDelegate::AutoLaunchCanceled() { | 310 void AppListViewDelegate::AutoLaunchCanceled() { |
291 base::RecordAction(base::UserMetricsAction("AppList_AutoLaunchCanceled")); | 311 base::RecordAction(base::UserMetricsAction("AppList_AutoLaunchCanceled")); |
292 auto_launch_timeout_ = base::TimeDelta(); | 312 auto_launch_timeout_ = base::TimeDelta(); |
293 } | 313 } |
294 | 314 |
295 void AppListViewDelegate::ViewInitialized() { | 315 void AppListViewDelegate::ViewInitialized() { |
296 app_list::StartPageService* service = | 316 app_list::StartPageService* service = |
297 app_list::StartPageService::Get(profile_); | 317 app_list::StartPageService::Get(profile_); |
298 if (service) | 318 if (service) { |
299 service->AppListShown(); | 319 service->AppListShown(); |
| 320 if (service->HotwordEnabled()) { |
| 321 HotwordService* hotword_service = |
| 322 HotwordServiceFactory::GetForProfile(profile_); |
| 323 if (hotword_service) |
| 324 hotword_service->RequestHotwordSession(this); |
| 325 } |
| 326 } |
300 } | 327 } |
301 | 328 |
302 void AppListViewDelegate::Dismiss() { | 329 void AppListViewDelegate::Dismiss() { |
303 controller_->DismissView(); | 330 controller_->DismissView(); |
304 } | 331 } |
305 | 332 |
306 void AppListViewDelegate::ViewClosing() { | 333 void AppListViewDelegate::ViewClosing() { |
307 controller_->ViewClosing(); | 334 controller_->ViewClosing(); |
308 | 335 |
309 app_list::StartPageService* service = | 336 app_list::StartPageService* service = |
310 app_list::StartPageService::Get(profile_); | 337 app_list::StartPageService::Get(profile_); |
311 if (service) | 338 if (service) { |
312 service->AppListHidden(); | 339 service->AppListHidden(); |
| 340 if (service->HotwordEnabled()) { |
| 341 HotwordService* hotword_service = |
| 342 HotwordServiceFactory::GetForProfile(profile_); |
| 343 if (hotword_service) |
| 344 hotword_service->StopHotwordSession(this); |
| 345 } |
| 346 } |
313 } | 347 } |
314 | 348 |
315 gfx::ImageSkia AppListViewDelegate::GetWindowIcon() { | 349 gfx::ImageSkia AppListViewDelegate::GetWindowIcon() { |
316 return controller_->GetWindowIcon(); | 350 return controller_->GetWindowIcon(); |
317 } | 351 } |
318 | 352 |
319 void AppListViewDelegate::OpenSettings() { | 353 void AppListViewDelegate::OpenSettings() { |
320 ExtensionService* service = profile_->GetExtensionService(); | 354 ExtensionService* service = profile_->GetExtensionService(); |
321 DCHECK(service); | 355 DCHECK(service); |
322 const extensions::Extension* extension = service->GetInstalledExtension( | 356 const extensions::Extension* extension = service->GetInstalledExtension( |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 | 468 |
435 void AppListViewDelegate::AddObserver( | 469 void AppListViewDelegate::AddObserver( |
436 app_list::AppListViewDelegateObserver* observer) { | 470 app_list::AppListViewDelegateObserver* observer) { |
437 observers_.AddObserver(observer); | 471 observers_.AddObserver(observer); |
438 } | 472 } |
439 | 473 |
440 void AppListViewDelegate::RemoveObserver( | 474 void AppListViewDelegate::RemoveObserver( |
441 app_list::AppListViewDelegateObserver* observer) { | 475 app_list::AppListViewDelegateObserver* observer) { |
442 observers_.RemoveObserver(observer); | 476 observers_.RemoveObserver(observer); |
443 } | 477 } |
OLD | NEW |