Commit 254dfde3 authored by amistry's avatar amistry Committed by Commit bot

Expose always-on hotword preference via hotwordPrivate API.

BUG=397019

Review URL: https://codereview.chromium.org/555423002

Cr-Commit-Position: refs/heads/master@{#294314}
parent 8b58d10c
......@@ -32,6 +32,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 +57,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);
}
......@@ -107,6 +112,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(
......
......@@ -165,6 +165,25 @@ IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, IsAvailableFalse) {
EXPECT_TRUE(listener.WaitUntilSatisfied());
}
IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, AlwaysOnEnabled) {
{
ExtensionTestMessageListener listener("alwaysOnEnabled: false",
false);
ASSERT_TRUE(RunComponentExtensionTest("alwaysOnEnabled"))
<< message_;
EXPECT_TRUE(listener.WaitUntilSatisfied());
}
profile()->GetPrefs()->SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled, true);
{
ExtensionTestMessageListener listener("alwaysOnEnabled: true",
false);
ASSERT_TRUE(RunComponentExtensionTest("alwaysOnEnabled"))
<< message_;
EXPECT_TRUE(listener.WaitUntilSatisfied());
}
}
IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, ExperimentalHotwordEnabled) {
// Disabled by default.
ExtensionTestMessageListener listener("experimentalHotwordEnabled: false",
......@@ -196,6 +215,11 @@ IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, OnEnabledChanged) {
ExtensionTestMessageListener listenerNotification("notification", false);
profile()->GetPrefs()->SetBoolean(prefs::kHotwordSearchEnabled, true);
EXPECT_TRUE(listenerNotification.WaitUntilSatisfied());
listenerNotification.Reset();
profile()->GetPrefs()->SetBoolean(prefs::kHotwordAlwaysOnSearchEnabled,
true);
EXPECT_TRUE(listenerNotification.WaitUntilSatisfied());
}
IN_PROC_BROWSER_TEST_F(HotwordPrivateApiTest, HotwordSession) {
......
......@@ -30,6 +30,9 @@
// Whether experimental hotwording functionality is enabled. Mirrors the
// "enable-experimental-hotwording" flag.
boolean experimentalHotwordEnabled;
// Whether always-on hotwording is enabled.
boolean alwaysOnEnabled;
};
// The type of the recognized hotword. Right now it only has 'search' but
......
{
"key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDCXAxIB5iu+XGtMYYJgSwMrqO+zNa3FlWeMJLOV+U1T2VL6wDU3WD9YNlioI6a6wG49AFquEbRxQwwxlvAZC1c95LBvRlnQAkEVum0KbrJ8WHTxxDEPOfITE0J1AP5j8V0WQ9jbYvUxgefIPhDPXHpdPRAxDotygTrPa33x1075wIDAQAB",
"name": "Hotword Private Test Extension",
"version": "0.1",
"manifest_version": 2,
"description": "Browser tests for chrome.hotword_private API",
"background" : {
"scripts": ["test.js"]
},
"permissions": ["hotwordPrivate"]
}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.test.runTests([
function alwaysOnEnabled() {
chrome.hotwordPrivate.getStatus(
chrome.test.callbackPass(function(result) {
chrome.test.sendMessage("alwaysOnEnabled: " + result.alwaysOnEnabled);
}));
}
]);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment