Skip to content

Commit

Permalink
Rename CrostiniUpgradeContainerView to CrostiniUpdateFilesystemView
Browse files Browse the repository at this point in the history
This will distinguish it from the "real" container upgrade (which upgrades the
Linux distribution)

Bug: 1025629
Change-Id: Icc35ccdbbbf500ba5b9d008c81d9a1880bfffbdd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1923207
Auto-Submit: Nicholas Verne <nverne@chromium.org>
Reviewed-by: Nic Hollingum <hollingum@google.com>
Commit-Queue: Nic Hollingum <hollingum@google.com>
Cr-Commit-Position: refs/heads/master@{#716450}
  • Loading branch information
Nicholas Verne authored and Commit Bot committed Nov 19, 2019
1 parent ceddf8e commit 99bb071
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 67 deletions.
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/crostini/crostini_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ class CrostiniManager::CrostiniRestarter
void StartLxdContainerFinished(CrostiniResult result) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);

CloseCrostiniUpgradeContainerView();
CloseCrostiniUpdateFilesystemView();
for (auto& observer : observer_list_) {
observer.OnContainerStarted(result);
}
Expand Down Expand Up @@ -2414,7 +2414,7 @@ void CrostiniManager::OnStartLxdContainer(
case vm_tools::cicerone::StartLxdContainerResponse::REMAPPING:
// Run the update container dialog to warn users of delays.
// The callback will be called when we receive the LxdContainerStarting
PrepareShowCrostiniUpgradeContainerView(profile_,
PrepareShowCrostiniUpdateFilesystemView(profile_,
CrostiniUISurface::kAppList);
// signal.
// Then perform the same steps as for starting.
Expand Down
12 changes: 6 additions & 6 deletions chrome/browser/chromeos/crostini/crostini_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ void ShowCrostiniUpdateComponentView(Profile* profile,

// Shows the Crostini Container Upgrade dialog (for running upgrades in the
// container).
void ShowCrostiniUpgradeContainerView(Profile* profile,
void ShowCrostiniUpdateFilesystemView(Profile* profile,
CrostiniUISurface ui_surface);
// Show the Crostini Container Upgrade dialog after a delay
// (CloseCrostiniUpgradeContainerView will cancel the next dialog show).
void PrepareShowCrostiniUpgradeContainerView(Profile* profile,
// (CloseCrostiniUpdateFilesystemView will cancel the next dialog show).
void PrepareShowCrostiniUpdateFilesystemView(Profile* profile,
CrostiniUISurface ui_surface);
// Closes the current CrostiniUpgradeContainerView or ensures that the view will
// not open until PrepareShowCrostiniUpgradeContainerView is called again.
void CloseCrostiniUpgradeContainerView();
// Closes the current CrostiniUpdateFilesystemView or ensures that the view will
// not open until PrepareShowCrostiniUpdateFilesystemView is called again.
void CloseCrostiniUpdateFilesystemView();

// Show the Crostini Software Config dialog (for installing Ansible and
// applying an Ansible playbook in the container).
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3768,8 +3768,8 @@ jumbo_static_library("ui") {
"views/crostini/crostini_uninstaller_view.h",
"views/crostini/crostini_update_component_view.cc",
"views/crostini/crostini_update_component_view.h",
"views/crostini/crostini_upgrade_container_view.cc",
"views/crostini/crostini_upgrade_container_view.h",
"views/crostini/crostini_update_filesystem_view.cc",
"views/crostini/crostini_update_filesystem_view.h",
"views/plugin_vm/plugin_vm_launcher_view.cc",
"views/plugin_vm/plugin_vm_launcher_view.h",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/views/crostini/crostini_upgrade_container_view.h"
#include "chrome/browser/ui/views/crostini/crostini_update_filesystem_view.h"

#include "base/bind.h"
#include "base/metrics/histogram_functions.h"
Expand All @@ -26,11 +26,11 @@

namespace {

bool g_crostini_upgrade_container_should_skip_delay_for_testing = false;
bool g_crostini_update_filesystem_should_skip_delay_for_testing = false;

CrostiniUpgradeContainerView* g_crostini_upgrade_container_view_dialog =
CrostiniUpdateFilesystemView* g_crostini_update_filesystem_view_dialog =
nullptr;
bool g_crostini_upgrade_container_should_show = false;
bool g_crostini_update_filesystem_should_show = false;
// The time to delay before showing the upgrade container dialog (to decrease
// flashiness).
constexpr base::TimeDelta kDelayBeforeUpgradeContainerDialog =
Expand All @@ -42,81 +42,81 @@ constexpr char kCrostiniUpgradeContainerSourceHistogram[] =
} // namespace

namespace crostini {
void SetCrostiniUpgradeSkipDelayForTesting(bool should_skip) {
g_crostini_upgrade_container_should_skip_delay_for_testing = should_skip;
void SetCrostiniUpdateFilesystemSkipDelayForTesting(bool should_skip) {
g_crostini_update_filesystem_should_skip_delay_for_testing = should_skip;
}

void PrepareShowCrostiniUpgradeContainerView(
void PrepareShowCrostiniUpdateFilesystemView(
Profile* profile,
crostini::CrostiniUISurface ui_surface) {
g_crostini_upgrade_container_should_show = true;
g_crostini_update_filesystem_should_show = true;

base::TimeDelta delay =
g_crostini_upgrade_container_should_skip_delay_for_testing
g_crostini_update_filesystem_should_skip_delay_for_testing
? base::TimeDelta::FromMilliseconds(0)
: kDelayBeforeUpgradeContainerDialog;

base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::BindOnce(&ShowCrostiniUpgradeContainerView, profile, ui_surface),
base::BindOnce(&ShowCrostiniUpdateFilesystemView, profile, ui_surface),
delay);
}

void ShowCrostiniUpgradeContainerView(Profile* profile,
void ShowCrostiniUpdateFilesystemView(Profile* profile,
crostini::CrostiniUISurface ui_surface) {
if (g_crostini_upgrade_container_should_show) {
if (g_crostini_update_filesystem_should_show) {
base::UmaHistogramEnumeration(kCrostiniUpgradeContainerSourceHistogram,
ui_surface,
crostini::CrostiniUISurface::kCount);
CrostiniUpgradeContainerView::Show(profile);
CrostiniUpdateFilesystemView::Show(profile);
}
}

void CloseCrostiniUpgradeContainerView() {
if (g_crostini_upgrade_container_view_dialog) {
g_crostini_upgrade_container_view_dialog->GetWidget()->Close();
void CloseCrostiniUpdateFilesystemView() {
if (g_crostini_update_filesystem_view_dialog) {
g_crostini_update_filesystem_view_dialog->GetWidget()->Close();
}
g_crostini_upgrade_container_should_show = false;
g_crostini_update_filesystem_should_show = false;
}
} // namespace crostini

void CrostiniUpgradeContainerView::Show(Profile* profile) {
void CrostiniUpdateFilesystemView::Show(Profile* profile) {
DCHECK(crostini::CrostiniFeatures::Get()->IsUIAllowed(profile));
if (!g_crostini_upgrade_container_view_dialog) {
g_crostini_upgrade_container_view_dialog =
new CrostiniUpgradeContainerView();
CreateDialogWidget(g_crostini_upgrade_container_view_dialog, nullptr,
if (!g_crostini_update_filesystem_view_dialog) {
g_crostini_update_filesystem_view_dialog =
new CrostiniUpdateFilesystemView();
CreateDialogWidget(g_crostini_update_filesystem_view_dialog, nullptr,
nullptr);
}
g_crostini_upgrade_container_view_dialog->GetWidget()->Show();
g_crostini_update_filesystem_view_dialog->GetWidget()->Show();
}

int CrostiniUpgradeContainerView::GetDialogButtons() const {
int CrostiniUpdateFilesystemView::GetDialogButtons() const {
return ui::DIALOG_BUTTON_OK;
}

base::string16 CrostiniUpgradeContainerView::GetWindowTitle() const {
base::string16 CrostiniUpdateFilesystemView::GetWindowTitle() const {
return l10n_util::GetStringUTF16(IDS_CROSTINI_UPGRADING_LABEL);
}

bool CrostiniUpgradeContainerView::ShouldShowCloseButton() const {
bool CrostiniUpdateFilesystemView::ShouldShowCloseButton() const {
return false;
}

gfx::Size CrostiniUpgradeContainerView::CalculatePreferredSize() const {
gfx::Size CrostiniUpdateFilesystemView::CalculatePreferredSize() const {
const int dialog_width = ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_STANDALONE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(dialog_width, GetHeightForWidth(dialog_width));
}

// static
CrostiniUpgradeContainerView*
CrostiniUpgradeContainerView::GetActiveViewForTesting() {
return g_crostini_upgrade_container_view_dialog;
CrostiniUpdateFilesystemView*
CrostiniUpdateFilesystemView::GetActiveViewForTesting() {
return g_crostini_update_filesystem_view_dialog;
}

CrostiniUpgradeContainerView::CrostiniUpgradeContainerView() {
CrostiniUpdateFilesystemView::CrostiniUpdateFilesystemView() {
constexpr int kDialogSpacingVertical = 32;

views::LayoutProvider* provider = views::LayoutProvider::Get();
Expand All @@ -136,6 +136,6 @@ CrostiniUpgradeContainerView::CrostiniUpgradeContainerView() {
chrome::DialogIdentifier::CROSTINI_CONTAINER_UPGRADE);
}

CrostiniUpgradeContainerView::~CrostiniUpgradeContainerView() {
g_crostini_upgrade_container_view_dialog = nullptr;
CrostiniUpdateFilesystemView::~CrostiniUpdateFilesystemView() {
g_crostini_update_filesystem_view_dialog = nullptr;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_VIEWS_CROSTINI_CROSTINI_UPGRADE_CONTAINER_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_CROSTINI_CROSTINI_UPGRADE_CONTAINER_VIEW_H_
#ifndef CHROME_BROWSER_UI_VIEWS_CROSTINI_CROSTINI_UPDATE_FILESYSTEM_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_CROSTINI_CROSTINI_UPDATE_FILESYSTEM_VIEW_H_

#include "ui/views/bubble/bubble_dialog_delegate_view.h"

class Profile;

namespace crostini {
void SetCrostiniUpgradeSkipDelayForTesting(bool should_skip);
void SetCrostiniUpdateFilesystemSkipDelayForTesting(bool should_skip);
} // namespace crostini

// Provides a warning to the user that an upgrade is occurring and Crostini
// start will take longer than usual.
class CrostiniUpgradeContainerView : public views::BubbleDialogDelegateView {
class CrostiniUpdateFilesystemView : public views::BubbleDialogDelegateView {
public:
static void Show(Profile* profile);

Expand All @@ -25,11 +25,11 @@ class CrostiniUpgradeContainerView : public views::BubbleDialogDelegateView {
bool ShouldShowCloseButton() const override;
gfx::Size CalculatePreferredSize() const override;

static CrostiniUpgradeContainerView* GetActiveViewForTesting();
static CrostiniUpdateFilesystemView* GetActiveViewForTesting();

private:
CrostiniUpgradeContainerView();
~CrostiniUpgradeContainerView() override;
CrostiniUpdateFilesystemView();
~CrostiniUpdateFilesystemView() override;
};

#endif // CHROME_BROWSER_UI_VIEWS_CROSTINI_CROSTINI_UPGRADE_CONTAINER_VIEW_H_
#endif // CHROME_BROWSER_UI_VIEWS_CROSTINI_CROSTINI_UPDATE_FILESYSTEM_VIEW_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/views/crostini/crostini_upgrade_container_view.h"
#include "chrome/browser/ui/views/crostini/crostini_update_filesystem_view.h"

#include "base/bind_helpers.h"
#include "base/metrics/histogram_base.h"
Expand Down Expand Up @@ -30,21 +30,21 @@ chromeos::FakeCiceroneClient* GetFakeCiceroneClient() {
chromeos::DBusThreadManager::Get()->GetCiceroneClient());
}

class CrostiniUpgradeContainerViewBrowserTest
class CrostiniUpdateFilesystemViewBrowserTest
: public CrostiniDialogBrowserTest {
public:
CrostiniUpgradeContainerViewBrowserTest()
CrostiniUpdateFilesystemViewBrowserTest()
: CrostiniDialogBrowserTest(true /*register_termina*/) {}

// DialogBrowserTest:
void ShowUi(const std::string& name) override {
PrepareShowCrostiniUpgradeContainerView(
PrepareShowCrostiniUpdateFilesystemView(
browser()->profile(), crostini::CrostiniUISurface::kAppList);
base::RunLoop().RunUntilIdle();
}

CrostiniUpgradeContainerView* ActiveView() {
return CrostiniUpgradeContainerView::GetActiveViewForTesting();
CrostiniUpdateFilesystemView* ActiveView() {
return CrostiniUpdateFilesystemView::GetActiveViewForTesting();
}

bool HasAcceptButton() {
Expand Down Expand Up @@ -72,19 +72,19 @@ class CrostiniUpgradeContainerViewBrowserTest
}

private:
DISALLOW_COPY_AND_ASSIGN(CrostiniUpgradeContainerViewBrowserTest);
DISALLOW_COPY_AND_ASSIGN(CrostiniUpdateFilesystemViewBrowserTest);
};

// Test the dialog is actually launched.
IN_PROC_BROWSER_TEST_F(CrostiniUpgradeContainerViewBrowserTest,
IN_PROC_BROWSER_TEST_F(CrostiniUpdateFilesystemViewBrowserTest,
InvokeUi_default) {
crostini::SetCrostiniUpgradeSkipDelayForTesting(true);
crostini::SetCrostiniUpdateFilesystemSkipDelayForTesting(true);
ShowAndVerifyUi();
}

IN_PROC_BROWSER_TEST_F(CrostiniUpgradeContainerViewBrowserTest, HitOK) {
IN_PROC_BROWSER_TEST_F(CrostiniUpdateFilesystemViewBrowserTest, HitOK) {
base::HistogramTester histogram_tester;
crostini::SetCrostiniUpgradeSkipDelayForTesting(true);
crostini::SetCrostiniUpdateFilesystemSkipDelayForTesting(true);

ShowUi("default");
ExpectView();
Expand All @@ -104,10 +104,10 @@ IN_PROC_BROWSER_TEST_F(CrostiniUpgradeContainerViewBrowserTest, HitOK) {
1);
}

IN_PROC_BROWSER_TEST_F(CrostiniUpgradeContainerViewBrowserTest,
IN_PROC_BROWSER_TEST_F(CrostiniUpdateFilesystemViewBrowserTest,
StartLxdContainerNoUpgradeNeeded) {
base::HistogramTester histogram_tester;
crostini::SetCrostiniUpgradeSkipDelayForTesting(true);
crostini::SetCrostiniUpdateFilesystemSkipDelayForTesting(true);

vm_tools::cicerone::StartLxdContainerResponse reply;
reply.set_status(vm_tools::cicerone::StartLxdContainerResponse::STARTING);
Expand All @@ -118,10 +118,10 @@ IN_PROC_BROWSER_TEST_F(CrostiniUpgradeContainerViewBrowserTest,
ExpectNoView();
}

IN_PROC_BROWSER_TEST_F(CrostiniUpgradeContainerViewBrowserTest,
IN_PROC_BROWSER_TEST_F(CrostiniUpdateFilesystemViewBrowserTest,
StartLxdContainerUpgradeNeeded) {
base::HistogramTester histogram_tester;
crostini::SetCrostiniUpgradeSkipDelayForTesting(true);
crostini::SetCrostiniUpdateFilesystemSkipDelayForTesting(true);

vm_tools::cicerone::StartLxdContainerResponse reply;
reply.set_status(vm_tools::cicerone::StartLxdContainerResponse::REMAPPING);
Expand Down
2 changes: 1 addition & 1 deletion chrome/test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2354,7 +2354,7 @@ if (!is_android) {
"../browser/ui/views/crostini/crostini_installer_view_browsertest.cc",
"../browser/ui/views/crostini/crostini_uninstaller_view_browsertest.cc",
"../browser/ui/views/crostini/crostini_update_component_view_browsertest.cc",
"../browser/ui/views/crostini/crostini_upgrade_container_view_browsertest.cc",
"../browser/ui/views/crostini/crostini_update_filesystem_view_browsertest.cc",
"../browser/ui/views/extensions/extension_dialog_bounds_browsertest.cc",
"../browser/ui/views/frame/browser_frame_ash_browsertest.cc",
"../browser/ui/views/frame/browser_non_client_frame_view_ash_browsertest.cc",
Expand Down

0 comments on commit 99bb071

Please sign in to comment.