Commit f3a9cf05 authored by David Roger's avatar David Roger Committed by Chromium LUCI CQ

[Profile Picker] Add remote kill switch for showing on startup

This CL also fixes the policy which was intended to disable the picker
at startup.

Change-Id: I12e387259e862dff8235d22bc1696e843ab6b2bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2624675
Commit-Queue: David Roger <droger@chromium.org>
Commit-Queue: Yann Dago <ydago@chromium.org>
Auto-Submit: David Roger <droger@chromium.org>
Reviewed-by: default avatarAlex Ilin <alexilin@chromium.org>
Reviewed-by: default avatarYann Dago <ydago@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842693}
parent fc9a1d97
......@@ -7,7 +7,6 @@
#include <algorithm>
#include <string>
#include "base/feature_list.h"
#include "base/metrics/histogram_functions.h"
#include "base/time/time.h"
#include "chrome/browser/browser_process.h"
......@@ -50,6 +49,9 @@ ProfilePicker::AvailabilityOnStartup GetAvailabilityOnStartup() {
} // namespace
const base::Feature kEnableProfilePickerOnStartupFeature{
"EnableProfilePickerOnStartup", base::FEATURE_ENABLED_BY_DEFAULT};
// static
bool ProfilePicker::ShouldShowAtLaunch() {
AvailabilityOnStartup availability_on_startup = GetAvailabilityOnStartup();
......@@ -57,6 +59,12 @@ bool ProfilePicker::ShouldShowAtLaunch() {
if (!base::FeatureList::IsEnabled(features::kNewProfilePicker))
return false;
if (!base::FeatureList::IsEnabled(kEnableProfilePickerOnStartupFeature))
return false;
if (availability_on_startup == AvailabilityOnStartup::kDisabled)
return false;
// TODO (crbug/1155158): Move this over the urls check (in
// startup_browser_creator.cc) once the profile picker can forward urls
// specified in command line.
......
......@@ -8,6 +8,7 @@
#include <vector>
#include "base/callback_forward.h"
#include "base/feature_list.h"
#include "base/time/time.h"
#include "third_party/skia/include/core/SkColor.h"
#include "url/gurl.h"
......@@ -27,6 +28,10 @@ class View;
class WebView;
} // namespace views
// Kill switch to disable showing the picker on startup. Has no effect if
// features::kNewProfilePicker is disabled.
extern const base::Feature kEnableProfilePickerOnStartupFeature;
class ProfilePicker {
public:
// An entry point that triggers the profile picker window to open.
......
......@@ -66,6 +66,18 @@ TEST_F(ProfilePickerTest, ShouldShowAtLaunch_MultipleProfiles_TwoActive) {
task_environment()->FastForwardBy(base::TimeDelta::FromDays(27));
EXPECT_TRUE(ProfilePicker::ShouldShowAtLaunch());
}
TEST_F(ProfilePickerTest, ShouldShowAtLaunch_KillSwitch) {
base::test::ScopedFeatureList feature_list;
feature_list.InitAndDisableFeature(kEnableProfilePickerOnStartupFeature);
TestingProfile* profile1 =
testing_profile_manager()->CreateTestingProfile("profile1");
GetProfileAttributes(profile1)->SetActiveTimeToNow();
TestingProfile* profile2 =
testing_profile_manager()->CreateTestingProfile("profile2");
GetProfileAttributes(profile2)->SetActiveTimeToNow();
EXPECT_FALSE(ProfilePicker::ShouldShowAtLaunch());
}
TEST_F(ProfilePickerTest,
ShouldShowAtLaunch_MultipleProfiles_Inactive_SeenPicker) {
......
......@@ -129,9 +129,11 @@ void AddStrings(content::WebUIDataSource* html_source) {
static_cast<ProfilePicker::AvailabilityOnStartup>(
g_browser_process->local_state()->GetInteger(
prefs::kBrowserProfilePickerAvailabilityOnStartup));
html_source->AddBoolean("disableAskOnStartup",
availability_on_startup !=
ProfilePicker::AvailabilityOnStartup::kEnabled);
bool disable_ask_on_startup =
availability_on_startup !=
ProfilePicker::AvailabilityOnStartup::kEnabled ||
!base::FeatureList::IsEnabled(kEnableProfilePickerOnStartupFeature);
html_source->AddBoolean("disableAskOnStartup", disable_ask_on_startup);
html_source->AddBoolean("askOnStartup",
g_browser_process->local_state()->GetBoolean(
prefs::kBrowserShowProfilePickerOnStartup));
......
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