| 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/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 Loading... |
| 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::MaybeLaunchHotwordAudioVerificationApp( |
| 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 // TODO(kcarattini): add this call once it's implemented in the API. |
| 727 // event_service->SpeakerModelExists(); |
| 728 return; |
| 729 } |
| 730 } |
| 731 |
| 732 LaunchHotwordAudioVerificationApp(launch_mode); |
| 733 } |
| 734 |
| 707 void HotwordService::LaunchHotwordAudioVerificationApp( | 735 void HotwordService::LaunchHotwordAudioVerificationApp( |
| 708 const LaunchMode& launch_mode) { | 736 const LaunchMode& launch_mode) { |
| 709 hotword_audio_verification_launch_mode_ = launch_mode; | 737 hotword_audio_verification_launch_mode_ = launch_mode; |
| 710 | 738 |
| 711 ExtensionService* extension_service = GetExtensionService(profile_); | 739 ExtensionService* extension_service = GetExtensionService(profile_); |
| 712 if (!extension_service) | 740 if (!extension_service) |
| 713 return; | 741 return; |
| 714 const extensions::Extension* extension = extension_service->GetExtensionById( | 742 const extensions::Extension* extension = extension_service->GetExtensionById( |
| 715 extension_misc::kHotwordAudioVerificationAppId, true); | 743 extension_misc::kHotwordAudioVerificationAppId, true); |
| 716 if (!extension) | 744 if (!extension) |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 // Only support multiple profiles and profile switching in ChromeOS. | 912 // Only support multiple profiles and profile switching in ChromeOS. |
| 885 if (user_manager::UserManager::IsInitialized()) { | 913 if (user_manager::UserManager::IsInitialized()) { |
| 886 user_manager::User* user = | 914 user_manager::User* user = |
| 887 user_manager::UserManager::Get()->GetActiveUser(); | 915 user_manager::UserManager::Get()->GetActiveUser(); |
| 888 if (user && user->is_profile_created()) | 916 if (user && user->is_profile_created()) |
| 889 return profile_ == ProfileManager::GetActiveUserProfile(); | 917 return profile_ == ProfileManager::GetActiveUserProfile(); |
| 890 } | 918 } |
| 891 #endif | 919 #endif |
| 892 return true; | 920 return true; |
| 893 } | 921 } |
| OLD | NEW |