Commit 6ec1aeb6 authored by Ahmed Fakhry's avatar Ahmed Fakhry Committed by Commit Bot

Copy whitelisted enabled features from sign-in screen to guest session

The AutoNightLight feature is enabled only on kohaku via the chromeos
session manager [1]. However, the session manager does not start the
guest session, and therefore, does not setup its command-line flags.

This CL adds the ability to copy a list of whitelisted features to
the guest session command-line if they are enabled in the current
session (the sign-in screen).

[1]: https://cs.corp.google.com/chromeos_public/src/platform2/login_manager/chrome_setup.cc?q=p:chromeos_+AutoNightLight&g=0&l=105

BUG=1044344
TEST=Make sure AutoNightLight is enabled on kohaku in guest sessions.

Change-Id: Ie18e9a0e98d4b54bcd753d3bdbb8ecd422fa16e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2013739
Commit-Queue: Ahmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734114}
parent 78873e58
......@@ -8,10 +8,12 @@
#include <vector>
#include "ash/public/cpp/app_list/app_list_switches.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/ash_switches.h"
#include "base/base_switches.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/memory/weak_ptr.h"
#include "base/process/launch.h"
#include "base/stl_util.h"
......@@ -221,6 +223,26 @@ void DeriveCommandLine(const GURL& start_url,
}
}
// Adds whitelisted features to |out_command_line| if they are enabled in the
// current session.
void DeriveEnabledFeatures(base::CommandLine* out_command_line) {
static const base::Feature* kForwardEnabledFeatures[] = {
&ash::features::kAutoNightLight,
};
std::vector<std::string> enabled_features;
for (const auto* feature : kForwardEnabledFeatures) {
if (base::FeatureList::IsEnabled(*feature))
enabled_features.push_back(feature->name);
}
if (enabled_features.empty())
return;
out_command_line->AppendSwitchASCII("enable-features",
base::JoinString(enabled_features, ","));
}
// Simulates a session manager restart by launching give command line
// and exit current process.
void ReLaunch(const base::CommandLine& command_line) {
......@@ -334,6 +356,7 @@ void GetOffTheRecordCommandLine(const GURL& start_url,
otr_switches.SetString(switches::kOobeGuestSession, std::string());
DeriveCommandLine(start_url, base_command_line, otr_switches, command_line);
DeriveEnabledFeatures(command_line);
}
void RestartChrome(const base::CommandLine& command_line) {
......
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