Commit 4c1ccb06 authored by Toby Huang's avatar Toby Huang Committed by Commit Bot

Enable Happiness Tracking Surveys (HaTS) for supervised users

HaTS is currently already enabled for regular users and Googlers. This
CL enables HaTS for supervised users, with a survey that only has one
multiple choice satisfaction question about their ChromeOS experience.
The free form feedback text box in the regular user version has been
removed for privacy reasons.

Since supervised users can't use incognito mode, supervised users can
only view the survey once every 90 days due to cookie settings.

This CL implements the HaTS survey for supervised users in the legacy
HaTS 1 system. All three surveys will need to migrate to HaTS Next in
the near future.

Bug: 1050807
Change-Id: I7747569e1f768b85284149db11df752e3b8d0d7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2095774Reviewed-by: default avatarMalay Keshav <malaykeshav@chromium.org>
Commit-Queue: Toby Huang <tobyhuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749298}
parent 118d2cd8
...@@ -35,8 +35,11 @@ namespace { ...@@ -35,8 +35,11 @@ namespace {
const int kDefaultWidth = 400; const int kDefaultWidth = 400;
const int kDefaultHeight = 420; const int kDefaultHeight = 420;
// Site ID for HaTS survey. // Site ID for HaTS survey.
constexpr char kSiteID[] = "cs5lsagwwbho7l5cbbdniso22e"; constexpr char kRegularSiteID[] = "cs5lsagwwbho7l5cbbdniso22e";
constexpr char kGooglerSiteID[] = "z56p2hjy7pegxh3gmmur4qlwha"; constexpr char kGooglerSiteID[] = "z56p2hjy7pegxh3gmmur4qlwha";
// This version of the HaTS survey for supervised users doesn't have freeform
// text input for privacy reasons.
constexpr char kSupervisedUserSiteID[] = "dpqb5rzdxtsl3can53vaxlrvn4";
constexpr char kScriptSrcReplacementToken[] = "$SCRIPT_SRC"; constexpr char kScriptSrcReplacementToken[] = "$SCRIPT_SRC";
constexpr char kDoneButtonLabelReplacementToken[] = "$DONE_BUTTON_LABEL"; constexpr char kDoneButtonLabelReplacementToken[] = "$DONE_BUTTON_LABEL";
...@@ -116,6 +119,18 @@ std::string GetFormattedSiteContext(const std::string& user_locale, ...@@ -116,6 +119,18 @@ std::string GetFormattedSiteContext(const std::string& user_locale,
return base::JoinString(pairs, join_keyword); return base::JoinString(pairs, join_keyword);
} }
// Determine which HaTS survey to show the user.
const std::string GetSiteID(bool is_google_account) {
Profile* profile = ProfileManager::GetActiveUserProfile();
if (profile->IsChild()) {
return kSupervisedUserSiteID;
} else if (is_google_account) {
return kGooglerSiteID;
} else {
return kRegularSiteID;
}
}
} // namespace } // namespace
// static // static
...@@ -141,15 +156,18 @@ void HatsDialog::Show(bool is_google_account, const std::string& site_context) { ...@@ -141,15 +156,18 @@ void HatsDialog::Show(bool is_google_account, const std::string& site_context) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
// Load and set the html data that needs to be displayed in the dialog. // Load and set the html data that needs to be displayed in the dialog.
std::string site_id = is_google_account ? kGooglerSiteID : kSiteID; std::string site_id = GetSiteID(is_google_account);
std::string html_data = LoadLocalHtmlAsString(site_id, site_context); std::string html_data = LoadLocalHtmlAsString(site_id, site_context);
// Self deleting. // Self deleting.
auto* hats_dialog = new HatsDialog(html_data); auto* hats_dialog = new HatsDialog(html_data);
chrome::ShowWebDialog( // Supervised users don't have off the record profiles.
nullptr, ProfileManager::GetActiveUserProfile()->GetOffTheRecordProfile(), Profile* active_profile = ProfileManager::GetActiveUserProfile();
hats_dialog); Profile* profile_to_show = active_profile->IsChild()
? active_profile
: active_profile->GetOffTheRecordProfile();
chrome::ShowWebDialog(nullptr, profile_to_show, hats_dialog);
} }
HatsDialog::HatsDialog(const std::string& html_data) : html_data_(html_data) { HatsDialog::HatsDialog(const std::string& html_data) : html_data_(html_data) {
...@@ -189,6 +207,9 @@ std::string HatsDialog::GetDialogArgs() const { ...@@ -189,6 +207,9 @@ std::string HatsDialog::GetDialogArgs() const {
void HatsDialog::OnDialogClosed(const std::string& json_retval) { void HatsDialog::OnDialogClosed(const std::string& json_retval) {
delete this; delete this;
// TODO(crbug/1055644): Since supervised users can't use incognito mode, we
// need to manually delete the HaTS cookie so that these users can see the
// survey more than once.
} }
void HatsDialog::OnCloseContents(WebContents* source, bool* out_close_dialog) { void HatsDialog::OnCloseContents(WebContents* source, bool* out_close_dialog) {
......
...@@ -137,12 +137,6 @@ bool HatsNotificationController::ShouldShowSurveyToProfile(Profile* profile) { ...@@ -137,12 +137,6 @@ bool HatsNotificationController::ShouldShowSurveyToProfile(Profile* profile) {
if (profile->IsGuestSession()) if (profile->IsGuestSession())
return false; return false;
// Do not show survey if this is a child profile, for now. See crbug/1055022.
// TODO(crbug/1050807): remove this check after enabling HaTS for supervised
// users.
if (profile->IsChild())
return false;
const bool is_enterprise_enrolled = g_browser_process->platform_part() const bool is_enterprise_enrolled = g_browser_process->platform_part()
->browser_policy_connector_chromeos() ->browser_policy_connector_chromeos()
->IsEnterpriseManaged(); ->IsEnterpriseManaged();
...@@ -154,6 +148,8 @@ bool HatsNotificationController::ShouldShowSurveyToProfile(Profile* profile) { ...@@ -154,6 +148,8 @@ bool HatsNotificationController::ShouldShowSurveyToProfile(Profile* profile) {
// In an enterprise enrolled device, the user can never be the owner, hence // In an enterprise enrolled device, the user can never be the owner, hence
// only check for ownership on a non enrolled device. // only check for ownership on a non enrolled device.
// TODO(crbug/1060436): Remove the IsOwnerProfile() check so that HaTS is
// enabled for all users, not just device owners.
if (!is_enterprise_enrolled && !ProfileHelper::IsOwnerProfile(profile)) if (!is_enterprise_enrolled && !ProfileHelper::IsOwnerProfile(profile))
return false; return false;
......
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