Commit 5a4f5742 authored by Michael Giuffrida's avatar Michael Giuffrida Committed by Commit Bot

Add chromeosInfoPrivate assistantStatus API

Adds a new "assistantStatus" property to chromeosInfoPrivate.get that
returns "[un]supported" depending on whether the device supports a
version of Google Assistant.

Bug: 856719
Test: browser_tests, manually with eve and another device
Change-Id: I947c7849bbb1f134dde7515e6ea40504d470d69c
Reviewed-on: https://chromium-review.googlesource.com/1157384
Commit-Queue: Michael Giuffrida <michaelpg@chromium.org>
Reviewed-by: default avatarToni Barzic <tbarzic@chromium.org>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581081}
parent ce9e5273
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "chrome/browser/chromeos/system/timezone_util.h" #include "chrome/browser/chromeos/system/timezone_util.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/network/device_state.h" #include "chromeos/network/device_state.h"
#include "chromeos/network/network_handler.h" #include "chromeos/network/network_handler.h"
#include "chromeos/network/network_state_handler.h" #include "chromeos/network/network_state_handler.h"
...@@ -185,6 +186,17 @@ const char kStylusStatusSupported[] = "supported"; ...@@ -185,6 +186,17 @@ const char kStylusStatusSupported[] = "supported";
// stylus or a stylus has been seen before. // stylus or a stylus has been seen before.
const char kStylusStatusSeen[] = "seen"; const char kStylusStatusSeen[] = "seen";
// Key which corresponds to the assistantStatus property in JS.
const char kPropertyAssistantStatus[] = "assistantStatus";
// Value to which assistantStatus property is set when the device does not
// support Assistant.
const char kAssistantStatusUnsupported[] = "unsupported";
// Value to which assistantStatus property is set when the device supports
// Assistant.
const char kAssistantStatusSupported[] = "supported";
const struct { const struct {
const char* api_name; const char* api_name;
const char* preference_name; const char* preference_name;
...@@ -362,6 +374,12 @@ std::unique_ptr<base::Value> ChromeosInfoPrivateGetFunction::GetValue( ...@@ -362,6 +374,12 @@ std::unique_ptr<base::Value> ChromeosInfoPrivateGetFunction::GetValue(
: kStylusStatusSupported); : kStylusStatusSupported);
} }
if (property_name == kPropertyAssistantStatus) {
return std::make_unique<base::Value>(
chromeos::switches::IsAssistantEnabled() ? kAssistantStatusSupported
: kAssistantStatusUnsupported);
}
if (property_name == kPropertyClientId) { if (property_name == kPropertyClientId) {
return std::make_unique<base::Value>(GetClientId()); return std::make_unique<base::Value>(GetClientId());
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "ash/public/cpp/ash_switches.h" #include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/stylus_utils.h" #include "ash/public/cpp/stylus_utils.h"
#include "base/sys_info.h" #include "base/sys_info.h"
#include "base/test/scoped_feature_list.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/chromeos/arc/arc_util.h" #include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
...@@ -15,6 +16,7 @@ ...@@ -15,6 +16,7 @@
#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/browser_window.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/settings/cros_settings_names.h" #include "chromeos/settings/cros_settings_names.h"
#include "components/arc/arc_util.h" #include "components/arc/arc_util.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
...@@ -137,6 +139,26 @@ IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, UnknownDeviceType) { ...@@ -137,6 +139,26 @@ IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, UnknownDeviceType) {
<< message_; << message_;
} }
IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, AssistantSupported) {
// Enable native Assistant.
base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(chromeos::switches::kAssistantFeature);
ASSERT_TRUE(RunPlatformAppTestWithArg("chromeos_info_private/extended",
"assistant supported"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, AssistantUnsupported) {
// Disable native Assistant.
base::test::ScopedFeatureList feature_list;
feature_list.InitAndDisableFeature(chromeos::switches::kAssistantFeature);
ASSERT_TRUE(RunPlatformAppTestWithArg("chromeos_info_private/extended",
"assistant unsupported"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, StylusUnsupported) { IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, StylusUnsupported) {
ASSERT_TRUE(RunPlatformAppTestWithArg("chromeos_info_private/extended", ASSERT_TRUE(RunPlatformAppTestWithArg("chromeos_info_private/extended",
"stylus unsupported")) "stylus unsupported"))
......
...@@ -59,6 +59,12 @@ ...@@ -59,6 +59,12 @@
"type": "string", "type": "string",
"enum": ["unsupported", "supported", "seen"], "enum": ["unsupported", "supported", "seen"],
"description": "Status of stylus." "description": "Status of stylus."
},
{
"id": "AssistantStatus",
"type": "string",
"enum": ["unsupported", "supported"],
"description": "Status of Google Assistant."
} }
], ],
"functions": [ "functions": [
...@@ -93,6 +99,7 @@ ...@@ -93,6 +99,7 @@
"managedDeviceStatus": {"$ref": "ManagedDeviceStatus", "optional": true}, "managedDeviceStatus": {"$ref": "ManagedDeviceStatus", "optional": true},
"deviceType": {"$ref": "DeviceType", "optional": true}, "deviceType": {"$ref": "DeviceType", "optional": true},
"stylusStatus": {"$ref": "StylusStatus", "optional": true}, "stylusStatus": {"$ref": "StylusStatus", "optional": true},
"assistantStatus": {"$ref": "AssistantStatus", "optional": true},
"clientId" : {"type": "string", "optional": true, "description": "Device client id"}, "clientId" : {"type": "string", "optional": true, "description": "Device client id"},
"timezone" : {"type": "string", "optional": true, "description": "Timezone"}, "timezone" : {"type": "string", "optional": true, "description": "Timezone"},
"a11yLargeCursorEnabled" : {"type": "boolean", "optional": true, "description": "If true, ChromeOS is showing enlarged cursor."}, "a11yLargeCursorEnabled" : {"type": "boolean", "optional": true, "description": "If true, ChromeOS is showing enlarged cursor."},
......
...@@ -15,6 +15,7 @@ chrome.app.runtime.onLaunched.addListener(function() { ...@@ -15,6 +15,7 @@ chrome.app.runtime.onLaunched.addListener(function() {
'managedDeviceStatus', 'managedDeviceStatus',
'deviceType', 'deviceType',
'stylusStatus', 'stylusStatus',
'assistantStatus',
], chrome.test.callbackPass(function(values) { ], chrome.test.callbackPass(function(values) {
switch (testName) { switch (testName) {
case 'kiosk': case 'kiosk':
...@@ -56,6 +57,12 @@ chrome.app.runtime.onLaunched.addListener(function() { ...@@ -56,6 +57,12 @@ chrome.app.runtime.onLaunched.addListener(function() {
case 'stylus seen': case 'stylus seen':
chrome.test.assertEq('seen', values['stylusStatus']); chrome.test.assertEq('seen', values['stylusStatus']);
break; break;
case 'assistant unsupported':
chrome.test.assertEq('unsupported', values['assistantStatus']);
break;
case 'assistant supported':
chrome.test.assertEq('supported', values['assistantStatus']);
break;
} }
})); }));
}); });
......
...@@ -27,11 +27,11 @@ const char kTestCrosGaiaIdMigration[] = "test-cros-gaia-id-migration"; ...@@ -27,11 +27,11 @@ const char kTestCrosGaiaIdMigration[] = "test-cros-gaia-id-migration";
// all stored user keys will be converted to GaiaId) // all stored user keys will be converted to GaiaId)
const char kTestCrosGaiaIdMigrationStarted[] = "started"; const char kTestCrosGaiaIdMigrationStarted[] = "started";
// Controls whether enable assistant for locale. // Controls whether to enable assistant for locale.
const base::Feature kAssistantFeatureForLocale{ const base::Feature kAssistantFeatureForLocale{
"ChromeOSAssistantForLocale", base::FEATURE_DISABLED_BY_DEFAULT}; "ChromeOSAssistantForLocale", base::FEATURE_DISABLED_BY_DEFAULT};
// Controls whether enable voice interaction feature. // Controls whether to enable voice interaction feature.
const base::Feature kVoiceInteractionFeature{"ChromeOSVoiceInteraction", const base::Feature kVoiceInteractionFeature{"ChromeOSVoiceInteraction",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
...@@ -47,7 +47,7 @@ const base::Feature kInstantTetheringBackgroundAdvertisementSupport{ ...@@ -47,7 +47,7 @@ const base::Feature kInstantTetheringBackgroundAdvertisementSupport{
const base::Feature kAccountManager{"ChromeOSAccountManager", const base::Feature kAccountManager{"ChromeOSAccountManager",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
// Controls whether enable Google Assistant feature. // Controls whether to enable Google Assistant feature.
const base::Feature kAssistantFeature{"ChromeOSAssistant", const base::Feature kAssistantFeature{"ChromeOSAssistant",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
......
...@@ -168,7 +168,7 @@ CHROMEOS_EXPORT extern const char kWakeOnWifiPacket[]; ...@@ -168,7 +168,7 @@ CHROMEOS_EXPORT extern const char kWakeOnWifiPacket[];
// Controls whether to enable Chrome OS Account Manager. // Controls whether to enable Chrome OS Account Manager.
CHROMEOS_EXPORT extern const base::Feature kAccountManager; CHROMEOS_EXPORT extern const base::Feature kAccountManager;
// Controls whether enable Google Assistant feature. // Controls whether to enable Google Assistant feature.
CHROMEOS_EXPORT extern const base::Feature kAssistantFeature; CHROMEOS_EXPORT extern const base::Feature kAssistantFeature;
// Returns true if the system should wake in response to wifi traffic. // Returns true if the system should wake in response to wifi traffic.
......
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