| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/start_page_service.h" | 5 #include "chrome/browser/ui/app_list/start_page_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 } | 478 } |
| 479 return NULL; | 479 return NULL; |
| 480 } | 480 } |
| 481 | 481 |
| 482 void StartPageService::OnSpeechResult( | 482 void StartPageService::OnSpeechResult( |
| 483 const base::string16& query, bool is_final) { | 483 const base::string16& query, bool is_final) { |
| 484 if (is_final) { | 484 if (is_final) { |
| 485 speech_result_obtained_ = true; | 485 speech_result_obtained_ = true; |
| 486 RecordAction(UserMetricsAction("AppList_SearchedBySpeech")); | 486 RecordAction(UserMetricsAction("AppList_SearchedBySpeech")); |
| 487 } | 487 } |
| 488 FOR_EACH_OBSERVER(StartPageObserver, | 488 for (auto& observer : observers_) |
| 489 observers_, | 489 observer.OnSpeechResult(query, is_final); |
| 490 OnSpeechResult(query, is_final)); | |
| 491 } | 490 } |
| 492 | 491 |
| 493 void StartPageService::OnSpeechSoundLevelChanged(int16_t level) { | 492 void StartPageService::OnSpeechSoundLevelChanged(int16_t level) { |
| 494 FOR_EACH_OBSERVER(StartPageObserver, | 493 for (auto& observer : observers_) |
| 495 observers_, | 494 observer.OnSpeechSoundLevelChanged(level); |
| 496 OnSpeechSoundLevelChanged(level)); | |
| 497 } | 495 } |
| 498 | 496 |
| 499 void StartPageService::OnSpeechRecognitionStateChanged( | 497 void StartPageService::OnSpeechRecognitionStateChanged( |
| 500 SpeechRecognitionState new_state) { | 498 SpeechRecognitionState new_state) { |
| 501 #if defined(OS_CHROMEOS) | 499 #if defined(OS_CHROMEOS) |
| 502 // Sometimes this can be called even though there are no audio input devices. | 500 // Sometimes this can be called even though there are no audio input devices. |
| 503 if (audio_status_ && !audio_status_->CanListen()) | 501 if (audio_status_ && !audio_status_->CanListen()) |
| 504 new_state = SPEECH_RECOGNITION_OFF; | 502 new_state = SPEECH_RECOGNITION_OFF; |
| 505 #endif | 503 #endif |
| 506 if (!microphone_available_) | 504 if (!microphone_available_) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 525 } else { | 523 } else { |
| 526 RecordAction(UserMetricsAction("AppList_VoiceSearchStartedManually")); | 524 RecordAction(UserMetricsAction("AppList_VoiceSearchStartedManually")); |
| 527 } | 525 } |
| 528 } else if (InSpeechRecognition(state_) && !InSpeechRecognition(new_state) && | 526 } else if (InSpeechRecognition(state_) && !InSpeechRecognition(new_state) && |
| 529 !speech_result_obtained_) { | 527 !speech_result_obtained_) { |
| 530 RecordAction(UserMetricsAction("AppList_VoiceSearchCanceled")); | 528 RecordAction(UserMetricsAction("AppList_VoiceSearchCanceled")); |
| 531 } | 529 } |
| 532 speech_button_toggled_manually_ = false; | 530 speech_button_toggled_manually_ = false; |
| 533 speech_result_obtained_ = false; | 531 speech_result_obtained_ = false; |
| 534 state_ = new_state; | 532 state_ = new_state; |
| 535 FOR_EACH_OBSERVER(StartPageObserver, | 533 for (auto& observer : observers_) |
| 536 observers_, | 534 observer.OnSpeechRecognitionStateChanged(new_state); |
| 537 OnSpeechRecognitionStateChanged(new_state)); | |
| 538 } | 535 } |
| 539 | 536 |
| 540 void StartPageService::GetSpeechAuthParameters(std::string* auth_scope, | 537 void StartPageService::GetSpeechAuthParameters(std::string* auth_scope, |
| 541 std::string* auth_token) { | 538 std::string* auth_token) { |
| 542 HotwordService* service = HotwordServiceFactory::GetForProfile(profile_); | 539 HotwordService* service = HotwordServiceFactory::GetForProfile(profile_); |
| 543 if (service && | 540 if (service && |
| 544 service->IsOptedIntoAudioLogging() && | 541 service->IsOptedIntoAudioLogging() && |
| 545 service->IsAlwaysOnEnabled() && | 542 service->IsAlwaysOnEnabled() && |
| 546 !speech_auth_helper_->GetToken().empty()) { | 543 !speech_auth_helper_->GetToken().empty()) { |
| 547 *auth_scope = speech_auth_helper_->GetScope(); | 544 *auth_scope = speech_auth_helper_->GetScope(); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 | 683 |
| 687 // Check for a new doodle. | 684 // Check for a new doodle. |
| 688 content::BrowserThread::PostDelayedTask( | 685 content::BrowserThread::PostDelayedTask( |
| 689 content::BrowserThread::UI, FROM_HERE, | 686 content::BrowserThread::UI, FROM_HERE, |
| 690 base::Bind(&StartPageService::FetchDoodleJson, | 687 base::Bind(&StartPageService::FetchDoodleJson, |
| 691 weak_factory_.GetWeakPtr()), | 688 weak_factory_.GetWeakPtr()), |
| 692 recheck_delay); | 689 recheck_delay); |
| 693 } | 690 } |
| 694 | 691 |
| 695 } // namespace app_list | 692 } // namespace app_list |
| OLD | NEW |