Chromium Code Reviews| Index: chrome/browser/ui/views/global_error_bubble_view.cc |
| diff --git a/chrome/browser/ui/views/global_error_bubble_view.cc b/chrome/browser/ui/views/global_error_bubble_view.cc |
| index 7d46d5474fae069fa312a904c099ccd7b80fbbe4..31281135ec3e9bf75d49163c4cf719246497781b 100644 |
| --- a/chrome/browser/ui/views/global_error_bubble_view.cc |
| +++ b/chrome/browser/ui/views/global_error_bubble_view.cc |
| @@ -28,21 +28,11 @@ |
| namespace { |
| -enum { |
| - TAG_ACCEPT_BUTTON = 1, |
| - TAG_CANCEL_BUTTON, |
| -}; |
| - |
| -const int kMaxBubbleViewWidth = 262; |
| +const int kMaxBubbleViewWidth = 362; |
| // The vertical inset of the app bubble anchor from the app menu button. |
| const int kAnchorVerticalInset = 5; |
| -const int kBubblePadding = 19; |
| - |
| -// Spacing between bubble text and buttons. |
| -const int kLabelToButtonVerticalSpacing = 14; |
| - |
| } // namespace |
| // GlobalErrorBubbleViewBase --------------------------------------------------- |
| @@ -55,7 +45,7 @@ GlobalErrorBubbleViewBase* GlobalErrorBubbleViewBase::ShowStandardBubbleView( |
| views::View* app_menu_button = browser_view->toolbar()->app_menu_button(); |
| GlobalErrorBubbleView* bubble_view = new GlobalErrorBubbleView( |
| app_menu_button, views::BubbleBorder::TOP_RIGHT, browser, error); |
| - views::BubbleDelegateView::CreateBubble(bubble_view); |
| + views::BubbleDialogDelegateView::CreateBubble(bubble_view); |
| bubble_view->GetWidget()->Show(); |
| return bubble_view; |
| } |
| @@ -67,13 +57,9 @@ GlobalErrorBubbleView::GlobalErrorBubbleView( |
| views::BubbleBorder::Arrow arrow, |
| Browser* browser, |
| const base::WeakPtr<GlobalErrorWithStandardBubble>& error) |
| - : BubbleDelegateView(anchor_view, arrow), |
| + : BubbleDialogDelegateView(anchor_view, arrow), |
| browser_(browser), |
| error_(error) { |
| - // Set content margins to left-align the bubble text with the title. |
| - // BubbleFrameView adds enough padding below title, no top padding needed. |
| - set_margins(gfx::Insets(0, kBubblePadding, kBubblePadding, kBubblePadding)); |
| - |
| // Compensate for built-in vertical padding in the anchor view's image. |
| set_anchor_view_insets( |
| gfx::Insets(kAnchorVerticalInset, 0, kAnchorVerticalInset, 0)); |
| @@ -83,50 +69,17 @@ GlobalErrorBubbleView::GlobalErrorBubbleView( |
| for (size_t i = 0; i < message_strings.size(); ++i) { |
| views::Label* message_label = new views::Label(message_strings[i]); |
| message_label->SetMultiLine(true); |
| - message_label->SizeToFit(kMaxBubbleViewWidth); |
| message_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| message_labels.push_back(message_label); |
| } |
| - base::string16 accept_string(error_->GetBubbleViewAcceptButtonLabel()); |
| - scoped_ptr<views::BlueButton> accept_button( |
| - new views::BlueButton(this, accept_string)); |
| - accept_button->SetIsDefault(true); |
| - accept_button->set_tag(TAG_ACCEPT_BUTTON); |
| - |
| - if (error_->ShouldAddElevationIconToAcceptButton()) |
| - elevation_icon_setter_.reset( |
| - new ElevationIconSetter( |
| - accept_button.get(), |
| - base::Bind(&GlobalErrorBubbleView::SizeToContents, |
| - base::Unretained(this)))); |
| - |
| - base::string16 cancel_string(error_->GetBubbleViewCancelButtonLabel()); |
| - scoped_ptr<views::LabelButton> cancel_button; |
| - if (!cancel_string.empty()) { |
| - cancel_button.reset(new views::LabelButton(this, cancel_string)); |
| - cancel_button->SetStyle(views::Button::STYLE_BUTTON); |
| - cancel_button->set_tag(TAG_CANCEL_BUTTON); |
| - } |
| - |
| views::GridLayout* layout = new views::GridLayout(this); |
| SetLayoutManager(layout); |
| // First row, message labels. |
| views::ColumnSet* cs = layout->AddColumnSet(0); |
| - cs->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, |
| - 1, views::GridLayout::USE_PREF, 0, 0); |
| - |
| - // Second row, accept and cancel button. |
| - cs = layout->AddColumnSet(1); |
| - cs->AddPaddingColumn(1, views::kRelatedControlHorizontalSpacing); |
| - cs->AddColumn(views::GridLayout::TRAILING, views::GridLayout::LEADING, |
| - 0, views::GridLayout::USE_PREF, 0, 0); |
| - if (cancel_button.get()) { |
| - cs->AddPaddingColumn(0, views::kRelatedButtonHSpacing); |
| - cs->AddColumn(views::GridLayout::TRAILING, views::GridLayout::LEADING, |
| - 0, views::GridLayout::USE_PREF, 0, 0); |
| - } |
| + cs->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, |
| + views::GridLayout::FIXED, kMaxBubbleViewWidth, 0); |
| for (size_t i = 0; i < message_labels.size(); ++i) { |
| layout->StartRow(1, 0); |
| @@ -134,16 +87,6 @@ GlobalErrorBubbleView::GlobalErrorBubbleView( |
| if (i < message_labels.size() - 1) |
| layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| } |
| - layout->AddPaddingRow(0, kLabelToButtonVerticalSpacing); |
| - |
| - layout->StartRow(0, 1); |
| - layout->AddView(accept_button.release()); |
| - if (cancel_button.get()) |
| - layout->AddView(cancel_button.release()); |
| - |
| - // Adjust the message label size in case buttons are too long. |
| - for (size_t i = 0; i < message_labels.size(); ++i) |
| - message_labels[i]->SizeToFit(layout->GetPreferredSize(this).width()); |
| // These bubbles show at times where activation is sporadic (like at startup, |
| // or a new window opening). Make sure the bubble doesn't disappear before the |
| @@ -157,19 +100,6 @@ GlobalErrorBubbleView::~GlobalErrorBubbleView() { |
| elevation_icon_setter_.reset(); |
| } |
| -void GlobalErrorBubbleView::ButtonPressed(views::Button* sender, |
| - const ui::Event& event) { |
| - if (error_) { |
| - if (sender->tag() == TAG_ACCEPT_BUTTON) |
| - error_->BubbleViewAcceptButtonPressed(browser_); |
| - else if (sender->tag() == TAG_CANCEL_BUTTON) |
| - error_->BubbleViewCancelButtonPressed(browser_); |
| - else |
| - NOTREACHED(); |
| - } |
| - GetWidget()->Close(); |
| -} |
| - |
| base::string16 GlobalErrorBubbleView::GetWindowTitle() const { |
| return error_->GetBubbleViewTitle(); |
| } |
| @@ -193,6 +123,38 @@ bool GlobalErrorBubbleView::ShouldShowCloseButton() const { |
| return error_ && error_->ShouldShowCloseButton(); |
| } |
| +bool GlobalErrorBubbleView::ShouldDefaultButtonBeBlue() const { |
| + return true; |
| +} |
| + |
| +base::string16 GlobalErrorBubbleView::GetDialogButtonLabel( |
| + ui::DialogButton button) const { |
| + return button == ui::DIALOG_BUTTON_OK |
| + ? error_->GetBubbleViewAcceptButtonLabel() |
| + : error_->GetBubbleViewCancelButtonLabel(); |
| +} |
| + |
| +int GlobalErrorBubbleView::GetDialogButtons() const { |
| + return ui::DIALOG_BUTTON_OK | |
| + (error_->GetBubbleViewCancelButtonLabel().empty() |
| + ? 0 |
| + : ui::DIALOG_BUTTON_CANCEL); |
| +} |
| + |
| +bool GlobalErrorBubbleView::Cancel() { |
| + error_->BubbleViewCancelButtonPressed(browser_); |
| + return true; |
| +} |
| + |
| +bool GlobalErrorBubbleView::Accept() { |
| + error_->BubbleViewAcceptButtonPressed(browser_); |
| + return true; |
| +} |
| + |
| +bool GlobalErrorBubbleView::Close() { |
| + return true; |
|
msw
2016/03/31 22:37:18
Why doesn't this call Cancel / Accept, like Dialog
Evan Stade
2016/04/01 20:58:15
hmm, I don't think so. ButtonPressed had a NOTREAC
|
| +} |
| + |
| void GlobalErrorBubbleView::CloseBubbleView() { |
| GetWidget()->Close(); |
| } |