| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/api/hotword_private/hotword_private_api.h" | 5 #include "chrome/browser/extensions/api/hotword_private/hotword_private_api.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 scoped_ptr<api::hotword_private::SetEnabled::Params> params( | 87 scoped_ptr<api::hotword_private::SetEnabled::Params> params( |
| 88 api::hotword_private::SetEnabled::Params::Create(*args_)); | 88 api::hotword_private::SetEnabled::Params::Create(*args_)); |
| 89 EXTENSION_FUNCTION_VALIDATE(params.get()); | 89 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 90 | 90 |
| 91 PrefService* prefs = GetProfile()->GetPrefs(); | 91 PrefService* prefs = GetProfile()->GetPrefs(); |
| 92 prefs->SetBoolean(prefs::kHotwordSearchEnabled, params->state); | 92 prefs->SetBoolean(prefs::kHotwordSearchEnabled, params->state); |
| 93 return true; | 93 return true; |
| 94 } | 94 } |
| 95 | 95 |
| 96 bool HotwordPrivateSetAudioLoggingEnabledFunction::RunSync() { | 96 bool HotwordPrivateSetAudioLoggingEnabledFunction::RunSync() { |
| 97 scoped_ptr<api::hotword_private::SetEnabled::Params> params( | 97 scoped_ptr<api::hotword_private::SetAudioLoggingEnabled::Params> params( |
| 98 api::hotword_private::SetEnabled::Params::Create(*args_)); | 98 api::hotword_private::SetAudioLoggingEnabled::Params::Create(*args_)); |
| 99 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 100 |
| 101 // TODO(kcarattini): Sync the chrome pref with the account-level |
| 102 // Audio History setting. |
| 103 PrefService* prefs = GetProfile()->GetPrefs(); |
| 104 prefs->SetBoolean(prefs::kHotwordAudioLoggingEnabled, params->state); |
| 105 return true; |
| 106 } |
| 107 |
| 108 bool HotwordPrivateSetHotwordAlwaysOnSearchEnabledFunction::RunSync() { |
| 109 scoped_ptr<api::hotword_private::SetHotwordAlwaysOnSearchEnabled::Params> |
| 110 params(api::hotword_private::SetHotwordAlwaysOnSearchEnabled::Params:: |
| 111 Create(*args_)); |
| 99 EXTENSION_FUNCTION_VALIDATE(params.get()); | 112 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 100 | 113 |
| 101 PrefService* prefs = GetProfile()->GetPrefs(); | 114 PrefService* prefs = GetProfile()->GetPrefs(); |
| 102 prefs->SetBoolean(prefs::kHotwordAudioLoggingEnabled, params->state); | 115 prefs->SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled, params->state); |
| 103 return true; | 116 return true; |
| 104 } | 117 } |
| 105 | 118 |
| 106 bool HotwordPrivateGetStatusFunction::RunSync() { | 119 bool HotwordPrivateGetStatusFunction::RunSync() { |
| 107 api::hotword_private::StatusDetails result; | 120 api::hotword_private::StatusDetails result; |
| 108 | 121 |
| 109 HotwordService* hotword_service = | 122 HotwordService* hotword_service = |
| 110 HotwordServiceFactory::GetForProfile(GetProfile()); | 123 HotwordServiceFactory::GetForProfile(GetProfile()); |
| 111 if (!hotword_service) | 124 if (!hotword_service) |
| 112 result.available = false; | 125 result.available = false; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } else { | 173 } else { |
| 161 result.launch_mode = | 174 result.launch_mode = |
| 162 hotword_service->GetHotwordAudioVerificationLaunchMode(); | 175 hotword_service->GetHotwordAudioVerificationLaunchMode(); |
| 163 } | 176 } |
| 164 | 177 |
| 165 SetResult(result.ToValue().release()); | 178 SetResult(result.ToValue().release()); |
| 166 return true; | 179 return true; |
| 167 } | 180 } |
| 168 | 181 |
| 169 } // namespace extensions | 182 } // namespace extensions |
| OLD | NEW |