Commit c41d543c authored by Renee Wright's avatar Renee Wright Committed by Commit Bot

Add a preference for whether or not Crostini is installed

This CL adds a preference called kCrostiniEnabled (= "crostini.enabled")
and sets it to true when Crostini is installed.

Bug: 833125
Change-Id: I58f27113e49cdcbc1c4aaf99f5aa4096fcdab902
Reviewed-on: https://chromium-review.googlesource.com/1013843
Commit-Queue: Renée Wright <rjwright@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarBernhard Bauer <bauerb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553926}
parent a480e6e3
......@@ -497,6 +497,8 @@ source_set("chromeos") {
"chrome_service_name.h",
"crostini/crostini_manager.cc",
"crostini/crostini_manager.h",
"crostini/crostini_pref_names.cc",
"crostini/crostini_pref_names.h",
"crostini/crostini_registry_service.cc",
"crostini/crostini_registry_service.h",
"crostini/crostini_registry_service_factory.cc",
......
// Copyright 2018 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/chromeos/crostini/crostini_pref_names.h"
#include "components/prefs/pref_registry_simple.h"
namespace crostini {
namespace prefs {
// A boolean preference representing whether a user has opted in to use
// Crostini (Called "Linux Apps" in UI).
const char kCrostiniEnabled[] = "crostini.enabled";
void RegisterProfilePrefs(PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(prefs::kCrostiniEnabled, false);
}
} // namespace prefs
} // namespace crostini
// Copyright 2018 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_CHROMEOS_CROSTINI_CROSTINI_PREF_NAMES_H_
#define CHROME_BROWSER_CHROMEOS_CROSTINI_CROSTINI_PREF_NAMES_H_
class PrefRegistrySimple;
namespace crostini {
namespace prefs {
extern const char kCrostiniEnabled[];
void RegisterProfilePrefs(PrefRegistrySimple* registry);
} // namespace prefs
} // namespace crostini
#endif // CHROME_BROWSER_CHROMEOS_CROSTINI_CROSTINI_PREF_NAMES_H_
......@@ -7,12 +7,14 @@
#include "base/feature_list.h"
#include "base/metrics/histogram_functions.h"
#include "chrome/browser/chromeos/crostini/crostini_manager.h"
#include "chrome/browser/chromeos/crostini/crostini_pref_names.h"
#include "chrome/browser/chromeos/crostini/crostini_registry_service.h"
#include "chrome/browser/chromeos/crostini/crostini_registry_service_factory.h"
#include "chrome/browser/chromeos/virtual_machines/virtual_machines_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/crostini/crostini_installer_view.h"
#include "chrome/common/chrome_features.h"
#include "components/prefs/pref_service.h"
namespace {
......@@ -77,7 +79,8 @@ void LaunchCrostiniApp(Profile* profile, const std::string& app_id) {
if (app_id == kCrostiniTerminalId) {
RecordAppLaunchHistogram(CrostiniAppLaunchAppType::kTerminal);
if (!crostini_manager->IsCrosTerminaInstalled()) {
if (!crostini_manager->IsCrosTerminaInstalled() ||
!profile->GetPrefs()->GetBoolean(crostini::prefs::kCrostiniEnabled)) {
CrostiniInstallerView::Show(profile);
} else {
crostini_manager->RestartCrostini(
......
......@@ -200,6 +200,7 @@
#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
#include "chrome/browser/chromeos/arc/arc_session_manager.h"
#include "chrome/browser/chromeos/arc/policy/arc_policy_bridge.h"
#include "chrome/browser/chromeos/crostini/crostini_pref_names.h"
#include "chrome/browser/chromeos/crostini/crostini_registry_service.h"
#include "chrome/browser/chromeos/cryptauth/cryptauth_device_id_provider_impl.h"
#include "chrome/browser/chromeos/customization/customization_document.h"
......@@ -618,6 +619,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
chromeos::SAMLOfflineSigninLimiter::RegisterProfilePrefs(registry);
chromeos::ServicesCustomizationDocument::RegisterProfilePrefs(registry);
chromeos::UserImageSyncObserver::RegisterProfilePrefs(registry);
crostini::prefs::RegisterProfilePrefs(registry);
crostini::CrostiniRegistryService::RegisterProfilePrefs(registry);
extensions::EPKPChallengeUserKey::RegisterProfilePrefs(registry);
flags_ui::PrefServiceFlagsStorage::RegisterProfilePrefs(registry);
......
......@@ -11,10 +11,12 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/crostini/crostini_manager.h"
#include "chrome/browser/chromeos/crostini/crostini_pref_names.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/grit/generated_resources.h"
#include "components/prefs/pref_service.h"
#include "components/signin/core/account_id/account_id.h"
#include "content/public/browser/browser_thread.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -94,6 +96,7 @@ bool CrostiniInstallerView::ShouldShowCloseButton() const {
bool CrostiniInstallerView::Accept() {
DCHECK_EQ(state_, State::PROMPT);
state_ = State::INSTALL_START;
profile_->GetPrefs()->SetBoolean(crostini::prefs::kCrostiniEnabled, true);
DialogModelChanged();
GetWidget()->UpdateWindowTitle();
......
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