Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: chrome/browser/ui/app_list/start_page_service.cc

Issue 2424563002: Replace FOR_EACH_OBSERVER in c/b/ui/app_list with range-based for (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/app_list_syncable_service.cc ('k') | chrome/browser/ui/app_list/test/fake_profile_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698