Chromium Code Reviews| 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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 736 | 736 |
| 737 HotwordAudioHistoryHandler* HotwordService::GetAudioHistoryHandler() { | 737 HotwordAudioHistoryHandler* HotwordService::GetAudioHistoryHandler() { |
| 738 return audio_history_handler_.get(); | 738 return audio_history_handler_.get(); |
| 739 } | 739 } |
| 740 | 740 |
| 741 void HotwordService::SetAudioHistoryHandler( | 741 void HotwordService::SetAudioHistoryHandler( |
| 742 HotwordAudioHistoryHandler* handler) { | 742 HotwordAudioHistoryHandler* handler) { |
| 743 audio_history_handler_.reset(handler); | 743 audio_history_handler_.reset(handler); |
| 744 } | 744 } |
| 745 | 745 |
| 746 void HotwordService::DisableHotwordPreferences() { | |
| 747 if (IsSometimesOnEnabled()) { | |
| 748 if (profile_->GetPrefs()->HasPrefPath(prefs::kHotwordSearchEnabled)) | |
|
Dan Beam
2014/12/04 20:44:07
why do you need to check HasPrefPath?
rpetterson
2014/12/04 23:20:28
We have some special cases for if the user has not
| |
| 749 profile_->GetPrefs()->SetBoolean(prefs::kHotwordSearchEnabled, false); | |
| 750 } else if (IsAlwaysOnEnabled()) { | |
| 751 if (profile_->GetPrefs()->HasPrefPath( | |
| 752 prefs::kHotwordAlwaysOnSearchEnabled)) { | |
| 753 profile_->GetPrefs()->SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled, | |
| 754 false); | |
| 755 } | |
| 756 } | |
| 757 } | |
| 758 | |
| 746 void HotwordService::OnHotwordSearchEnabledChanged( | 759 void HotwordService::OnHotwordSearchEnabledChanged( |
| 747 const std::string& pref_name) { | 760 const std::string& pref_name) { |
| 748 DCHECK_EQ(pref_name, std::string(prefs::kHotwordSearchEnabled)); | 761 DCHECK_EQ(pref_name, std::string(prefs::kHotwordSearchEnabled)); |
| 749 | 762 |
| 750 ExtensionService* extension_service = GetExtensionService(profile_); | 763 ExtensionService* extension_service = GetExtensionService(profile_); |
| 751 if (profile_->GetPrefs()->GetBoolean(prefs::kHotwordSearchEnabled)) | 764 if (profile_->GetPrefs()->GetBoolean(prefs::kHotwordSearchEnabled)) |
| 752 EnableHotwordExtension(extension_service); | 765 EnableHotwordExtension(extension_service); |
| 753 else | 766 else |
| 754 DisableHotwordExtension(extension_service); | 767 DisableHotwordExtension(extension_service); |
| 755 } | 768 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 814 HotwordPrivateEventService* event_service = | 827 HotwordPrivateEventService* event_service = |
| 815 BrowserContextKeyedAPIFactory<HotwordPrivateEventService>::Get(profile_); | 828 BrowserContextKeyedAPIFactory<HotwordPrivateEventService>::Get(profile_); |
| 816 // "enabled" isn't being changed, but piggy-back off the notification anyway. | 829 // "enabled" isn't being changed, but piggy-back off the notification anyway. |
| 817 if (event_service) | 830 if (event_service) |
| 818 event_service->OnEnabledChanged(prefs::kHotwordSearchEnabled); | 831 event_service->OnEnabledChanged(prefs::kHotwordSearchEnabled); |
| 819 } | 832 } |
| 820 | 833 |
| 821 bool HotwordService::UserIsActive() { | 834 bool HotwordService::UserIsActive() { |
| 822 return profile_ == ProfileManager::GetActiveUserProfile(); | 835 return profile_ == ProfileManager::GetActiveUserProfile(); |
| 823 } | 836 } |
| OLD | NEW |