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

Side by Side Diff: chrome/browser/search/hotword_service.cc

Issue 1027683002: Hotword Private API: Add function and event to query the existence of a speaker model (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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/search/hotword_service.h" 5 #include "chrome/browser/search/hotword_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/i18n/case_conversion.h" 10 #include "base/i18n/case_conversion.h"
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 697
698 void HotwordService::DisableHotwordExtension( 698 void HotwordService::DisableHotwordExtension(
699 ExtensionService* extension_service) { 699 ExtensionService* extension_service) {
700 if (extension_service) { 700 if (extension_service) {
701 extension_service->DisableExtension( 701 extension_service->DisableExtension(
702 extension_misc::kHotwordExtensionId, 702 extension_misc::kHotwordExtensionId,
703 extensions::Extension::DISABLE_USER_ACTION); 703 extensions::Extension::DISABLE_USER_ACTION);
704 } 704 }
705 } 705 }
706 706
707 void HotwordService::SpeakerModelExistsComplete(bool exists) {
708 if (exists) {
709 profile_->GetPrefs()->
710 SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled, true);
711 } else {
712 LaunchHotwordAudioVerificationApp(HotwordService::HOTWORD_ONLY);
713 }
714 }
715
716 void HotwordService::OptIntoHotwording(
717 const LaunchMode& launch_mode) {
718 // First determine if we actually need to launch the app, or can just enable
719 // the pref. If Audio History has already been enabled, and we already have
720 // a speaker model, then we don't need to launch the app at all.
721 if (launch_mode == HotwordService::HOTWORD_ONLY) {
722 HotwordPrivateEventService* event_service =
723 BrowserContextKeyedAPIFactory<HotwordPrivateEventService>::Get(
724 profile_);
725 if (event_service) {
726 event_service->OnSpeakerModelExists();
727 return;
728 }
729 }
730
731 LaunchHotwordAudioVerificationApp(launch_mode);
732 }
733
707 void HotwordService::LaunchHotwordAudioVerificationApp( 734 void HotwordService::LaunchHotwordAudioVerificationApp(
708 const LaunchMode& launch_mode) { 735 const LaunchMode& launch_mode) {
709 hotword_audio_verification_launch_mode_ = launch_mode; 736 hotword_audio_verification_launch_mode_ = launch_mode;
710 737
711 ExtensionService* extension_service = GetExtensionService(profile_); 738 ExtensionService* extension_service = GetExtensionService(profile_);
712 if (!extension_service) 739 if (!extension_service)
713 return; 740 return;
714 const extensions::Extension* extension = extension_service->GetExtensionById( 741 const extensions::Extension* extension = extension_service->GetExtensionById(
715 extension_misc::kHotwordAudioVerificationAppId, true); 742 extension_misc::kHotwordAudioVerificationAppId, true);
716 if (!extension) 743 if (!extension)
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 // Only support multiple profiles and profile switching in ChromeOS. 911 // Only support multiple profiles and profile switching in ChromeOS.
885 if (user_manager::UserManager::IsInitialized()) { 912 if (user_manager::UserManager::IsInitialized()) {
886 user_manager::User* user = 913 user_manager::User* user =
887 user_manager::UserManager::Get()->GetActiveUser(); 914 user_manager::UserManager::Get()->GetActiveUser();
888 if (user && user->is_profile_created()) 915 if (user && user->is_profile_created())
889 return profile_ == ProfileManager::GetActiveUserProfile(); 916 return profile_ == ProfileManager::GetActiveUserProfile();
890 } 917 }
891 #endif 918 #endif
892 return true; 919 return true;
893 } 920 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698