Commit 2e31d251 authored by Eyor Alemayehu's avatar Eyor Alemayehu Committed by Commit Bot

Disable screen context toggle in setup if disabled by administrator

A G-Suite user should not be able to do a screen context query if it is
disabled by the administrator. Therefore, we should not allow the
G-Suite user to enable screen context queries during the setup flow.

This is currently implemented by disabling the screen context toggle
and setting it to false.

Bug: 941818
Change-Id: I6bfff2387e2e2994e3358a5f24f621f70a9adfe6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1518062
Commit-Queue: Eyor Alemayehu <eyor@google.com>
Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#641120}
parent 55f6ecb9
...@@ -125,6 +125,9 @@ Polymer({ ...@@ -125,6 +125,9 @@ Polymer({
if (data['defaultEnabled']) { if (data['defaultEnabled']) {
toggle.setAttribute('checked', ''); toggle.setAttribute('checked', '');
} }
if (data['toggleDisabled']) {
toggle.disabled = true;
}
zippy.appendChild(toggle); zippy.appendChild(toggle);
var description = document.createElement('div'); var description = document.createElement('div');
......
...@@ -14,11 +14,36 @@ ...@@ -14,11 +14,36 @@
#include "chromeos/services/assistant/public/features.h" #include "chromeos/services/assistant/public/features.h"
#include "components/arc/arc_prefs.h" #include "components/arc/arc_prefs.h"
#include "components/consent_auditor/consent_auditor.h" #include "components/consent_auditor/consent_auditor.h"
#include "components/prefs/pref_service.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
#include "services/identity/public/cpp/identity_manager.h" #include "services/identity/public/cpp/identity_manager.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h" #include "ui/base/webui/web_ui_util.h"
namespace {
bool IsScreenContextDefaultEnabled(PrefService* prefs) {
const PrefService::Preference* pref =
prefs->FindPreference(arc::prefs::kVoiceInteractionContextEnabled);
if (pref->IsManaged()) {
return pref->GetValue()->GetBool();
}
if (pref->GetRecommendedValue()) {
return pref->GetRecommendedValue()->GetBool();
}
return true;
}
bool IsScreenContextToggleDisabled(PrefService* prefs) {
return prefs->IsManagedPreference(
arc::prefs::kVoiceInteractionContextEnabled);
}
} // namespace
namespace chromeos { namespace chromeos {
void RecordAssistantOptInStatus(AssistantOptInFlowStatus status) { void RecordAssistantOptInStatus(AssistantOptInFlowStatus status) {
...@@ -106,7 +131,8 @@ base::Value CreateDisclosureData(const SettingZippyList& disclosure_list) { ...@@ -106,7 +131,8 @@ base::Value CreateDisclosureData(const SettingZippyList& disclosure_list) {
// Helper method to create get more screen data. // Helper method to create get more screen data.
base::Value CreateGetMoreData(bool email_optin_needed, base::Value CreateGetMoreData(bool email_optin_needed,
const assistant::EmailOptInUi& email_optin_ui) { const assistant::EmailOptInUi& email_optin_ui,
PrefService* prefs) {
base::Value get_more_data(base::Value::Type::LIST); base::Value get_more_data(base::Value::Type::LIST);
if (!base::FeatureList::IsEnabled( if (!base::FeatureList::IsEnabled(
...@@ -135,7 +161,10 @@ base::Value CreateGetMoreData(bool email_optin_needed, ...@@ -135,7 +161,10 @@ base::Value CreateGetMoreData(bool email_optin_needed,
IDS_ASSISTANT_SCREEN_CONTEXT_TITLE))); IDS_ASSISTANT_SCREEN_CONTEXT_TITLE)));
context_data.SetKey("description", base::Value(l10n_util::GetStringUTF16( context_data.SetKey("description", base::Value(l10n_util::GetStringUTF16(
IDS_ASSISTANT_SCREEN_CONTEXT_DESC))); IDS_ASSISTANT_SCREEN_CONTEXT_DESC)));
context_data.SetKey("defaultEnabled", base::Value(true)); context_data.SetKey("defaultEnabled",
base::Value(IsScreenContextDefaultEnabled(prefs)));
context_data.SetKey("toggleDisabled",
base::Value(IsScreenContextToggleDisabled(prefs)));
context_data.SetKey( context_data.SetKey(
"iconUri", "iconUri",
base::Value("https://www.gstatic.com/images/icons/material/system/" base::Value("https://www.gstatic.com/images/icons/material/system/"
...@@ -230,5 +259,4 @@ bool IsHotwordDspAvailable() { ...@@ -230,5 +259,4 @@ bool IsHotwordDspAvailable() {
} }
return false; return false;
} }
} // namespace chromeos } // namespace chromeos
...@@ -7,12 +7,14 @@ ...@@ -7,12 +7,14 @@
#include <string> #include <string>
#include "base/callback.h"
#include "chrome/browser/profiles/profile.h"
#include "chromeos/services/assistant/public/mojom/constants.mojom.h"
#include "chromeos/services/assistant/public/proto/settings_ui.pb.h" #include "chromeos/services/assistant/public/proto/settings_ui.pb.h"
#include "components/prefs/pref_service.h"
#include "services/service_manager/public/cpp/connector.h" class PrefService;
class Profile;
namespace base {
class Value;
}
namespace chromeos { namespace chromeos {
...@@ -61,7 +63,8 @@ base::Value CreateDisclosureData(const SettingZippyList& disclosure_list); ...@@ -61,7 +63,8 @@ base::Value CreateDisclosureData(const SettingZippyList& disclosure_list);
// Helper method to create get more screen data. // Helper method to create get more screen data.
base::Value CreateGetMoreData(bool email_optin_needed, base::Value CreateGetMoreData(bool email_optin_needed,
const assistant::EmailOptInUi& email_optin_ui); const assistant::EmailOptInUi& email_optin_ui,
PrefService* prefs);
// Get string constants for settings ui. // Get string constants for settings ui.
base::Value GetSettingsUiStrings(const assistant::SettingsUi& settings_ui, base::Value GetSettingsUiStrings(const assistant::SettingsUi& settings_ui,
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/oobe_screen.h" #include "chrome/browser/chromeos/login/oobe_screen.h"
#include "chrome/browser/chromeos/login/screens/assistant_optin_flow_screen.h" #include "chrome/browser/chromeos/login/screens/assistant_optin_flow_screen.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/ash/assistant/assistant_pref_util.h" #include "chrome/browser/ui/ash/assistant/assistant_pref_util.h"
...@@ -23,6 +24,7 @@ ...@@ -23,6 +24,7 @@
#include "components/arc/arc_prefs.h" #include "components/arc/arc_prefs.h"
#include "components/login/localized_values_builder.h" #include "components/login/localized_values_builder.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/user_manager/user_manager.h"
#include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/connector.h"
namespace chromeos { namespace chromeos {
...@@ -351,8 +353,11 @@ void AssistantOptInFlowScreenHandler::OnGetSettingsResponse( ...@@ -351,8 +353,11 @@ void AssistantOptInFlowScreenHandler::OnGetSettingsResponse(
// Process get more data. // Process get more data.
email_optin_needed_ = settings_ui.has_email_opt_in_ui() && email_optin_needed_ = settings_ui.has_email_opt_in_ui() &&
settings_ui.email_opt_in_ui().has_title(); settings_ui.email_opt_in_ui().has_title();
auto* profile_helper = ProfileHelper::Get();
const auto* user = user_manager::UserManager::Get()->GetActiveUser();
auto get_more_data = auto get_more_data =
CreateGetMoreData(email_optin_needed_, settings_ui.email_opt_in_ui()); CreateGetMoreData(email_optin_needed_, settings_ui.email_opt_in_ui(),
profile_helper->GetProfileByUser(user)->GetPrefs());
bool skip_get_more = bool skip_get_more =
skip_third_party_disclosure && !get_more_data.GetList().size(); skip_third_party_disclosure && !get_more_data.GetList().size();
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h" #include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h"
#include "chromeos/constants/chromeos_switches.h" #include "chromeos/constants/chromeos_switches.h"
#include "chromeos/services/assistant/public/mojom/constants.mojom.h"
#include "components/arc/arc_prefs.h" #include "components/arc/arc_prefs.h"
#include "components/arc/arc_service_manager.h" #include "components/arc/arc_service_manager.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
......
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