Commit 71f820a1 authored by Xiaohui Chen's avatar Xiaohui Chen Committed by Commit Bot

Disable assistant for child account

Bug: b:112857091
Test: locally build and test
Change-Id: I9deac6849662a48263966b01012553046f5aa328
Reviewed-on: https://chromium-review.googlesource.com/1182448Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Commit-Queue: Xiaohui Chen <xiaohuic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584799}
parent f2624f2c
......@@ -705,6 +705,7 @@ void HandleToggleVoiceInteraction(const ui::Accelerator& accelerator) {
case mojom::AssistantAllowedState::DISALLOWED_BY_ARC_DISALLOWED:
case mojom::AssistantAllowedState::DISALLOWED_BY_FLAG:
case mojom::AssistantAllowedState::DISALLOWED_BY_SUPERVISED_USER:
case mojom::AssistantAllowedState::DISALLOWED_BY_CHILD_USER:
case mojom::AssistantAllowedState::DISALLOWED_BY_INCOGNITO:
// TODO(xiaohuic): show a specific toast.
return;
......
......@@ -39,6 +39,8 @@ enum AssistantAllowedState {
DISALLOWED_BY_NONPRIMARY_USER,
// Disallowed because current user is supervised user.
DISALLOWED_BY_SUPERVISED_USER,
// Disallowed because current user is child user.
DISALLOWED_BY_CHILD_USER,
// Disallowed because incognito mode.
DISALLOWED_BY_INCOGNITO
};
......
......@@ -608,6 +608,9 @@ ash::mojom::AssistantAllowedState IsAssistantAllowedForProfile(
if (profile->IsLegacySupervised())
return ash::mojom::AssistantAllowedState::DISALLOWED_BY_SUPERVISED_USER;
if (profile->IsChild())
return ash::mojom::AssistantAllowedState::DISALLOWED_BY_CHILD_USER;
if (chromeos::switches::IsVoiceInteractionFlagsEnabled()) {
if (!chromeos::switches::IsVoiceInteractionLocalesSupported())
return ash::mojom::AssistantAllowedState::DISALLOWED_BY_LOCALE;
......
......@@ -27,6 +27,7 @@
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/policy/profile_policy_connector_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/supervised_user/supervised_user_constants.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
......@@ -585,6 +586,18 @@ TEST_F(ChromeArcUtilTest, IsAssistantAllowedForProfile_SupervisedUser) {
IsAssistantAllowedForProfile(profile()));
}
TEST_F(ChromeArcUtilTest, IsAssistantAllowedForProfile_ChildUser) {
base::CommandLine::ForCurrentProcess()->InitFromArgv(
{"", "--arc-availability=officially-supported",
"--enable-voice-interaction"});
ScopedLogIn login(GetFakeUserManager(),
AccountId::FromUserEmailGaiaId(
profile()->GetProfileUserName(), kTestGaiaId));
profile()->SetSupervisedUserId(supervised_users::kChildAccountSUID);
EXPECT_EQ(ash::mojom::AssistantAllowedState::DISALLOWED_BY_CHILD_USER,
IsAssistantAllowedForProfile(profile()));
}
TEST_F(ChromeArcUtilTest, IsAssistantAllowedForProfile_Locale) {
base::CommandLine::ForCurrentProcess()->InitFromArgv(
{"", "--arc-availability=officially-supported",
......
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