diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-25 01:55:10 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-25 01:55:10 +0000 |
commit | 818b9257c3348614cee083020d9b3414cb22e3f6 (patch) | |
tree | 7ae644f983c6c0b7080e933627ef1ed84b4ae754 /chrome/browser | |
parent | ab63e26f6872c804cb50637982dba419bfb1b45c (diff) | |
download | chromium_src-818b9257c3348614cee083020d9b3414cb22e3f6.zip chromium_src-818b9257c3348614cee083020d9b3414cb22e3f6.tar.gz chromium_src-818b9257c3348614cee083020d9b3414cb22e3f6.tar.bz2 |
Fix crash with plugin installer infobar due to the infobardelegate not being removed from the containing TabContents.
http://crbug.com/4620
Review URL: http://codereview.chromium.org/12624
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5957 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browser_init.cc | 3 | ||||
-rw-r--r-- | chrome/browser/infobar_delegate.h | 10 | ||||
-rw-r--r-- | chrome/browser/password_manager.cc | 8 | ||||
-rw-r--r-- | chrome/browser/password_manager.h | 4 | ||||
-rw-r--r-- | chrome/browser/plugin_installer.cc | 3 | ||||
-rw-r--r-- | chrome/browser/plugin_installer.h | 2 | ||||
-rw-r--r-- | chrome/browser/views/infobars/infobars.cc | 14 | ||||
-rw-r--r-- | chrome/browser/views/infobars/infobars.h | 4 |
8 files changed, 30 insertions, 18 deletions
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc index 88bb11c..f1a709a 100644 --- a/chrome/browser/browser_init.cc +++ b/chrome/browser/browser_init.cc @@ -74,10 +74,11 @@ class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate { virtual std::wstring GetButtonLabel(InfoBarButton button) const { return l10n_util::GetString(IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON); } - virtual void Accept() { + virtual bool Accept() { // Restore the session. SessionRestore::RestoreSession(profile_, NULL, false, true, false, std::vector<GURL>()); + return true; } private: diff --git a/chrome/browser/infobar_delegate.h b/chrome/browser/infobar_delegate.h index 33b750a..f23dea6 100644 --- a/chrome/browser/infobar_delegate.h +++ b/chrome/browser/infobar_delegate.h @@ -113,11 +113,13 @@ class ConfirmInfoBarDelegate : public AlertInfoBarDelegate { // returns "OK" for the OK button and "Cancel" for the Cancel button. virtual std::wstring GetButtonLabel(InfoBarButton button) const; - // Called when the OK button is pressed. - virtual void Accept() {} + // Called when the OK button is pressed. If the function returns true, the + // InfoBarDelegate should be removed from the associated TabContents. + virtual bool Accept() { return true; } - // Called when the Cancel button is pressed. - virtual void Cancel() {} + // Called when the Cancel button is pressed. If the function returns true, + // the InfoBarDelegate should be removed from the associated TabContents. + virtual bool Cancel() { return true; } // Overridden from InfoBarDelegate: virtual InfoBar* CreateInfoBar(); diff --git a/chrome/browser/password_manager.cc b/chrome/browser/password_manager.cc index 2bd8cdf..3edd0fea 100644 --- a/chrome/browser/password_manager.cc +++ b/chrome/browser/password_manager.cc @@ -210,13 +210,13 @@ std::wstring PasswordManager::GetButtonLabel(InfoBarButton button) const { return std::wstring(); } -void PasswordManager::Accept() { +bool PasswordManager::Accept() { pending_save_manager_->Save(); - web_contents_->RemoveInfoBar(this); + return true; } -void PasswordManager::Cancel() { +bool PasswordManager::Cancel() { pending_save_manager_->PermanentlyBlacklist(); - web_contents_->RemoveInfoBar(this); + return true; } diff --git a/chrome/browser/password_manager.h b/chrome/browser/password_manager.h index 584ffff..1b57082 100644 --- a/chrome/browser/password_manager.h +++ b/chrome/browser/password_manager.h @@ -67,8 +67,8 @@ class PasswordManager : public views::LoginModel, virtual SkBitmap* GetIcon() const; virtual int GetButtons() const; virtual std::wstring GetButtonLabel(InfoBarButton button) const; - virtual void Accept(); - virtual void Cancel(); + virtual bool Accept(); + virtual bool Cancel(); // When a form is "seen" on a page, a PasswordFormManager is created // and stored in this collection until user navigates away from page. diff --git a/chrome/browser/plugin_installer.cc b/chrome/browser/plugin_installer.cc index afd0314..444ff2d 100644 --- a/chrome/browser/plugin_installer.cc +++ b/chrome/browser/plugin_installer.cc @@ -61,6 +61,7 @@ std::wstring PluginInstaller::GetButtonLabel(InfoBarButton button) const { return ConfirmInfoBarDelegate::GetButtonLabel(button); } -void PluginInstaller::Accept() { +bool PluginInstaller::Accept() { web_contents_->render_view_host()->InstallMissingPlugin(); + return true; } diff --git a/chrome/browser/plugin_installer.h b/chrome/browser/plugin_installer.h index a3b479a..2ba3424 100644 --- a/chrome/browser/plugin_installer.h +++ b/chrome/browser/plugin_installer.h @@ -25,7 +25,7 @@ class PluginInstaller : public ConfirmInfoBarDelegate { virtual SkBitmap* GetIcon() const; virtual int GetButtons() const; virtual std::wstring GetButtonLabel(InfoBarButton button) const; - virtual void Accept(); + virtual bool Accept(); // The containing WebContents WebContents* web_contents_; diff --git a/chrome/browser/views/infobars/infobars.cc b/chrome/browser/views/infobars/infobars.cc index 466a74f..52fcf55 100644 --- a/chrome/browser/views/infobars/infobars.cc +++ b/chrome/browser/views/infobars/infobars.cc @@ -150,11 +150,15 @@ int InfoBar::GetAvailableWidth() const { return close_button_->x() - kIconLabelSpacing; } +void InfoBar::RemoveInfoBar() const { + container_->RemoveDelegate(delegate()); +} + // InfoBar, views::BaseButton::ButtonListener implementation: ------------------ void InfoBar::ButtonPressed(views::BaseButton* sender) { if (sender == close_button_) - container_->RemoveDelegate(delegate()); + RemoveInfoBar(); } // InfoBar, AnimationDelegate implementation: ---------------------------------- @@ -320,11 +324,11 @@ void ConfirmInfoBar::ViewHierarchyChanged(bool is_add, void ConfirmInfoBar::ButtonPressed(views::NativeButton* sender) { if (sender == ok_button_) { - GetDelegate()->Accept(); - AnimateClose(); + if (GetDelegate()->Accept()) + RemoveInfoBar(); } else if (sender == cancel_button_) { - GetDelegate()->Cancel(); - AnimateClose(); + if (GetDelegate()->Cancel()) + RemoveInfoBar(); } else { NOTREACHED(); } diff --git a/chrome/browser/views/infobars/infobars.h b/chrome/browser/views/infobars/infobars.h index f2ccc73..028632b 100644 --- a/chrome/browser/views/infobars/infobars.h +++ b/chrome/browser/views/infobars/infobars.h @@ -64,6 +64,10 @@ class InfoBar : public views::View, // excluding the close button. virtual int GetAvailableWidth() const; + // Removes our associated InfoBarDelegate from the associated TabContents. + // (Will lead to this InfoBar being closed). + void RemoveInfoBar() const; + private: // Overridden from views::Button::ButtonListener: virtual void ButtonPressed(views::BaseButton* sender); |