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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 urls->push_back(extension->GetResourceURL(info->page)); | 151 urls->push_back(extension->GetResourceURL(info->page)); |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 } // namespace | 155 } // namespace |
156 | 156 |
157 AppListViewDelegate::AppListViewDelegate(AppListControllerDelegate* controller) | 157 AppListViewDelegate::AppListViewDelegate(AppListControllerDelegate* controller) |
158 : controller_(controller), | 158 : controller_(controller), |
159 profile_(NULL), | 159 profile_(NULL), |
160 model_(NULL), | 160 model_(NULL), |
| 161 is_voice_query_(false), |
161 scoped_observer_(this) { | 162 scoped_observer_(this) { |
162 // TODO(vadimt): Remove ScopedTracker below once crbug.com/431326 is fixed. | 163 // TODO(vadimt): Remove ScopedTracker below once crbug.com/431326 is fixed. |
163 tracked_objects::ScopedTracker tracking_profile( | 164 tracked_objects::ScopedTracker tracking_profile( |
164 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 165 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
165 "431326 AppListViewDelegate::AppListViewDelegate")); | 166 "431326 AppListViewDelegate::AppListViewDelegate")); |
166 | 167 |
167 CHECK(controller_); | 168 CHECK(controller_); |
168 // The SigninManagerFactor and the SigninManagers are observed to keep the | 169 // The SigninManagerFactor and the SigninManagers are observed to keep the |
169 // profile switcher menu up to date, with the correct list of profiles and the | 170 // profile switcher menu up to date, with the correct list of profiles and the |
170 // correct email address (or none for signed out users) for each. | 171 // correct email address (or none for signed out users) for each. |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 extension, | 423 extension, |
423 profile_, | 424 profile_, |
424 base::Bind(CreateShortcutInWebAppDir, app_data_dir, callback)); | 425 base::Bind(CreateShortcutInWebAppDir, app_data_dir, callback)); |
425 #else | 426 #else |
426 callback.Run(base::FilePath()); | 427 callback.Run(base::FilePath()); |
427 #endif | 428 #endif |
428 } | 429 } |
429 | 430 |
430 void AppListViewDelegate::StartSearch() { | 431 void AppListViewDelegate::StartSearch() { |
431 if (search_controller_) { | 432 if (search_controller_) { |
432 search_controller_->Start(); | 433 search_controller_->Start(is_voice_query_); |
433 controller_->OnSearchStarted(); | 434 controller_->OnSearchStarted(); |
434 } | 435 } |
435 } | 436 } |
436 | 437 |
437 void AppListViewDelegate::StopSearch() { | 438 void AppListViewDelegate::StopSearch() { |
438 if (search_controller_) | 439 if (search_controller_) |
439 search_controller_->Stop(); | 440 search_controller_->Stop(); |
440 } | 441 } |
441 | 442 |
442 void AppListViewDelegate::OpenSearchResult( | 443 void AppListViewDelegate::OpenSearchResult( |
(...skipping 12 matching lines...) Expand all Loading... |
455 search_controller_->InvokeResultAction(result, action_index, event_flags); | 456 search_controller_->InvokeResultAction(result, action_index, event_flags); |
456 } | 457 } |
457 | 458 |
458 base::TimeDelta AppListViewDelegate::GetAutoLaunchTimeout() { | 459 base::TimeDelta AppListViewDelegate::GetAutoLaunchTimeout() { |
459 return auto_launch_timeout_; | 460 return auto_launch_timeout_; |
460 } | 461 } |
461 | 462 |
462 void AppListViewDelegate::AutoLaunchCanceled() { | 463 void AppListViewDelegate::AutoLaunchCanceled() { |
463 base::RecordAction(base::UserMetricsAction("AppList_AutoLaunchCanceled")); | 464 base::RecordAction(base::UserMetricsAction("AppList_AutoLaunchCanceled")); |
464 auto_launch_timeout_ = base::TimeDelta(); | 465 auto_launch_timeout_ = base::TimeDelta(); |
| 466 // Cancelling the auto launch means we are no longer in a voice query. |
| 467 is_voice_query_ = false; |
465 } | 468 } |
466 | 469 |
467 void AppListViewDelegate::ViewInitialized() { | 470 void AppListViewDelegate::ViewInitialized() { |
468 app_list::StartPageService* service = | 471 app_list::StartPageService* service = |
469 app_list::StartPageService::Get(profile_); | 472 app_list::StartPageService::Get(profile_); |
470 if (service) { | 473 if (service) { |
471 service->AppListShown(); | 474 service->AppListShown(); |
472 if (service->HotwordEnabled()) { | 475 if (service->HotwordEnabled()) { |
473 HotwordService* hotword_service = | 476 HotwordService* hotword_service = |
474 HotwordServiceFactory::GetForProfile(profile_); | 477 HotwordServiceFactory::GetForProfile(profile_); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 const base::FilePath& profile_path) { | 582 const base::FilePath& profile_path) { |
580 controller_->ShowForProfileByPath(profile_path); | 583 controller_->ShowForProfileByPath(profile_path); |
581 } | 584 } |
582 | 585 |
583 void AppListViewDelegate::OnSpeechResult(const base::string16& result, | 586 void AppListViewDelegate::OnSpeechResult(const base::string16& result, |
584 bool is_final) { | 587 bool is_final) { |
585 speech_ui_->SetSpeechResult(result, is_final); | 588 speech_ui_->SetSpeechResult(result, is_final); |
586 if (is_final) { | 589 if (is_final) { |
587 auto_launch_timeout_ = base::TimeDelta::FromMilliseconds( | 590 auto_launch_timeout_ = base::TimeDelta::FromMilliseconds( |
588 kAutoLaunchDefaultTimeoutMilliSec); | 591 kAutoLaunchDefaultTimeoutMilliSec); |
| 592 is_voice_query_ = true; |
589 model_->search_box()->SetText(result); | 593 model_->search_box()->SetText(result); |
590 } | 594 } |
591 } | 595 } |
592 | 596 |
593 void AppListViewDelegate::OnSpeechSoundLevelChanged(int16 level) { | 597 void AppListViewDelegate::OnSpeechSoundLevelChanged(int16 level) { |
594 speech_ui_->UpdateSoundLevel(level); | 598 speech_ui_->UpdateSoundLevel(level); |
595 } | 599 } |
596 | 600 |
597 void AppListViewDelegate::OnSpeechRecognitionStateChanged( | 601 void AppListViewDelegate::OnSpeechRecognitionStateChanged( |
598 app_list::SpeechRecognitionState new_state) { | 602 app_list::SpeechRecognitionState new_state) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 | 739 |
736 // SigninManagerFactory is not a leaky singleton (unlike this class), and | 740 // SigninManagerFactory is not a leaky singleton (unlike this class), and |
737 // its destructor will check that it has no remaining observers. | 741 // its destructor will check that it has no remaining observers. |
738 scoped_observer_.RemoveAll(); | 742 scoped_observer_.RemoveAll(); |
739 SigninManagerFactory::GetInstance()->RemoveObserver(this); | 743 SigninManagerFactory::GetInstance()->RemoveObserver(this); |
740 break; | 744 break; |
741 default: | 745 default: |
742 NOTREACHED(); | 746 NOTREACHED(); |
743 } | 747 } |
744 } | 748 } |
OLD | NEW |