Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 app_list::SpeechUIModel* AppListViewDelegate::GetSpeechUI() { | 274 app_list::SpeechUIModel* AppListViewDelegate::GetSpeechUI() { |
| 275 return speech_ui_.get(); | 275 return speech_ui_.get(); |
| 276 } | 276 } |
| 277 | 277 |
| 278 void AppListViewDelegate::StartSearch() { | 278 void AppListViewDelegate::StartSearch() { |
| 279 if (search_controller_) { | 279 if (search_controller_) { |
| 280 search_controller_->Start(is_voice_query_); | 280 search_controller_->Start(is_voice_query_); |
| 281 controller_->OnSearchStarted(); | 281 controller_->OnSearchStarted(); |
| 282 } | 282 } |
| 283 if (search_answer_delegate_) | 283 if (search_answer_delegate_) |
| 284 search_answer_delegate_->Update(); | 284 search_answer_delegate_->Update(is_voice_query_); |
| 285 } | 285 } |
| 286 | 286 |
| 287 void AppListViewDelegate::StopSearch() { | 287 void AppListViewDelegate::StopSearch() { |
| 288 if (search_controller_) | 288 if (search_controller_) |
| 289 search_controller_->Stop(); | 289 search_controller_->Stop(); |
| 290 } | 290 } |
| 291 | 291 |
| 292 void AppListViewDelegate::OpenSearchResult( | 292 void AppListViewDelegate::OpenSearchResult( |
| 293 app_list::SearchResult* result, | 293 app_list::SearchResult* result, |
| 294 bool auto_launch, | 294 bool auto_launch, |
| 295 int event_flags) { | 295 int event_flags) { |
| 296 if (auto_launch) | 296 if (auto_launch) |
| 297 base::RecordAction(base::UserMetricsAction("AppList_AutoLaunched")); | 297 base::RecordAction(base::UserMetricsAction("AppList_AutoLaunched")); |
| 298 search_controller_->OpenResult(result, event_flags); | 298 search_controller_->OpenResult(result, event_flags); |
| 299 is_voice_query_ = false; | 299 is_voice_query_ = false; |
| 300 model_->search_box()->SetText(base::string16()); | |
|
xiyuan
2017/04/27 21:59:30
Is this necessary? This would trigger another Star
vadimt
2017/04/27 22:14:37
This is a fundamentally correct thing to do.
We sh
xiyuan
2017/04/27 22:29:20
It will cause searches in other search providers.
vadimt
2017/04/29 00:48:28
Done.
Moved is_voice_query_ from AppListViewDelega
| |
| 300 } | 301 } |
| 301 | 302 |
| 302 void AppListViewDelegate::InvokeSearchResultAction( | 303 void AppListViewDelegate::InvokeSearchResultAction( |
| 303 app_list::SearchResult* result, | 304 app_list::SearchResult* result, |
| 304 int action_index, | 305 int action_index, |
| 305 int event_flags) { | 306 int event_flags) { |
| 306 search_controller_->InvokeResultAction(result, action_index, event_flags); | 307 search_controller_->InvokeResultAction(result, action_index, event_flags); |
| 307 } | 308 } |
| 308 | 309 |
| 309 base::TimeDelta AppListViewDelegate::GetAutoLaunchTimeout() { | 310 base::TimeDelta AppListViewDelegate::GetAutoLaunchTimeout() { |
| 310 return auto_launch_timeout_; | 311 return auto_launch_timeout_; |
| 311 } | 312 } |
| 312 | 313 |
| 313 void AppListViewDelegate::AutoLaunchCanceled() { | 314 void AppListViewDelegate::AutoLaunchCanceled() { |
| 314 if (is_voice_query_) { | 315 if (is_voice_query_) { |
| 315 base::RecordAction(base::UserMetricsAction("AppList_AutoLaunchCanceled")); | 316 base::RecordAction(base::UserMetricsAction("AppList_AutoLaunchCanceled")); |
| 316 // Cancelling the auto launch means we are no longer in a voice query. | 317 // Cancelling the auto launch means we are no longer in a voice query. |
| 317 is_voice_query_ = false; | 318 is_voice_query_ = false; |
| 319 model_->search_box()->SetText(base::string16()); | |
| 318 } | 320 } |
| 319 auto_launch_timeout_ = base::TimeDelta(); | 321 auto_launch_timeout_ = base::TimeDelta(); |
| 320 } | 322 } |
| 321 | 323 |
| 322 void AppListViewDelegate::ViewInitialized() { | 324 void AppListViewDelegate::ViewInitialized() { |
| 323 app_list::StartPageService* service = | 325 app_list::StartPageService* service = |
| 324 app_list::StartPageService::Get(profile_); | 326 app_list::StartPageService::Get(profile_); |
| 325 if (service) { | 327 if (service) { |
| 326 service->AppListShown(); | 328 service->AppListShown(); |
| 327 if (service->HotwordEnabled()) { | 329 if (service->HotwordEnabled()) { |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 524 TemplateURLService* template_url_service = | 526 TemplateURLService* template_url_service = |
| 525 TemplateURLServiceFactory::GetForProfile(profile_); | 527 TemplateURLServiceFactory::GetForProfile(profile_); |
| 526 const TemplateURL* default_provider = | 528 const TemplateURL* default_provider = |
| 527 template_url_service->GetDefaultSearchProvider(); | 529 template_url_service->GetDefaultSearchProvider(); |
| 528 bool is_google = | 530 bool is_google = |
| 529 default_provider->GetEngineType( | 531 default_provider->GetEngineType( |
| 530 template_url_service->search_terms_data()) == | 532 template_url_service->search_terms_data()) == |
| 531 SEARCH_ENGINE_GOOGLE; | 533 SEARCH_ENGINE_GOOGLE; |
| 532 | 534 |
| 533 model_->SetSearchEngineIsGoogle(is_google); | 535 model_->SetSearchEngineIsGoogle(is_google); |
| 534 search_answer_delegate_->Update(); | 536 search_answer_delegate_->Update(is_voice_query_); |
| 535 | 537 |
| 536 app_list::StartPageService* start_page_service = | 538 app_list::StartPageService* start_page_service = |
| 537 app_list::StartPageService::Get(profile_); | 539 app_list::StartPageService::Get(profile_); |
| 538 if (start_page_service) | 540 if (start_page_service) |
| 539 start_page_service->set_search_engine_is_google(is_google); | 541 start_page_service->set_search_engine_is_google(is_google); |
| 540 } | 542 } |
| 541 | 543 |
| 542 void AppListViewDelegate::Observe(int type, | 544 void AppListViewDelegate::Observe(int type, |
| 543 const content::NotificationSource& source, | 545 const content::NotificationSource& source, |
| 544 const content::NotificationDetails& details) { | 546 const content::NotificationDetails& details) { |
| 545 DCHECK_EQ(chrome::NOTIFICATION_APP_TERMINATING, type); | 547 DCHECK_EQ(chrome::NOTIFICATION_APP_TERMINATING, type); |
| 546 | 548 |
| 547 SetProfile(nullptr); // Ensures launcher page web contents are torn down. | 549 SetProfile(nullptr); // Ensures launcher page web contents are torn down. |
| 548 } | 550 } |
| OLD | NEW |