Commit 09723d9d authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

cbui: remove more GetDialogButtonLabel overrides

This CL removes overrides from:

* AppUninstallDialogView, which uses text that is computed during the
  constructor (and used redundant cancel text)
* DataRemovalConfirmationDialog, which uses static text
* DownloadInProgressDialogView, which uses static text
* Various NativeFileSystem dialogs, which use static text or text computed
  during the constructor & then never changed

This change also makes
NativeFileSystemRestrictedDirectoryDialogView::is_directory_ const to make the
code easier to reason about.

Bug: 1011446
Change-Id: Ib345c6f742b860a9041a9df21e003f802fe5648d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1863632Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706430}
parent e5f23738
...@@ -47,6 +47,10 @@ AppUninstallDialogView::AppUninstallDialogView( ...@@ -47,6 +47,10 @@ AppUninstallDialogView::AppUninstallDialogView(
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(
ui::DIALOG_BUTTON_OK,
l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_UNINSTALL_BUTTON));
ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
SetLayoutManager(std::make_unique<views::BoxLayout>( SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical, gfx::Insets(), views::BoxLayout::Orientation::kVertical, gfx::Insets(),
...@@ -91,12 +95,6 @@ gfx::Size AppUninstallDialogView::CalculatePreferredSize() const { ...@@ -91,12 +95,6 @@ gfx::Size AppUninstallDialogView::CalculatePreferredSize() const {
return gfx::Size(default_width, GetHeightForWidth(default_width)); return gfx::Size(default_width, GetHeightForWidth(default_width));
} }
base::string16 AppUninstallDialogView::GetDialogButtonLabel(
ui::DialogButton button) const {
return button == ui::DIALOG_BUTTON_CANCEL ? cancel_button_text_
: confirm_button_text_;
}
ui::ModalType AppUninstallDialogView::GetModalType() const { ui::ModalType AppUninstallDialogView::GetModalType() const {
return ui::MODAL_TYPE_WINDOW; return ui::MODAL_TYPE_WINDOW;
} }
...@@ -139,9 +137,6 @@ void AppUninstallDialogView::InitializeViewForExtension( ...@@ -139,9 +137,6 @@ void AppUninstallDialogView::InitializeViewForExtension(
l10n_util::GetStringFUTF16(IDS_EXTENSION_PROMPT_UNINSTALL_TITLE, l10n_util::GetStringFUTF16(IDS_EXTENSION_PROMPT_UNINSTALL_TITLE,
base::UTF8ToUTF16(extension->name())); base::UTF8ToUTF16(extension->name()));
confirm_button_text_ =
l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_UNINSTALL_BUTTON);
if (extensions::ManifestURL::UpdatesFromGallery(extension)) { if (extensions::ManifestURL::UpdatesFromGallery(extension)) {
auto report_abuse_checkbox = std::make_unique<views::Checkbox>( auto report_abuse_checkbox = std::make_unique<views::Checkbox>(
l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_UNINSTALL_REPORT_ABUSE)); l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_UNINSTALL_REPORT_ABUSE));
...@@ -185,9 +180,11 @@ void AppUninstallDialogView::InitializeViewForArcApp( ...@@ -185,9 +180,11 @@ void AppUninstallDialogView::InitializeViewForArcApp(
IDS_ARC_APP_UNINSTALL_PROMPT_DATA_REMOVAL_WARNING); IDS_ARC_APP_UNINSTALL_PROMPT_DATA_REMOVAL_WARNING);
} }
confirm_button_text_ = l10n_util::GetStringUTF16( if (!app_info->shortcut) {
app_info->shortcut ? IDS_EXTENSION_PROMPT_UNINSTALL_BUTTON DialogDelegate::set_button_label(
: IDS_EXTENSION_PROMPT_UNINSTALL_APP_BUTTON); ui::DIALOG_BUTTON_OK,
l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_UNINSTALL_APP_BUTTON));
}
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 =
...@@ -207,8 +204,6 @@ void AppUninstallDialogView::InitializeViewForArcApp( ...@@ -207,8 +204,6 @@ void AppUninstallDialogView::InitializeViewForArcApp(
void AppUninstallDialogView::InitializeView(Profile* profile, void AppUninstallDialogView::InitializeView(Profile* profile,
apps::mojom::AppType app_type, apps::mojom::AppType app_type,
const std::string& app_id) { const std::string& app_id) {
cancel_button_text_ = l10n_util::GetStringUTF16(IDS_CANCEL);
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:
......
...@@ -57,7 +57,6 @@ class AppUninstallDialogView : public apps::UninstallDialog::UiBase, ...@@ -57,7 +57,6 @@ class AppUninstallDialogView : public apps::UninstallDialog::UiBase,
bool Accept() override; bool Accept() override;
bool Close() override; bool Close() override;
gfx::Size CalculatePreferredSize() const override; gfx::Size CalculatePreferredSize() const override;
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
ui::ModalType GetModalType() const override; ui::ModalType GetModalType() const override;
gfx::ImageSkia GetWindowIcon() override; gfx::ImageSkia GetWindowIcon() override;
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
...@@ -80,8 +79,6 @@ class AppUninstallDialogView : public apps::UninstallDialog::UiBase, ...@@ -80,8 +79,6 @@ class AppUninstallDialogView : public apps::UninstallDialog::UiBase,
// TODO(crbug.com/1009248): Remove these fields to use the consistent title // TODO(crbug.com/1009248): Remove these fields to use the consistent title
// and button. // and button.
base::string16 window_title_; base::string16 window_title_;
base::string16 confirm_button_text_;
base::string16 cancel_button_text_;
DISALLOW_COPY_AND_ASSIGN(AppUninstallDialogView); DISALLOW_COPY_AND_ASSIGN(AppUninstallDialogView);
}; };
......
...@@ -50,7 +50,6 @@ class DataRemovalConfirmationDialog : public views::DialogDelegateView, ...@@ -50,7 +50,6 @@ class DataRemovalConfirmationDialog : public views::DialogDelegateView,
ui::ModalType GetModalType() const override; ui::ModalType GetModalType() const override;
// views::DialogDelegate: // views::DialogDelegate:
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
bool Accept() override; bool Accept() override;
bool Cancel() override; bool Cancel() override;
...@@ -83,6 +82,10 @@ DataRemovalConfirmationDialog::DataRemovalConfirmationDialog( ...@@ -83,6 +82,10 @@ DataRemovalConfirmationDialog::DataRemovalConfirmationDialog(
Profile* profile, Profile* profile,
DataRemovalConfirmationCallback confirm_callback) DataRemovalConfirmationCallback confirm_callback)
: profile_(profile), confirm_callback_(std::move(confirm_callback)) { : profile_(profile), confirm_callback_(std::move(confirm_callback)) {
DialogDelegate::set_button_label(
ui::DIALOG_BUTTON_OK,
l10n_util::GetStringUTF16(IDS_ARC_DATA_REMOVAL_CONFIRMATION_OK_BUTTON));
ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
std::unique_ptr<views::BoxLayout> layout = std::make_unique<views::BoxLayout>( std::unique_ptr<views::BoxLayout> layout = std::make_unique<views::BoxLayout>(
...@@ -131,15 +134,6 @@ ui::ModalType DataRemovalConfirmationDialog::GetModalType() const { ...@@ -131,15 +134,6 @@ ui::ModalType DataRemovalConfirmationDialog::GetModalType() const {
return ui::MODAL_TYPE_WINDOW; return ui::MODAL_TYPE_WINDOW;
} }
base::string16 DataRemovalConfirmationDialog::GetDialogButtonLabel(
ui::DialogButton button) const {
if (button == ui::DIALOG_BUTTON_OK) {
return l10n_util::GetStringUTF16(
IDS_ARC_DATA_REMOVAL_CONFIRMATION_OK_BUTTON);
}
return views::DialogDelegate::GetDialogButtonLabel(button);
}
bool DataRemovalConfirmationDialog::Accept() { bool DataRemovalConfirmationDialog::Accept() {
if (confirm_callback_) if (confirm_callback_)
std::move(confirm_callback_).Run(true); std::move(confirm_callback_).Run(true);
......
...@@ -36,6 +36,12 @@ DownloadInProgressDialogView::DownloadInProgressDialogView( ...@@ -36,6 +36,12 @@ DownloadInProgressDialogView::DownloadInProgressDialogView(
app_modal_(app_modal), app_modal_(app_modal),
callback_(callback) { callback_(callback) {
DialogDelegate::set_default_button(ui::DIALOG_BUTTON_CANCEL); DialogDelegate::set_default_button(ui::DIALOG_BUTTON_CANCEL);
DialogDelegate::set_button_label(
ui::DIALOG_BUTTON_OK,
l10n_util::GetStringUTF16(IDS_ABANDON_DOWNLOAD_DIALOG_EXIT_BUTTON));
DialogDelegate::set_button_label(
ui::DIALOG_BUTTON_CANCEL,
l10n_util::GetStringUTF16(IDS_ABANDON_DOWNLOAD_DIALOG_CONTINUE_BUTTON));
SetLayoutManager(std::make_unique<views::FillLayout>()); SetLayoutManager(std::make_unique<views::FillLayout>());
set_margins(ChromeLayoutProvider::Get()->GetDialogInsetsForContentType( set_margins(ChromeLayoutProvider::Get()->GetDialogInsetsForContentType(
views::TEXT, views::TEXT)); views::TEXT, views::TEXT));
...@@ -76,14 +82,6 @@ gfx::Size DownloadInProgressDialogView::CalculatePreferredSize() const { ...@@ -76,14 +82,6 @@ gfx::Size DownloadInProgressDialogView::CalculatePreferredSize() const {
return gfx::Size(width, GetHeightForWidth(width)); return gfx::Size(width, GetHeightForWidth(width));
} }
base::string16 DownloadInProgressDialogView::GetDialogButtonLabel(
ui::DialogButton button) const {
return l10n_util::GetStringUTF16(
button == ui::DIALOG_BUTTON_OK
? IDS_ABANDON_DOWNLOAD_DIALOG_EXIT_BUTTON
: IDS_ABANDON_DOWNLOAD_DIALOG_CONTINUE_BUTTON);
}
bool DownloadInProgressDialogView::Cancel() { bool DownloadInProgressDialogView::Cancel() {
callback_.Run(false /* cancel_downloads */); callback_.Run(false /* cancel_downloads */);
return true; return true;
......
...@@ -34,7 +34,6 @@ class DownloadInProgressDialogView : public views::DialogDelegateView { ...@@ -34,7 +34,6 @@ class DownloadInProgressDialogView : public views::DialogDelegateView {
// views::DialogDelegateView: // views::DialogDelegateView:
gfx::Size CalculatePreferredSize() const override; gfx::Size CalculatePreferredSize() const override;
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
bool Cancel() override; bool Cancel() override;
bool Accept() override; bool Accept() override;
ui::ModalType GetModalType() const override; ui::ModalType GetModalType() const override;
......
...@@ -49,15 +49,6 @@ base::string16 NativeFileSystemDirectoryAccessConfirmationView::GetWindowTitle() ...@@ -49,15 +49,6 @@ base::string16 NativeFileSystemDirectoryAccessConfirmationView::GetWindowTitle()
IDS_NATIVE_FILE_SYSTEM_DIRECTORY_ACCESS_CONFIRMATION_TITLE); IDS_NATIVE_FILE_SYSTEM_DIRECTORY_ACCESS_CONFIRMATION_TITLE);
} }
base::string16
NativeFileSystemDirectoryAccessConfirmationView::GetDialogButtonLabel(
ui::DialogButton button) const {
if (button == ui::DIALOG_BUTTON_OK)
return l10n_util::GetStringUTF16(
IDS_NATIVE_FILE_SYSTEM_DIRECTORY_ACCESS_ALLOW_BUTTON);
return l10n_util::GetStringUTF16(IDS_APP_CANCEL);
}
bool NativeFileSystemDirectoryAccessConfirmationView::ShouldShowCloseButton() bool NativeFileSystemDirectoryAccessConfirmationView::ShouldShowCloseButton()
const { const {
return false; return false;
...@@ -99,6 +90,10 @@ NativeFileSystemDirectoryAccessConfirmationView:: ...@@ -99,6 +90,10 @@ NativeFileSystemDirectoryAccessConfirmationView::
const base::FilePath& path, const base::FilePath& path,
base::OnceCallback<void(PermissionAction result)> callback) base::OnceCallback<void(PermissionAction result)> callback)
: callback_(std::move(callback)) { : callback_(std::move(callback)) {
DialogDelegate::set_button_label(
ui::DIALOG_BUTTON_OK,
l10n_util::GetStringUTF16(
IDS_NATIVE_FILE_SYSTEM_DIRECTORY_ACCESS_ALLOW_BUTTON));
const views::LayoutProvider* provider = ChromeLayoutProvider::Get(); const views::LayoutProvider* provider = ChromeLayoutProvider::Get();
SetLayoutManager(std::make_unique<views::BoxLayout>( SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical, views::BoxLayout::Orientation::kVertical,
......
...@@ -44,7 +44,6 @@ class NativeFileSystemDirectoryAccessConfirmationView ...@@ -44,7 +44,6 @@ class NativeFileSystemDirectoryAccessConfirmationView
// views::DialogDelegateView: // views::DialogDelegateView:
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
bool ShouldShowCloseButton() const override; bool ShouldShowCloseButton() const override;
bool Accept() override; bool Accept() override;
bool Cancel() override; bool Cancel() override;
......
...@@ -26,6 +26,11 @@ NativeFileSystemPermissionView::NativeFileSystemPermissionView( ...@@ -26,6 +26,11 @@ NativeFileSystemPermissionView::NativeFileSystemPermissionView(
bool is_directory, bool is_directory,
base::OnceCallback<void(PermissionAction result)> callback) base::OnceCallback<void(PermissionAction result)> callback)
: path_(path), callback_(std::move(callback)) { : path_(path), callback_(std::move(callback)) {
DialogDelegate::set_button_label(
ui::DIALOG_BUTTON_OK,
l10n_util::GetStringUTF16(
IDS_NATIVE_FILE_SYSTEM_WRITE_PERMISSION_ALLOW_TEXT));
const views::LayoutProvider* provider = ChromeLayoutProvider::Get(); const views::LayoutProvider* provider = ChromeLayoutProvider::Get();
SetLayoutManager(std::make_unique<views::BoxLayout>( SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical, views::BoxLayout::Orientation::kVertical,
...@@ -62,14 +67,6 @@ base::string16 NativeFileSystemPermissionView::GetWindowTitle() const { ...@@ -62,14 +67,6 @@ base::string16 NativeFileSystemPermissionView::GetWindowTitle() const {
path_.BaseName().LossyDisplayName()); path_.BaseName().LossyDisplayName());
} }
base::string16 NativeFileSystemPermissionView::GetDialogButtonLabel(
ui::DialogButton button) const {
if (button == ui::DIALOG_BUTTON_OK)
return l10n_util::GetStringUTF16(
IDS_NATIVE_FILE_SYSTEM_WRITE_PERMISSION_ALLOW_TEXT);
return l10n_util::GetStringUTF16(IDS_APP_CANCEL);
}
bool NativeFileSystemPermissionView::ShouldShowCloseButton() const { bool NativeFileSystemPermissionView::ShouldShowCloseButton() const {
return false; return false;
} }
......
...@@ -46,7 +46,6 @@ class NativeFileSystemPermissionView : public views::DialogDelegateView { ...@@ -46,7 +46,6 @@ class NativeFileSystemPermissionView : public views::DialogDelegateView {
// views::DialogDelegateView: // views::DialogDelegateView:
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
bool ShouldShowCloseButton() const override; bool ShouldShowCloseButton() const override;
bool Accept() override; bool Accept() override;
bool Cancel() override; bool Cancel() override;
......
...@@ -48,16 +48,6 @@ int NativeFileSystemRestrictedDirectoryDialogView::GetDialogButtons() const { ...@@ -48,16 +48,6 @@ int NativeFileSystemRestrictedDirectoryDialogView::GetDialogButtons() const {
return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL;
} }
base::string16
NativeFileSystemRestrictedDirectoryDialogView::GetDialogButtonLabel(
ui::DialogButton button) const {
if (button == ui::DIALOG_BUTTON_OK)
return l10n_util::GetStringUTF16(
is_directory_ ? IDS_NATIVE_FILE_SYSTEM_RESTRICTED_DIRECTORY_BUTTON
: IDS_NATIVE_FILE_SYSTEM_RESTRICTED_FILE_BUTTON);
return l10n_util::GetStringUTF16(IDS_APP_CANCEL);
}
bool NativeFileSystemRestrictedDirectoryDialogView::ShouldShowCloseButton() bool NativeFileSystemRestrictedDirectoryDialogView::ShouldShowCloseButton()
const { const {
return false; return false;
...@@ -97,6 +87,12 @@ NativeFileSystemRestrictedDirectoryDialogView:: ...@@ -97,6 +87,12 @@ NativeFileSystemRestrictedDirectoryDialogView::
bool is_directory, bool is_directory,
base::OnceCallback<void(SensitiveDirectoryResult)> callback) base::OnceCallback<void(SensitiveDirectoryResult)> callback)
: is_directory_(is_directory), callback_(std::move(callback)) { : is_directory_(is_directory), callback_(std::move(callback)) {
DialogDelegate::set_button_label(
ui::DIALOG_BUTTON_OK,
l10n_util::GetStringUTF16(
is_directory_ ? IDS_NATIVE_FILE_SYSTEM_RESTRICTED_DIRECTORY_BUTTON
: IDS_NATIVE_FILE_SYSTEM_RESTRICTED_FILE_BUTTON));
SetLayoutManager(std::make_unique<views::FillLayout>()); SetLayoutManager(std::make_unique<views::FillLayout>());
set_margins(ChromeLayoutProvider::Get()->GetDialogInsetsForContentType( set_margins(ChromeLayoutProvider::Get()->GetDialogInsetsForContentType(
views::TEXT, views::TEXT)); views::TEXT, views::TEXT));
......
...@@ -48,7 +48,6 @@ class NativeFileSystemRestrictedDirectoryDialogView ...@@ -48,7 +48,6 @@ class NativeFileSystemRestrictedDirectoryDialogView
// views::DialogDelegateView: // views::DialogDelegateView:
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
int GetDialogButtons() const override; int GetDialogButtons() const override;
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
bool ShouldShowCloseButton() const override; bool ShouldShowCloseButton() const override;
bool Accept() override; bool Accept() override;
bool Cancel() override; bool Cancel() override;
...@@ -62,7 +61,7 @@ class NativeFileSystemRestrictedDirectoryDialogView ...@@ -62,7 +61,7 @@ class NativeFileSystemRestrictedDirectoryDialogView
bool is_directory, bool is_directory,
base::OnceCallback<void(SensitiveDirectoryResult)> callback); base::OnceCallback<void(SensitiveDirectoryResult)> callback);
bool is_directory_; const bool is_directory_;
base::OnceCallback<void(SensitiveDirectoryResult)> callback_; base::OnceCallback<void(SensitiveDirectoryResult)> callback_;
DISALLOW_COPY_AND_ASSIGN(NativeFileSystemRestrictedDirectoryDialogView); DISALLOW_COPY_AND_ASSIGN(NativeFileSystemRestrictedDirectoryDialogView);
......
...@@ -297,7 +297,10 @@ NativeFileSystemUsageBubbleView::NativeFileSystemUsageBubbleView( ...@@ -297,7 +297,10 @@ NativeFileSystemUsageBubbleView::NativeFileSystemUsageBubbleView(
origin_(origin), origin_(origin),
usage_(std::move(usage)), usage_(std::move(usage)),
writable_paths_model_(usage_.writable_files, usage_.writable_directories), writable_paths_model_(usage_.writable_files, usage_.writable_directories),
readable_paths_model_({}, usage_.readable_directories) {} readable_paths_model_({}, usage_.readable_directories) {
DialogDelegate::set_button_label(ui::DIALOG_BUTTON_OK,
l10n_util::GetStringUTF16(IDS_DONE));
}
NativeFileSystemUsageBubbleView::~NativeFileSystemUsageBubbleView() = default; NativeFileSystemUsageBubbleView::~NativeFileSystemUsageBubbleView() = default;
...@@ -318,11 +321,6 @@ int NativeFileSystemUsageBubbleView::GetDialogButtons() const { ...@@ -318,11 +321,6 @@ int NativeFileSystemUsageBubbleView::GetDialogButtons() const {
return ui::DIALOG_BUTTON_OK; return ui::DIALOG_BUTTON_OK;
} }
base::string16 NativeFileSystemUsageBubbleView::GetDialogButtonLabel(
ui::DialogButton button) const {
return l10n_util::GetStringUTF16(IDS_DONE);
}
bool NativeFileSystemUsageBubbleView::ShouldShowCloseButton() const { bool NativeFileSystemUsageBubbleView::ShouldShowCloseButton() const {
return true; return true;
} }
......
...@@ -64,7 +64,6 @@ class NativeFileSystemUsageBubbleView : public LocationBarBubbleDelegateView, ...@@ -64,7 +64,6 @@ class NativeFileSystemUsageBubbleView : public LocationBarBubbleDelegateView,
// LocationBarBubbleDelegateView: // LocationBarBubbleDelegateView:
base::string16 GetAccessibleWindowTitle() const override; base::string16 GetAccessibleWindowTitle() const override;
int GetDialogButtons() const override; int GetDialogButtons() const override;
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
bool ShouldShowCloseButton() const override; bool ShouldShowCloseButton() const override;
void Init() override; void Init() override;
void WindowClosing() override; void WindowClosing() override;
......
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