Commit 38ceca08 authored by Erik Chen's avatar Erik Chen Committed by Chromium LUCI CQ

lacros: Prevent experimental banner from showing up more than once.

This CL stores whether the banner has already been shown as a local
pref. If it has been shown, then it is not shown again.

Bug: 1144321
Change-Id: I5dd97d6e4263c308bd14d90a480cf6cdeb7e7611
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2593282Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: Erik Chen <erikchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837382}
parent e770ec30
......@@ -4601,6 +4601,8 @@ static_library("browser") {
"lacros/immersive_context_lacros.h",
"lacros/lacros_chrome_service_delegate_impl.cc",
"lacros/lacros_chrome_service_delegate_impl.h",
"lacros/lacros_prefs.cc",
"lacros/lacros_prefs.h",
"lacros/metrics_reporting_observer.cc",
"lacros/metrics_reporting_observer.h",
"lacros/snap_controller_lacros.cc",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/lacros/lacros_prefs.h"
#include "components/prefs/pref_registry_simple.h"
namespace lacros_prefs {
const char kShowedExperimentalBannerPref[] =
"lacros.showed_experimental_banner";
void RegisterLocalStatePrefs(PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(kShowedExperimentalBannerPref,
/*default_value=*/false);
}
} // namespace lacros_prefs
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_LACROS_LACROS_PREFS_H_
#define CHROME_BROWSER_LACROS_LACROS_PREFS_H_
class PrefRegistrySimple;
namespace lacros_prefs {
// A preference for whether the "this is an experimental feature" banner has
// been shown to the user.
extern const char kShowedExperimentalBannerPref[];
// Local state prefs are also known as browser-wide prefs. This function
// registers Lacros-related local state prefs.
void RegisterLocalStatePrefs(PrefRegistrySimple* registry);
} // namespace lacros_prefs
#endif // CHROME_BROWSER_LACROS_LACROS_PREFS_H_
......@@ -389,6 +389,10 @@
#include "chrome/browser/browser_switcher/browser_switcher_prefs.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chrome/browser/lacros/lacros_prefs.h"
#endif
#if !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/device_identity//device_oauth2_token_store_desktop.h"
#include "chrome/browser/downgrade/downgrade_prefs.h"
......@@ -786,6 +790,10 @@ void RegisterLocalState(PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(kKeyCreated, false);
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
lacros_prefs::RegisterLocalStatePrefs(registry);
#endif
#if defined(OS_WIN)
OSCrypt::RegisterLocalPrefs(registry);
registry->RegisterBooleanPref(prefs::kRendererCodeIntegrityEnabled, true);
......
......@@ -79,6 +79,7 @@
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chrome/browser/lacros/lacros_prefs.h"
#include "chrome/grit/generated_resources.h"
#include "components/infobars/core/simple_alert_infobar_delegate.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -574,15 +575,25 @@ void StartupBrowserCreatorImpl::AddInfoBarsIfNecessary(
InfoBarService::FromWebContents(web_contents);
#if BUILDFLAG(IS_CHROMEOS_LACROS)
// Show the experimental lacros info bar. auto_expire must be set to false,
// since otherwise an automated navigation [which can happen at launch] will
// cause the info bar to disappear.
SimpleAlertInfoBarDelegate::Create(
infobar_service,
infobars::InfoBarDelegate::EXPERIMENTAL_INFOBAR_DELEGATE_LACROS,
/*vector_icon=*/nullptr,
l10n_util::GetStringUTF16(IDS_EXPERIMENTAL_LACROS_WARNING_MESSAGE),
/*auto_expire=*/false, /*should_animate=*/false);
PrefService* local_state = g_browser_process->local_state();
if (local_state) {
if (!local_state->GetBoolean(
lacros_prefs::kShowedExperimentalBannerPref)) {
// Show the experimental lacros info bar. auto_expire must be set to
// false, since otherwise an automated navigation [which can happen at
// launch] will cause the info bar to disappear.
SimpleAlertInfoBarDelegate::Create(
infobar_service,
infobars::InfoBarDelegate::EXPERIMENTAL_INFOBAR_DELEGATE_LACROS,
/*vector_icon=*/nullptr,
l10n_util::GetStringUTF16(IDS_EXPERIMENTAL_LACROS_WARNING_MESSAGE),
/*auto_expire=*/false, /*should_animate=*/false);
// Mark the pref as shown, so that we don't show the banner again.
local_state->SetBoolean(lacros_prefs::kShowedExperimentalBannerPref,
true);
}
}
#endif
if (!google_apis::HasAPIKeyConfigured())
......
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