X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fchrome%2Fbrowser%2Fextensions%2Fapi%2Fhotword_private%2Fhotword_private_api.cc;h=2de65c89c42932bd1e8bd662cb6944e222dbd711;hb=3545e9f2671f595d2a2f3ee75ca0393b01e35ef6;hp=53f6170c75725d14147381f8c49cc5dd86482d9c;hpb=7d210d4c7e9ba36e635eabc5b5780495f8a63292;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/chrome/browser/extensions/api/hotword_private/hotword_private_api.cc b/src/chrome/browser/extensions/api/hotword_private/hotword_private_api.cc index 53f6170..2de65c8 100644 --- a/src/chrome/browser/extensions/api/hotword_private/hotword_private_api.cc +++ b/src/chrome/browser/extensions/api/hotword_private/hotword_private_api.cc @@ -17,6 +17,10 @@ namespace extensions { +namespace hotword_private_constants { +const char kHotwordServiceUnavailable[] = "Hotword Service is unavailable."; +} // hotword_private_constants + namespace OnEnabledChanged = api::hotword_private::OnEnabledChanged; @@ -32,6 +36,10 @@ HotwordPrivateEventService::HotwordPrivateEventService( prefs::kHotwordSearchEnabled, base::Bind(&HotwordPrivateEventService::OnEnabledChanged, base::Unretained(this))); + pref_change_registrar_.Add( + prefs::kHotwordAlwaysOnSearchEnabled, + base::Bind(&HotwordPrivateEventService::OnEnabledChanged, + base::Unretained(this))); } HotwordPrivateEventService::~HotwordPrivateEventService() { @@ -53,7 +61,8 @@ const char* HotwordPrivateEventService::service_name() { void HotwordPrivateEventService::OnEnabledChanged( const std::string& pref_name) { - DCHECK_EQ(pref_name, std::string(prefs::kHotwordSearchEnabled)); + DCHECK(pref_name == std::string(prefs::kHotwordSearchEnabled) || + pref_name == std::string(prefs::kHotwordAlwaysOnSearchEnabled)); SignalEvent(OnEnabledChanged::kEventName); } @@ -85,15 +94,28 @@ bool HotwordPrivateSetEnabledFunction::RunSync() { } bool HotwordPrivateSetAudioLoggingEnabledFunction::RunSync() { - scoped_ptr params( - api::hotword_private::SetEnabled::Params::Create(*args_)); + scoped_ptr params( + api::hotword_private::SetAudioLoggingEnabled::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); + // TODO(kcarattini): Sync the chrome pref with the account-level + // Audio History setting. PrefService* prefs = GetProfile()->GetPrefs(); prefs->SetBoolean(prefs::kHotwordAudioLoggingEnabled, params->state); return true; } +bool HotwordPrivateSetHotwordAlwaysOnSearchEnabledFunction::RunSync() { + scoped_ptr + params(api::hotword_private::SetHotwordAlwaysOnSearchEnabled::Params:: + Create(*args_)); + EXTENSION_FUNCTION_VALIDATE(params.get()); + + PrefService* prefs = GetProfile()->GetPrefs(); + prefs->SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled, params->state); + return true; +} + bool HotwordPrivateGetStatusFunction::RunSync() { api::hotword_private::StatusDetails result; @@ -107,6 +129,8 @@ bool HotwordPrivateGetStatusFunction::RunSync() { PrefService* prefs = GetProfile()->GetPrefs(); result.enabled_set = prefs->HasPrefPath(prefs::kHotwordSearchEnabled); result.enabled = prefs->GetBoolean(prefs::kHotwordSearchEnabled); + result.always_on_enabled = + prefs->GetBoolean(prefs::kHotwordAlwaysOnSearchEnabled); result.audio_logging_enabled = false; CommandLine* command_line = CommandLine::ForCurrentProcess(); result.experimental_hotword_enabled = command_line->HasSwitch( @@ -138,4 +162,21 @@ bool HotwordPrivateNotifyHotwordRecognitionFunction::RunSync() { return true; } +bool HotwordPrivateGetLaunchStateFunction::RunSync() { + api::hotword_private::LaunchState result; + + HotwordService* hotword_service = + HotwordServiceFactory::GetForProfile(GetProfile()); + if (!hotword_service) { + error_ = hotword_private_constants::kHotwordServiceUnavailable; + return false; + } else { + result.launch_mode = + hotword_service->GetHotwordAudioVerificationLaunchMode(); + } + + SetResult(result.ToValue().release()); + return true; +} + } // namespace extensions