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 62789d901a1a452384093144da1d94ce2f126c3a..3b807736b55ac8beed21ffd661536825563000e8 100644 |
| --- a/chrome/browser/ui/views/global_error_bubble_view.cc |
| +++ b/chrome/browser/ui/views/global_error_bubble_view.cc |
| @@ -74,12 +74,17 @@ GlobalErrorBubbleView::GlobalErrorBubbleView( |
| GlobalErrorBubbleView::~GlobalErrorBubbleView() {} |
| base::string16 GlobalErrorBubbleView::GetWindowTitle() const { |
| + if (!error_) |
| + return base::string16(); |
| return error_->GetBubbleViewTitle(); |
| } |
| gfx::ImageSkia GlobalErrorBubbleView::GetWindowIcon() { |
| - gfx::Image image = error_->GetBubbleViewIcon(); |
| - DCHECK(!image.IsEmpty()); |
| + gfx::Image image; |
| + if (error_) { |
| + image = error_->GetBubbleViewIcon(); |
| + DCHECK(!image.IsEmpty()); |
| + } |
| return *image.ToImageSkia(); |
| } |
| @@ -92,6 +97,8 @@ void GlobalErrorBubbleView::WindowClosing() { |
| error_->BubbleViewDidClose(browser_); |
| } |
| +// |error_| is assumed to be valid, and stay valid, at least until Init() |
|
sky
2017/01/26 19:06:07
optional: This comment applies to Init(), so I wou
CJ
2017/01/27 00:44:05
Done.
|
| +// returns. |
| void GlobalErrorBubbleView::Init() { |
| // Compensate for built-in vertical padding in the anchor view's image. |
| set_anchor_view_insets(gfx::Insets( |
| @@ -129,12 +136,14 @@ void GlobalErrorBubbleView::Init() { |
| void GlobalErrorBubbleView::UpdateButton(views::LabelButton* button, |
| ui::DialogButton type) { |
| - BubbleDialogDelegateView::UpdateButton(button, type); |
| - if (type == ui::DIALOG_BUTTON_OK && |
| - error_->ShouldAddElevationIconToAcceptButton()) { |
| - elevation_icon_setter_.reset(new ElevationIconSetter( |
| - button, base::Bind(&GlobalErrorBubbleView::SizeToContents, |
| - base::Unretained(this)))); |
| + if (error_) { |
| + BubbleDialogDelegateView::UpdateButton(button, type); |
| + if (type == ui::DIALOG_BUTTON_OK && |
| + error_->ShouldAddElevationIconToAcceptButton()) { |
| + elevation_icon_setter_.reset(new ElevationIconSetter( |
| + button, base::Bind(&GlobalErrorBubbleView::SizeToContents, |
| + base::Unretained(this)))); |
| + } |
| } |
| } |
| @@ -148,12 +157,16 @@ bool GlobalErrorBubbleView::ShouldDefaultButtonBeBlue() const { |
| base::string16 GlobalErrorBubbleView::GetDialogButtonLabel( |
| ui::DialogButton button) const { |
| + if (!error_) |
| + return base::string16(); |
| return button == ui::DIALOG_BUTTON_OK |
| ? error_->GetBubbleViewAcceptButtonLabel() |
| : error_->GetBubbleViewCancelButtonLabel(); |
| } |
| int GlobalErrorBubbleView::GetDialogButtons() const { |
| + if (!error_) |
| + return ui::DIALOG_BUTTON_NONE; |
| return ui::DIALOG_BUTTON_OK | |
| (error_->GetBubbleViewCancelButtonLabel().empty() |
| ? 0 |
| @@ -161,12 +174,14 @@ int GlobalErrorBubbleView::GetDialogButtons() const { |
| } |
| bool GlobalErrorBubbleView::Cancel() { |
| - error_->BubbleViewCancelButtonPressed(browser_); |
| + if (error_) |
| + error_->BubbleViewCancelButtonPressed(browser_); |
| return true; |
| } |
| bool GlobalErrorBubbleView::Accept() { |
| - error_->BubbleViewAcceptButtonPressed(browser_); |
| + if (error_) |
| + error_->BubbleViewAcceptButtonPressed(browser_); |
| return true; |
| } |