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 "apps/custom_launcher_page_contents.h" | 9 #include "apps/custom_launcher_page_contents.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "chrome/browser/web_applications/web_app.h" | 36 #include "chrome/browser/web_applications/web_app.h" |
37 #include "chrome/common/chrome_switches.h" | 37 #include "chrome/common/chrome_switches.h" |
38 #include "chrome/common/extensions/extension_constants.h" | 38 #include "chrome/common/extensions/extension_constants.h" |
39 #include "chrome/common/url_constants.h" | 39 #include "chrome/common/url_constants.h" |
40 #include "components/signin/core/browser/signin_manager.h" | 40 #include "components/signin/core/browser/signin_manager.h" |
41 #include "content/public/browser/browser_thread.h" | 41 #include "content/public/browser/browser_thread.h" |
42 #include "content/public/browser/notification_service.h" | 42 #include "content/public/browser/notification_service.h" |
43 #include "content/public/browser/page_navigator.h" | 43 #include "content/public/browser/page_navigator.h" |
44 #include "content/public/browser/render_view_host.h" | 44 #include "content/public/browser/render_view_host.h" |
45 #include "content/public/browser/render_widget_host_view.h" | 45 #include "content/public/browser/render_widget_host_view.h" |
| 46 #include "content/public/browser/speech_recognition_session_preamble.h" |
46 #include "content/public/browser/user_metrics.h" | 47 #include "content/public/browser/user_metrics.h" |
47 #include "content/public/browser/web_contents.h" | 48 #include "content/public/browser/web_contents.h" |
48 #include "extensions/browser/extension_registry.h" | 49 #include "extensions/browser/extension_registry.h" |
49 #include "extensions/common/constants.h" | 50 #include "extensions/common/constants.h" |
50 #include "extensions/common/extension_set.h" | 51 #include "extensions/common/extension_set.h" |
51 #include "extensions/common/manifest_constants.h" | 52 #include "extensions/common/manifest_constants.h" |
52 #include "extensions/common/manifest_handlers/launcher_page_info.h" | 53 #include "extensions/common/manifest_handlers/launcher_page_info.h" |
53 #include "grit/theme_resources.h" | 54 #include "grit/theme_resources.h" |
54 #include "ui/app_list/app_list_switches.h" | 55 #include "ui/app_list/app_list_switches.h" |
55 #include "ui/app_list/app_list_view_delegate_observer.h" | 56 #include "ui/app_list/app_list_view_delegate_observer.h" |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 if (speech_ui_->state() == app_list::SPEECH_RECOGNITION_READY) { | 379 if (speech_ui_->state() == app_list::SPEECH_RECOGNITION_READY) { |
379 OnSpeechRecognitionStateChanged( | 380 OnSpeechRecognitionStateChanged( |
380 app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING); | 381 app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING); |
381 } | 382 } |
382 } else { | 383 } else { |
383 if (speech_ui_->state() == app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING) | 384 if (speech_ui_->state() == app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING) |
384 OnSpeechRecognitionStateChanged(app_list::SPEECH_RECOGNITION_READY); | 385 OnSpeechRecognitionStateChanged(app_list::SPEECH_RECOGNITION_READY); |
385 } | 386 } |
386 } | 387 } |
387 | 388 |
388 void AppListViewDelegate::OnHotwordRecognized() { | 389 void AppListViewDelegate::OnHotwordRecognized( |
| 390 const scoped_refptr<content::SpeechRecognitionSessionPreamble>& preamble) { |
389 DCHECK_EQ(app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING, | 391 DCHECK_EQ(app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING, |
390 speech_ui_->state()); | 392 speech_ui_->state()); |
391 ToggleSpeechRecognition(); | 393 ToggleSpeechRecognitionForHotword(preamble); |
392 } | 394 } |
393 | 395 |
394 void AppListViewDelegate::SigninManagerCreated(SigninManagerBase* manager) { | 396 void AppListViewDelegate::SigninManagerCreated(SigninManagerBase* manager) { |
395 scoped_observer_.Add(manager); | 397 scoped_observer_.Add(manager); |
396 } | 398 } |
397 | 399 |
398 void AppListViewDelegate::SigninManagerShutdown(SigninManagerBase* manager) { | 400 void AppListViewDelegate::SigninManagerShutdown(SigninManagerBase* manager) { |
399 if (scoped_observer_.IsObserving(manager)) | 401 if (scoped_observer_.IsObserving(manager)) |
400 scoped_observer_.Remove(manager); | 402 scoped_observer_.Remove(manager); |
401 } | 403 } |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 | 599 |
598 void AppListViewDelegate::OpenFeedback() { | 600 void AppListViewDelegate::OpenFeedback() { |
599 chrome::HostDesktopType desktop = chrome::GetHostDesktopTypeForNativeWindow( | 601 chrome::HostDesktopType desktop = chrome::GetHostDesktopTypeForNativeWindow( |
600 controller_->GetAppListWindow()); | 602 controller_->GetAppListWindow()); |
601 Browser* browser = chrome::FindTabbedBrowser(profile_, false, desktop); | 603 Browser* browser = chrome::FindTabbedBrowser(profile_, false, desktop); |
602 chrome::ShowFeedbackPage(browser, std::string(), | 604 chrome::ShowFeedbackPage(browser, std::string(), |
603 chrome::kAppLauncherCategoryTag); | 605 chrome::kAppLauncherCategoryTag); |
604 } | 606 } |
605 | 607 |
606 void AppListViewDelegate::ToggleSpeechRecognition() { | 608 void AppListViewDelegate::ToggleSpeechRecognition() { |
| 609 ToggleSpeechRecognitionForHotword(nullptr); |
| 610 } |
| 611 |
| 612 void AppListViewDelegate::ToggleSpeechRecognitionForHotword( |
| 613 const scoped_refptr<content::SpeechRecognitionSessionPreamble>& preamble) { |
607 app_list::StartPageService* service = | 614 app_list::StartPageService* service = |
608 app_list::StartPageService::Get(profile_); | 615 app_list::StartPageService::Get(profile_); |
609 if (service) | 616 if (service) |
610 service->ToggleSpeechRecognition(); | 617 service->ToggleSpeechRecognition(preamble); |
611 | 618 |
612 // With the new hotword extension, stop the hotword session. With the launcher | 619 // With the new hotword extension, stop the hotword session. With the launcher |
613 // and NTP, this is unnecessary since the hotwording is implicitly stopped. | 620 // and NTP, this is unnecessary since the hotwording is implicitly stopped. |
614 // However, for always on, hotword triggering launches the launcher which | 621 // However, for always on, hotword triggering launches the launcher which |
615 // starts a session and hence starts the hotword detector. This results in the | 622 // starts a session and hence starts the hotword detector. This results in the |
616 // hotword detector and the speech-to-text engine running in parallel, which | 623 // hotword detector and the speech-to-text engine running in parallel, which |
617 // will conflict with each other (i.e. saying 'Ok Google' twice in a row | 624 // will conflict with each other (i.e. saying 'Ok Google' twice in a row |
618 // should cause a search to happen for 'Ok Google', not two hotword triggers). | 625 // should cause a search to happen for 'Ok Google', not two hotword triggers). |
619 // To get around this, always stop the session when switching to speech | 626 // To get around this, always stop the session when switching to speech |
620 // recognition. | 627 // recognition. |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 | 795 |
789 // SigninManagerFactory is not a leaky singleton (unlike this class), and | 796 // SigninManagerFactory is not a leaky singleton (unlike this class), and |
790 // its destructor will check that it has no remaining observers. | 797 // its destructor will check that it has no remaining observers. |
791 scoped_observer_.RemoveAll(); | 798 scoped_observer_.RemoveAll(); |
792 SigninManagerFactory::GetInstance()->RemoveObserver(this); | 799 SigninManagerFactory::GetInstance()->RemoveObserver(this); |
793 break; | 800 break; |
794 default: | 801 default: |
795 NOTREACHED(); | 802 NOTREACHED(); |
796 } | 803 } |
797 } | 804 } |
OLD | NEW |