| 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..bdbcd639e7f732d95f83f2143a03e8d59cee24bd 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();
|
| }
|
|
|
| @@ -93,6 +98,9 @@ void GlobalErrorBubbleView::WindowClosing() {
|
| }
|
|
|
| void GlobalErrorBubbleView::Init() {
|
| + // |error_| is assumed to be valid, and stay valid, at least until Init()
|
| + // returns.
|
| +
|
| // Compensate for built-in vertical padding in the anchor view's image.
|
| set_anchor_view_insets(gfx::Insets(
|
| GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0));
|
| @@ -129,12 +137,16 @@ 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_) {
|
| + // UpdateButton can result in calls back in to GlobalErrorBubbleView,
|
| + // possibly accessing |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 +160,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 +177,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;
|
| }
|
|
|
|
|