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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
458 if (!profile_) | 458 if (!profile_) |
459 return; | 459 return; |
460 | 460 |
461 app_list::StartPageService* service = | 461 app_list::StartPageService* service = |
462 app_list::StartPageService::Get(profile_); | 462 app_list::StartPageService::Get(profile_); |
463 if (service) { | 463 if (service) { |
464 service->AppListHidden(); | 464 service->AppListHidden(); |
465 if (service->HotwordEnabled()) { | 465 if (service->HotwordEnabled()) { |
466 HotwordService* hotword_service = | 466 HotwordService* hotword_service = |
467 HotwordServiceFactory::GetForProfile(profile_); | 467 HotwordServiceFactory::GetForProfile(profile_); |
468 if (hotword_service) | 468 if (hotword_service) { |
469 hotword_service->StopHotwordSession(this); | 469 hotword_service->StopHotwordSession(this); |
470 | |
471 // If we're in always-on mode, we always want to re-start hotwording | |
Matt Giuca
2014/10/09 18:07:11
nit: "restart" does not need a hyphen.
Anand Mistry (off Chromium)
2014/10/13 21:51:59
Done.
| |
472 // after closing the launcher window. Use an empty client so that the | |
473 // launcher is opened. The previous call to StopHotwordSession is still | |
Matt Giuca
2014/10/09 18:07:11
I'm a bit unclear on what this comment means. Are
Anand Mistry (off Chromium)
2014/10/13 21:51:59
Yes.
| |
474 // needed to clear the client since you can't have two sessions running. | |
475 // TODO(amistry): This only works on ChromeOS since Chrome hides the | |
Matt Giuca
2014/10/09 18:07:11
What happens on non-ChromeOS platforms in this cas
Anand Mistry (off Chromium)
2014/10/13 21:51:59
For now, we're not targeting non-ChromeOS platform
tapted
2014/10/13 22:48:08
sorry - missed this Q. Answer: maybe :).
The view
| |
476 // launcher instead of destroying it. Make this work on Chrome. | |
477 if (hotword_service->IsAlwaysOnEnabled()) | |
478 hotword_service->RequestHotwordSession(NULL); | |
479 } | |
470 } | 480 } |
471 } | 481 } |
472 } | 482 } |
473 | 483 |
474 gfx::ImageSkia AppListViewDelegate::GetWindowIcon() { | 484 gfx::ImageSkia AppListViewDelegate::GetWindowIcon() { |
475 return controller_->GetWindowIcon(); | 485 return controller_->GetWindowIcon(); |
476 } | 486 } |
477 | 487 |
478 void AppListViewDelegate::OpenSettings() { | 488 void AppListViewDelegate::OpenSettings() { |
479 const extensions::Extension* extension = | 489 const extensions::Extension* extension = |
(...skipping 25 matching lines...) Expand all Loading... | |
505 Browser* browser = chrome::FindTabbedBrowser(profile_, false, desktop); | 515 Browser* browser = chrome::FindTabbedBrowser(profile_, false, desktop); |
506 chrome::ShowFeedbackPage(browser, std::string(), | 516 chrome::ShowFeedbackPage(browser, std::string(), |
507 chrome::kAppLauncherCategoryTag); | 517 chrome::kAppLauncherCategoryTag); |
508 } | 518 } |
509 | 519 |
510 void AppListViewDelegate::ToggleSpeechRecognition() { | 520 void AppListViewDelegate::ToggleSpeechRecognition() { |
511 app_list::StartPageService* service = | 521 app_list::StartPageService* service = |
512 app_list::StartPageService::Get(profile_); | 522 app_list::StartPageService::Get(profile_); |
513 if (service) | 523 if (service) |
514 service->ToggleSpeechRecognition(); | 524 service->ToggleSpeechRecognition(); |
525 | |
526 // With the new hotword extension, stop the hotword session. With the launcher | |
527 // and NTP, this is unnecessary since the hotwording is implicitly stopped. | |
528 // However, for always on, hotword triggering launches the launcher which | |
529 // starts a session and hence starts the detector. This results in the | |
530 // detector running in parallel with the speech recognition. To get around | |
Matt Giuca
2014/10/09 18:07:11
It's not clear what the difference is between "the
Anand Mistry (off Chromium)
2014/10/13 21:51:59
They're two different things. By "detector", I mea
| |
531 // this, always stop the session when switching to speech recognition. An | |
532 // alternative is to launch the launcher with a "do not start hotword session" | |
Matt Giuca
2014/10/09 18:07:11
Don't need to write alternatives in a comment (unl
Anand Mistry (off Chromium)
2014/10/13 21:51:59
Done.
| |
533 // flag, but that seems messy compared to this. | |
534 if (HotwordService::IsExperimentalHotwordingEnabled() && | |
535 service && service->HotwordEnabled()) { | |
536 HotwordService* hotword_service = | |
537 HotwordServiceFactory::GetForProfile(profile_); | |
538 if (hotword_service) { | |
Matt Giuca
2014/10/09 18:07:11
nit: No curlies.
Anand Mistry (off Chromium)
2014/10/13 21:51:59
Done.
| |
539 hotword_service->StopHotwordSession(this); | |
540 } | |
541 } | |
515 } | 542 } |
516 | 543 |
517 void AppListViewDelegate::ShowForProfileByPath( | 544 void AppListViewDelegate::ShowForProfileByPath( |
518 const base::FilePath& profile_path) { | 545 const base::FilePath& profile_path) { |
519 controller_->ShowForProfileByPath(profile_path); | 546 controller_->ShowForProfileByPath(profile_path); |
520 } | 547 } |
521 | 548 |
522 void AppListViewDelegate::OnSpeechResult(const base::string16& result, | 549 void AppListViewDelegate::OnSpeechResult(const base::string16& result, |
523 bool is_final) { | 550 bool is_final) { |
524 speech_ui_->SetSpeechResult(result, is_final); | 551 speech_ui_->SetSpeechResult(result, is_final); |
525 if (is_final) { | 552 if (is_final) { |
526 auto_launch_timeout_ = base::TimeDelta::FromMilliseconds( | 553 auto_launch_timeout_ = base::TimeDelta::FromMilliseconds( |
527 kAutoLaunchDefaultTimeoutMilliSec); | 554 kAutoLaunchDefaultTimeoutMilliSec); |
528 model_->search_box()->SetText(result); | 555 model_->search_box()->SetText(result); |
529 } | 556 } |
530 } | 557 } |
531 | 558 |
532 void AppListViewDelegate::OnSpeechSoundLevelChanged(int16 level) { | 559 void AppListViewDelegate::OnSpeechSoundLevelChanged(int16 level) { |
533 speech_ui_->UpdateSoundLevel(level); | 560 speech_ui_->UpdateSoundLevel(level); |
534 } | 561 } |
535 | 562 |
536 void AppListViewDelegate::OnSpeechRecognitionStateChanged( | 563 void AppListViewDelegate::OnSpeechRecognitionStateChanged( |
537 app_list::SpeechRecognitionState new_state) { | 564 app_list::SpeechRecognitionState new_state) { |
538 speech_ui_->SetSpeechRecognitionState(new_state); | 565 speech_ui_->SetSpeechRecognitionState(new_state); |
539 | 566 |
540 app_list::StartPageService* service = | 567 app_list::StartPageService* service = |
541 app_list::StartPageService::Get(profile_); | 568 app_list::StartPageService::Get(profile_); |
542 // With the new hotword extension, we need to re-request hotwording after | 569 // With the new hotword extension, we need to re-request hotwording after |
543 // speech recognition has stopped. | 570 // speech recognition has stopped. IsAppListVisible() is called because this |
Matt Giuca
2014/10/09 18:07:11
Just say "Do not request hotwording after the app
Anand Mistry (off Chromium)
2014/10/13 21:51:59
Done.
| |
571 // notification can happen after the app list is closed. In that case, we | |
572 // don't want to re-request hotwording. | |
544 if (new_state == app_list::SPEECH_RECOGNITION_READY && | 573 if (new_state == app_list::SPEECH_RECOGNITION_READY && |
545 HotwordService::IsExperimentalHotwordingEnabled() && | 574 HotwordService::IsExperimentalHotwordingEnabled() && |
546 service && service->HotwordEnabled()) { | 575 service && service->HotwordEnabled() && |
576 AppListService::Get(chrome::GetActiveDesktop())->IsAppListVisible()) { | |
tapted
2014/10/09 03:37:00
There is an AppListViewDelegate for each desktop t
Anand Mistry (off Chromium)
2014/10/13 21:51:59
Done.
| |
547 HotwordService* hotword_service = | 577 HotwordService* hotword_service = |
548 HotwordServiceFactory::GetForProfile(profile_); | 578 HotwordServiceFactory::GetForProfile(profile_); |
549 if (hotword_service) { | 579 if (hotword_service) { |
550 hotword_service->RequestHotwordSession(this); | 580 hotword_service->RequestHotwordSession(this); |
551 } | 581 } |
552 } | 582 } |
553 } | 583 } |
554 | 584 |
555 #if defined(TOOLKIT_VIEWS) | 585 #if defined(TOOLKIT_VIEWS) |
556 views::View* AppListViewDelegate::CreateStartPageWebView( | 586 views::View* AppListViewDelegate::CreateStartPageWebView( |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
655 | 685 |
656 // SigninManagerFactory is not a leaky singleton (unlike this class), and | 686 // SigninManagerFactory is not a leaky singleton (unlike this class), and |
657 // its destructor will check that it has no remaining observers. | 687 // its destructor will check that it has no remaining observers. |
658 scoped_observer_.RemoveAll(); | 688 scoped_observer_.RemoveAll(); |
659 SigninManagerFactory::GetInstance()->RemoveObserver(this); | 689 SigninManagerFactory::GetInstance()->RemoveObserver(this); |
660 break; | 690 break; |
661 default: | 691 default: |
662 NOTREACHED(); | 692 NOTREACHED(); |
663 } | 693 } |
664 } | 694 } |
OLD | NEW |