Commit 435dd325 authored by Renee Wright's avatar Renee Wright Committed by Commit Bot

Move Crostini views to views directory

Bug: 841060

Change-Id: I1542a8f07da2c433406c733bf0489d42e8bd69b3
Reviewed-on: https://chromium-review.googlesource.com/1068533
Commit-Queue: Renée Wright <rjwright@chromium.org>
Reviewed-by: default avatarNicholas Verne <nverne@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarBen Wells <benwells@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561367}
parent bc654169
......@@ -14,7 +14,6 @@
#include "chrome/browser/chromeos/profiles/profile_helper.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"
......@@ -96,7 +95,7 @@ void LaunchCrostiniApp(Profile* profile, const std::string& app_id) {
if (!crostini_manager->IsCrosTerminaInstalled() ||
!IsCrostiniEnabled(profile)) {
CrostiniInstallerView::Show(profile);
ShowCrostiniInstallerView(profile);
} else {
crostini_manager->RestartCrostini(
profile, kCrostiniDefaultVmName, kCrostiniDefaultContainerName,
......
......@@ -42,6 +42,9 @@ std::string AppNameFromCrostiniAppId(const std::string& id);
base::Optional<std::string> CrostiniAppIdFromAppName(
const std::string& app_name);
void ShowCrostiniInstallerView(Profile* profile);
void ShowCrostiniUninstallerView(Profile* profile);
constexpr char kCrostiniTerminalAppName[] = "Terminal";
// We can use any arbitrary well-formed extension id for the Terminal app, this
// is equal to GenerateId("Terminal").
......
......@@ -3641,10 +3641,6 @@ split_static_library("ui") {
"app_list/crostini/crostini_app_item.h",
"app_list/crostini/crostini_app_model_builder.cc",
"app_list/crostini/crostini_app_model_builder.h",
"app_list/crostini/crostini_installer_view.cc",
"app_list/crostini/crostini_installer_view.h",
"app_list/crostini/crostini_uninstaller_view.cc",
"app_list/crostini/crostini_uninstaller_view.h",
"app_list/internal_app/internal_app_icon_loader.cc",
"app_list/internal_app/internal_app_icon_loader.h",
"app_list/internal_app/internal_app_item.cc",
......@@ -3690,6 +3686,10 @@ split_static_library("ui") {
"ash/launcher/shelf_spinner_item_controller.cc",
"ash/launcher/shelf_spinner_item_controller.h",
"views/arc_app_dialog_view.cc",
"views/crostini/crostini_installer_view.cc",
"views/crostini/crostini_installer_view.h",
"views/crostini/crostini_uninstaller_view.cc",
"views/crostini/crostini_uninstaller_view.h",
]
deps += [ "//mash/common" ]
}
......
......@@ -6,7 +6,6 @@
#include "chrome/browser/chromeos/crostini/crostini_manager.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h"
#include "chrome/browser/ui/app_list/crostini/crostini_uninstaller_view.h"
#include "chrome/grit/generated_resources.h"
#include "ui/base/ui_base_features.h"
......@@ -44,7 +43,7 @@ void CrostiniAppContextMenu::ExecuteCommand(int command_id, int event_flags) {
switch (command_id) {
case UNINSTALL:
if (app_id() == kCrostiniTerminalId) {
CrostiniUninstallerView::Show(profile());
ShowCrostiniUninstallerView(profile());
return;
}
break;
......
benwells@chromium.org
nverne@chromium.org
timloh@chromium.org
......@@ -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/app_list/crostini/crostini_installer_view.h"
#include "chrome/browser/ui/views/crostini/crostini_installer_view.h"
#include <memory>
#include <vector>
......@@ -16,6 +16,7 @@
#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/browser/ui/views/harmony/chrome_layout_provider.h"
#include "chrome/grit/generated_resources.h"
#include "components/account_id/account_id.h"
#include "components/prefs/pref_service.h"
......@@ -40,12 +41,14 @@ CrostiniInstallerView* g_crostini_installer_view = nullptr;
// TODO(timloh): This is just a placeholder.
constexpr int kDownloadSizeInBytes = 300 * 1024 * 1024;
constexpr int kDialogWidth = 448;
constexpr char kCrostiniSetupResultHistogram[] = "Crostini.SetupResult";
} // namespace
void ShowCrostiniInstallerView(Profile* profile) {
return CrostiniInstallerView::Show(profile);
}
void CrostiniInstallerView::Show(Profile* profile) {
DCHECK(IsCrostiniUIAllowedForProfile(profile));
if (!g_crostini_installer_view) {
......@@ -130,9 +133,10 @@ bool CrostiniInstallerView::Cancel() {
}
gfx::Size CrostiniInstallerView::CalculatePreferredSize() const {
int height =
GetLayoutManager()->GetPreferredHeightForWidth(this, kDialogWidth);
return gfx::Size(kDialogWidth, height);
const int dialog_width = ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(dialog_width, GetHeightForWidth(dialog_width));
}
void CrostiniInstallerView::OnComponentLoaded(ConciergeClientResult result) {
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_APP_LIST_CROSTINI_CROSTINI_INSTALLER_VIEW_H_
#define CHROME_BROWSER_UI_APP_LIST_CROSTINI_CROSTINI_INSTALLER_VIEW_H_
#ifndef CHROME_BROWSER_UI_VIEWS_CROSTINI_CROSTINI_INSTALLER_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_CROSTINI_CROSTINI_INSTALLER_VIEW_H_
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
......@@ -106,4 +106,4 @@ class CrostiniInstallerView
DISALLOW_COPY_AND_ASSIGN(CrostiniInstallerView);
};
#endif // CHROME_BROWSER_UI_APP_LIST_CROSTINI_CROSTINI_INSTALLER_VIEW_H_
#endif // CHROME_BROWSER_UI_VIEWS_CROSTINI_CROSTINI_INSTALLER_VIEW_H_
......@@ -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/app_list/crostini/crostini_installer_view.h"
#include "chrome/browser/ui/views/crostini/crostini_installer_view.h"
#include "base/metrics/histogram_base.h"
#include "base/run_loop.h"
......
......@@ -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/app_list/crostini/crostini_uninstaller_view.h"
#include "chrome/browser/ui/views/crostini/crostini_uninstaller_view.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/utf_string_conversions.h"
......@@ -10,6 +10,7 @@
#include "chrome/browser/chromeos/crostini/crostini_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/views/harmony/chrome_layout_provider.h"
#include "chrome/grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
......@@ -22,12 +23,11 @@
#include "ui/views/layout/layout_provider.h"
namespace {
CrostiniUninstallerView* g_crostini_uninstaller_view = nullptr;
// TODO(nverne): We should get this from a ChromeLayoutProvider
constexpr int kDialogWidth = 448;
CrostiniUninstallerView* g_crostini_uninstaller_view = nullptr;
constexpr char kCrostiniUninstallResultHistogram[] = "Crostini.UninstallResult";
} // namespace
// These values are persisted to logs. Entries should not be renumbered and
......@@ -39,6 +39,10 @@ enum class CrostiniUninstallerView::UninstallResult {
kCount
};
void ShowCrostiniUninstallerView(Profile* profile) {
return CrostiniUninstallerView::Show(profile);
}
void CrostiniUninstallerView::Show(Profile* profile) {
DCHECK(IsCrostiniUIAllowedForProfile(profile));
if (!g_crostini_uninstaller_view) {
......@@ -108,9 +112,10 @@ bool CrostiniUninstallerView::Cancel() {
}
gfx::Size CrostiniUninstallerView::CalculatePreferredSize() const {
int height =
GetLayoutManager()->GetPreferredHeightForWidth(this, kDialogWidth);
return gfx::Size(kDialogWidth, height);
const int dialog_width = ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(dialog_width, GetHeightForWidth(dialog_width));
}
CrostiniUninstallerView::CrostiniUninstallerView(Profile* profile)
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_APP_LIST_CROSTINI_CROSTINI_UNINSTALLER_VIEW_H_
#define CHROME_BROWSER_UI_APP_LIST_CROSTINI_CROSTINI_UNINSTALLER_VIEW_H_
#ifndef CHROME_BROWSER_UI_VIEWS_CROSTINI_CROSTINI_UNINSTALLER_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_CROSTINI_CROSTINI_UNINSTALLER_VIEW_H_
#include "ui/views/window/dialog_delegate.h"
......@@ -61,4 +61,4 @@ class CrostiniUninstallerView : public views::DialogDelegateView {
DISALLOW_COPY_AND_ASSIGN(CrostiniUninstallerView);
};
#endif // CHROME_BROWSER_UI_APP_LIST_CROSTINI_CROSTINI_UNINSTALLER_VIEW_H_
#endif // CHROME_BROWSER_UI_VIEWS_CROSTINI_CROSTINI_UNINSTALLER_VIEW_H_
......@@ -8,8 +8,6 @@
#include "chrome/browser/chromeos/crostini/crostini_manager.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/crostini/crostini_installer_view.h"
#include "chrome/browser/ui/app_list/crostini/crostini_uninstaller_view.h"
#include "content/public/browser/browser_thread.h"
namespace chromeos {
......@@ -33,12 +31,12 @@ void CrostiniHandler::RegisterMessages() {
void CrostiniHandler::HandleRequestCrostiniInstallerView(
const base::ListValue* args) {
AllowJavascript();
CrostiniInstallerView::Show(Profile::FromWebUI(web_ui()));
ShowCrostiniInstallerView(Profile::FromWebUI(web_ui()));
}
void CrostiniHandler::HandleRequestRemoveCrostini(const base::ListValue* args) {
AllowJavascript();
CrostiniUninstallerView::Show(Profile::FromWebUI(web_ui()));
ShowCrostiniUninstallerView(Profile::FromWebUI(web_ui()));
}
} // namespace settings
......
......@@ -1688,7 +1688,6 @@ test("browser_tests") {
"../browser/signin/chromeos_mirror_account_consistency_browsertest.cc",
"../browser/ui/app_list/app_list_browsertest.cc",
"../browser/ui/app_list/arc/arc_usb_host_permission_browsertest.cc",
"../browser/ui/app_list/crostini/crostini_installer_view_browsertest.cc",
"../browser/ui/ash/accelerator_commands_browsertest.cc",
"../browser/ui/ash/chrome_new_window_client_browsertest.cc",
"../browser/ui/ash/chrome_screenshot_grabber_browsertest.cc",
......@@ -1709,6 +1708,7 @@ test("browser_tests") {
"../browser/ui/ash/volume_controller_browsertest.cc",
"../browser/ui/views/apps/chrome_native_app_window_views_aura_ash_browsertest.cc",
"../browser/ui/views/arc_app_dialog_view_browsertest.cc",
"../browser/ui/views/crostini/crostini_installer_view_browsertest.cc",
"../browser/ui/views/frame/browser_frame_ash_browsertest.cc",
"../browser/ui/views/frame/browser_non_client_frame_view_ash_browsertest.cc",
"../browser/ui/views/frame/immersive_mode_controller_ash_browsertest.cc",
......
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