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

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

Issue 800523002: [Hotword] Sync Audio History pref every 24 hours, when opening chrome://settings and . . . (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 218
219 // Overridden from NotificationDelegate: 219 // Overridden from NotificationDelegate:
220 void ButtonClick(int button_index) override { 220 void ButtonClick(int button_index) override {
221 DCHECK_EQ(0, button_index); 221 DCHECK_EQ(0, button_index);
222 222
223 // Launch the hotword audio verification app in the right mode. 223 // Launch the hotword audio verification app in the right mode.
224 HotwordService::LaunchMode launch_mode = 224 HotwordService::LaunchMode launch_mode =
225 HotwordService::HOTWORD_AND_AUDIO_HISTORY; 225 HotwordService::HOTWORD_AND_AUDIO_HISTORY;
226 if (profile_->GetPrefs()->GetBoolean( 226 if (profile_->GetPrefs()->GetBoolean(
227 prefs::kHotwordAudioLoggingEnabled)) { 227 prefs::kHotwordAudioLoggingEnabled)) {
228 // TODO(rlp): Make sure the Chrome Audio History pref is synced
229 // to the account-level Audio History setting from footprints.
230 launch_mode = HotwordService::HOTWORD_ONLY; 228 launch_mode = HotwordService::HOTWORD_ONLY;
231 } 229 }
232 230
233 HotwordService* hotword_service = 231 HotwordService* hotword_service =
234 HotwordServiceFactory::GetForProfile(profile_); 232 HotwordServiceFactory::GetForProfile(profile_);
235 233
236 if (!hotword_service) 234 if (!hotword_service)
237 return; 235 return;
238 236
239 hotword_service->LaunchHotwordAudioVerificationApp(launch_mode); 237 hotword_service->LaunchHotwordAudioVerificationApp(launch_mode);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 &HotwordService::MaybeReinstallHotwordExtension), 339 &HotwordService::MaybeReinstallHotwordExtension),
342 weak_factory_.GetWeakPtr())); 340 weak_factory_.GetWeakPtr()));
343 341
344 // Clear the old user pref because it became unusable. 342 // Clear the old user pref because it became unusable.
345 // TODO(rlp): Remove this code per crbug.com/358789. 343 // TODO(rlp): Remove this code per crbug.com/358789.
346 if (profile_->GetPrefs()->HasPrefPath( 344 if (profile_->GetPrefs()->HasPrefPath(
347 hotword_internal::kHotwordUnusablePrefName)) { 345 hotword_internal::kHotwordUnusablePrefName)) {
348 profile_->GetPrefs()->ClearPref(hotword_internal::kHotwordUnusablePrefName); 346 profile_->GetPrefs()->ClearPref(hotword_internal::kHotwordUnusablePrefName);
349 } 347 }
350 348
351 audio_history_handler_.reset(new HotwordAudioHistoryHandler(profile_)); 349 SetAudioHistoryHandler(new HotwordAudioHistoryHandler(
350 profile_, base::MessageLoop::current()->task_runner()));
352 351
353 if (HotwordServiceFactory::IsHotwordHardwareAvailable() && 352 if (HotwordServiceFactory::IsHotwordHardwareAvailable() &&
354 IsHotwordAllowed() && 353 IsHotwordAllowed() &&
355 IsExperimentalHotwordingEnabled()) { 354 IsExperimentalHotwordingEnabled()) {
356 // Show the hotword notification in 5 seconds if the experimental flag is 355 // Show the hotword notification in 5 seconds if the experimental flag is
357 // on, or in 30 minutes if not. We need to wait at least a few seconds 356 // on, or in 30 minutes if not. We need to wait at least a few seconds
358 // for the hotword extension to be installed. 357 // for the hotword extension to be installed.
359 CommandLine* command_line = CommandLine::ForCurrentProcess(); 358 CommandLine* command_line = CommandLine::ForCurrentProcess();
360 if (command_line->HasSwitch(switches::kEnableExperimentalHotwordHardware)) { 359 if (command_line->HasSwitch(switches::kEnableExperimentalHotwordHardware)) {
361 base::MessageLoop::current()->PostDelayedTask( 360 base::MessageLoop::current()->PostDelayedTask(
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 return training_; 738 return training_;
740 } 739 }
741 740
742 HotwordAudioHistoryHandler* HotwordService::GetAudioHistoryHandler() { 741 HotwordAudioHistoryHandler* HotwordService::GetAudioHistoryHandler() {
743 return audio_history_handler_.get(); 742 return audio_history_handler_.get();
744 } 743 }
745 744
746 void HotwordService::SetAudioHistoryHandler( 745 void HotwordService::SetAudioHistoryHandler(
747 HotwordAudioHistoryHandler* handler) { 746 HotwordAudioHistoryHandler* handler) {
748 audio_history_handler_.reset(handler); 747 audio_history_handler_.reset(handler);
748 audio_history_handler_->UpdateAudioHistoryState();
749 } 749 }
750 750
751 void HotwordService::DisableHotwordPreferences() { 751 void HotwordService::DisableHotwordPreferences() {
752 if (IsSometimesOnEnabled()) { 752 if (IsSometimesOnEnabled()) {
753 if (profile_->GetPrefs()->HasPrefPath(prefs::kHotwordSearchEnabled)) 753 if (profile_->GetPrefs()->HasPrefPath(prefs::kHotwordSearchEnabled))
754 profile_->GetPrefs()->SetBoolean(prefs::kHotwordSearchEnabled, false); 754 profile_->GetPrefs()->SetBoolean(prefs::kHotwordSearchEnabled, false);
755 } else if (IsAlwaysOnEnabled()) { 755 } else if (IsAlwaysOnEnabled()) {
756 if (profile_->GetPrefs()->HasPrefPath( 756 if (profile_->GetPrefs()->HasPrefPath(
757 prefs::kHotwordAlwaysOnSearchEnabled)) { 757 prefs::kHotwordAlwaysOnSearchEnabled)) {
758 profile_->GetPrefs()->SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled, 758 profile_->GetPrefs()->SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 // Only support multiple profiles and profile switching in ChromeOS. 841 // Only support multiple profiles and profile switching in ChromeOS.
842 if (user_manager::UserManager::IsInitialized()) { 842 if (user_manager::UserManager::IsInitialized()) {
843 user_manager::User* user = 843 user_manager::User* user =
844 user_manager::UserManager::Get()->GetActiveUser(); 844 user_manager::UserManager::Get()->GetActiveUser();
845 if (user && user->is_profile_created()) 845 if (user && user->is_profile_created())
846 return profile_ == ProfileManager::GetActiveUserProfile(); 846 return profile_ == ProfileManager::GetActiveUserProfile();
847 } 847 }
848 #endif 848 #endif
849 return true; 849 return true;
850 } 850 }
OLDNEW
« no previous file with comments | « chrome/browser/search/hotword_audio_history_handler.cc ('k') | chrome/browser/search/hotword_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698