Commit 35ebfd15 authored by nancy's avatar nancy Committed by Commit Bot

Update uninstall dialog for ARC apps.

The ARC app uninstall dialog's layout is different with the
extension/Web App/Chrome App uninstall dialog, so use different layout
for the ARC app uninstall dialog. The icon for the ARC app is not the
window icon, but used for ImageView. So update the ARC app uninstall
dialog to keep the consistency with the current ARC app uninstall
dialog.

BUG=1009248

Change-Id: Ia624312b2b55dabfbbc43ea04aac0e35f8b44fed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1861794
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706711}
parent c26e52b0
...@@ -7,6 +7,13 @@ ...@@ -7,6 +7,13 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/services/app_service/public/cpp/icon_loader.h" #include "chrome/services/app_service/public/cpp/icon_loader.h"
namespace {
constexpr int32_t kUninstallIconSize = 32;
constexpr int32_t kArcUninstallIconSize = 48;
} // namespace
namespace apps { namespace apps {
UninstallDialog::UninstallDialog(Profile* profile, UninstallDialog::UninstallDialog(Profile* profile,
...@@ -19,10 +26,28 @@ UninstallDialog::UninstallDialog(Profile* profile, ...@@ -19,10 +26,28 @@ UninstallDialog::UninstallDialog(Profile* profile,
app_type_(app_type), app_type_(app_type),
app_id_(app_id), app_id_(app_id),
uninstall_callback_(std::move(uninstall_callback)) { uninstall_callback_(std::move(uninstall_callback)) {
int32_t size_hint_in_dip;
switch (app_type) {
case apps::mojom::AppType::kCrostini:
// Crostini uninstall dialog doesn't show the icon.
UiBase::Create(profile_, app_type_, app_id_, gfx::ImageSkia(), this);
return;
case apps::mojom::AppType::kArc:
// Currently ARC apps only support 48*48 native icon.
size_hint_in_dip = kArcUninstallIconSize;
break;
case apps::mojom::AppType::kExtension:
case apps::mojom::AppType::kWeb:
size_hint_in_dip = kUninstallIconSize;
break;
default:
NOTREACHED();
return;
}
constexpr bool kAllowPlaceholderIcon = false; constexpr bool kAllowPlaceholderIcon = false;
icon_loader->LoadIconFromIconKey( icon_loader->LoadIconFromIconKey(
app_type, app_id, std::move(icon_key), app_type, app_id, std::move(icon_key),
apps::mojom::IconCompression::kUncompressed, kSizeHintInDip, apps::mojom::IconCompression::kUncompressed, size_hint_in_dip,
kAllowPlaceholderIcon, kAllowPlaceholderIcon,
base::BindOnce(&UninstallDialog::OnLoadIcon, base::BindOnce(&UninstallDialog::OnLoadIcon,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
......
...@@ -79,8 +79,6 @@ class UninstallDialog { ...@@ -79,8 +79,6 @@ class UninstallDialog {
bool report_rebuse, bool report_rebuse,
UninstallDialog* uninstall_dialog)>; UninstallDialog* uninstall_dialog)>;
static constexpr int32_t kSizeHintInDip = 32;
UninstallDialog(Profile* profile, UninstallDialog(Profile* profile,
apps::mojom::AppType app_type, apps::mojom::AppType app_type,
const std::string& app_id, const std::string& app_id,
......
...@@ -46,24 +46,9 @@ AppUninstallDialogView::AppUninstallDialogView( ...@@ -46,24 +46,9 @@ AppUninstallDialogView::AppUninstallDialogView(
gfx::ImageSkia image, gfx::ImageSkia image,
apps::UninstallDialog* uninstall_dialog) apps::UninstallDialog* uninstall_dialog)
: apps::UninstallDialog::UiBase(image, uninstall_dialog), : apps::UninstallDialog::UiBase(image, uninstall_dialog),
BubbleDialogDelegateView(nullptr, views::BubbleBorder::NONE) { BubbleDialogDelegateView(nullptr, views::BubbleBorder::NONE),
DialogDelegate::set_button_label( app_type_(app_type) {
ui::DIALOG_BUTTON_OK, InitializeView(profile, app_id);
l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_UNINSTALL_BUTTON));
ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical, gfx::Insets(),
provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL)));
// Add margins for the icon plus the icon-title padding so that the dialog
// contents align with the title text.
set_margins(
margins() +
gfx::Insets(0, margins().left() + apps::UninstallDialog::kSizeHintInDip,
0, 0));
InitializeView(profile, app_type, app_id);
constrained_window::CreateBrowserModalDialogViews(this, nullptr)->Show(); constrained_window::CreateBrowserModalDialogViews(this, nullptr)->Show();
} }
...@@ -112,7 +97,8 @@ bool AppUninstallDialogView::ShouldShowCloseButton() const { ...@@ -112,7 +97,8 @@ bool AppUninstallDialogView::ShouldShowCloseButton() const {
} }
bool AppUninstallDialogView::ShouldShowWindowIcon() const { bool AppUninstallDialogView::ShouldShowWindowIcon() const {
return true; return app_type_ == apps::mojom::AppType::kExtension ||
app_type_ == apps::mojom::AppType::kWeb;
} }
void AppUninstallDialogView::AddMultiLineLabel( void AppUninstallDialogView::AddMultiLineLabel(
...@@ -128,6 +114,16 @@ void AppUninstallDialogView::AddMultiLineLabel( ...@@ -128,6 +114,16 @@ void AppUninstallDialogView::AddMultiLineLabel(
void AppUninstallDialogView::InitializeViewForExtension( void AppUninstallDialogView::InitializeViewForExtension(
Profile* profile, Profile* profile,
const std::string& app_id) { const std::string& app_id) {
ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical, gfx::Insets(),
provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL)));
// Add margins for the icon plus the icon-title padding so that the dialog
// contents align with the title text.
set_margins(margins() +
gfx::Insets(0, margins().left() + image().size().height(), 0, 0));
const extensions::Extension* extension = const extensions::Extension* extension =
extensions::ExtensionRegistry::Get(profile)->GetInstalledExtension( extensions::ExtensionRegistry::Get(profile)->GetInstalledExtension(
app_id); app_id);
...@@ -159,6 +155,12 @@ void AppUninstallDialogView::InitializeViewForExtension( ...@@ -159,6 +155,12 @@ void AppUninstallDialogView::InitializeViewForExtension(
void AppUninstallDialogView::InitializeViewForArcApp( void AppUninstallDialogView::InitializeViewForArcApp(
Profile* profile, Profile* profile,
const std::string& app_id) { const std::string& app_id) {
ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal,
provider->GetDialogInsetsForContentType(views::TEXT, views::TEXT),
provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_HORIZONTAL)));
ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(profile); ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(profile);
DCHECK(arc_prefs); DCHECK(arc_prefs);
...@@ -186,9 +188,15 @@ void AppUninstallDialogView::InitializeViewForArcApp( ...@@ -186,9 +188,15 @@ void AppUninstallDialogView::InitializeViewForArcApp(
l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_UNINSTALL_APP_BUTTON)); l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_UNINSTALL_APP_BUTTON));
} }
auto* icon_view = AddChildView(std::make_unique<views::ImageView>());
constexpr int kArcImageViewSize = 64;
icon_view->SetPreferredSize(gfx::Size(kArcImageViewSize, kArcImageViewSize));
icon_view->SetImageSize(image().size());
icon_view->SetImage(image());
auto* text_container = AddChildView(std::make_unique<views::View>()); auto* text_container = AddChildView(std::make_unique<views::View>());
auto* text_container_layout = auto* text_container_layout =
SetLayoutManager(std::make_unique<views::BoxLayout>( text_container->SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical)); views::BoxLayout::Orientation::kVertical));
text_container_layout->set_main_axis_alignment( text_container_layout->set_main_axis_alignment(
views::BoxLayout::MainAxisAlignment::kCenter); views::BoxLayout::MainAxisAlignment::kCenter);
...@@ -202,9 +210,8 @@ void AppUninstallDialogView::InitializeViewForArcApp( ...@@ -202,9 +210,8 @@ void AppUninstallDialogView::InitializeViewForArcApp(
#endif #endif
void AppUninstallDialogView::InitializeView(Profile* profile, void AppUninstallDialogView::InitializeView(Profile* profile,
apps::mojom::AppType app_type,
const std::string& app_id) { const std::string& app_id) {
switch (app_type) { switch (app_type_) {
case apps::mojom::AppType::kUnknown: case apps::mojom::AppType::kUnknown:
case apps::mojom::AppType::kBuiltIn: case apps::mojom::AppType::kBuiltIn:
NOTREACHED(); NOTREACHED();
......
...@@ -70,9 +70,10 @@ class AppUninstallDialogView : public apps::UninstallDialog::UiBase, ...@@ -70,9 +70,10 @@ class AppUninstallDialogView : public apps::UninstallDialog::UiBase,
void InitializeViewForArcApp(Profile* profile, const std::string& app_id); void InitializeViewForArcApp(Profile* profile, const std::string& app_id);
#endif #endif
void InitializeView(Profile* profile, void InitializeView(Profile* profile,
apps::mojom::AppType app_type,
const std::string& app_id); const std::string& app_id);
apps::mojom::AppType app_type_;
views::Checkbox* report_abuse_checkbox_ = nullptr; views::Checkbox* report_abuse_checkbox_ = nullptr;
views::Checkbox* clear_site_data_checkbox_ = nullptr; views::Checkbox* clear_site_data_checkbox_ = nullptr;
......
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