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

cbui: remove ExtensionInstallDialogView GetDialogButtonLabel

This dialog gets its strings from an ExtensionInstallPrompt::Prompt, via
the Get{Accept,Abort}ButtonLabel methods. Those methods, in turn, depend
on two fields of Prompt: type_ and extension_. Better yet, type_ is
already const.

I attempted to make extension_ const but wasn't able to do so.  Instead,
this change relies on the current behavior of that class, which is that
it is always used like this:

  auto prompt = make_unique<Prompt>();
  // somewhere else:
  prompt->set_extension(...);
  // yet a third place:
  ShowDialog(..., std::move(prompt), ...)

Not all the places where Prompt is constructed have ready access to the
extension it will eventually represent, which makes passing the
extension as a constructor parameter to Prompt infeasible. Rats.

This change calls the prompt from ExtensionInstallDialogView's
constructor to get the appropriate button labels and apply them.

Bug: 1011446
Change-Id: If4ceff51f3aa4a5ca3cb8c3013954748377c8544
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1872420Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708189}
parent eb3d7198
......@@ -247,10 +247,16 @@ ExtensionInstallDialogView::ExtensionInstallDialogView(
scroll_view_(nullptr),
handled_result_(false),
install_button_enabled_(false) {
DCHECK(prompt_->extension());
DialogDelegate::set_default_button(ui::DIALOG_BUTTON_CANCEL);
DialogDelegate::set_draggable(true);
if (prompt_->has_webstore_data())
DialogDelegate::SetExtraView(CreatePromptLink(this));
DialogDelegate::set_button_label(ui::DIALOG_BUTTON_OK,
prompt_->GetAcceptButtonLabel());
DialogDelegate::set_button_label(ui::DIALOG_BUTTON_CANCEL,
prompt_->GetAbortButtonLabel());
set_close_on_deactivate(false);
CreateContents();
......@@ -404,19 +410,6 @@ int ExtensionInstallDialogView::GetDialogButtons() const {
return buttons;
}
base::string16 ExtensionInstallDialogView::GetDialogButtonLabel(
ui::DialogButton button) const {
switch (button) {
case ui::DIALOG_BUTTON_OK:
return prompt_->GetAcceptButtonLabel();
case ui::DIALOG_BUTTON_CANCEL:
return prompt_->GetAbortButtonLabel();
default:
NOTREACHED();
return base::string16();
}
}
bool ExtensionInstallDialogView::IsDialogButtonEnabled(
ui::DialogButton button) const {
if (button == ui::DIALOG_BUTTON_OK)
......
......@@ -60,7 +60,6 @@ class ExtensionInstallDialogView : public views::BubbleDialogDelegateView,
bool Cancel() override;
bool Accept() override;
int GetDialogButtons() const override;
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override;
bool ShouldShowCloseButton() const 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