diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-22 14:23:15 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-22 14:23:15 +0000 |
commit | 7ee15ed4f397aaf0f6ba5cde033cfb63c971781c (patch) | |
tree | 285798b8944a88baab210ef86ca0730bc212729d /chrome/browser | |
parent | af3847a1694dc6f83900d1d924d9b9dfc06c0cc4 (diff) | |
download | chromium_src-7ee15ed4f397aaf0f6ba5cde033cfb63c971781c.zip chromium_src-7ee15ed4f397aaf0f6ba5cde033cfb63c971781c.tar.gz chromium_src-7ee15ed4f397aaf0f6ba5cde033cfb63c971781c.tar.bz2 |
Fixes crash when clicking session restore button on info bar. The
crash can happen if you drag the tab showing the crashed info bar into
another browser, close the browser you dragged it out of, then click
the restore button.
BUG=93317
TEST=none
R=pkasting@chromium.org
Review URL: http://codereview.chromium.org/7692009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97635 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/ui/browser_init.cc | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc index 9e26e58..5e9cbc6 100644 --- a/chrome/browser/ui/browser_init.cc +++ b/chrome/browser/ui/browser_init.cc @@ -298,7 +298,7 @@ void CheckDefaultBrowserTask::Run() { // A delegate for the InfoBar shown when the previous session has crashed. class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate { public: - SessionCrashedInfoBarDelegate(Browser* browser, TabContents* contents); + SessionCrashedInfoBarDelegate(Profile* profile, TabContents* contents); private: virtual ~SessionCrashedInfoBarDelegate(); @@ -310,8 +310,6 @@ class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate { virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; virtual bool Accept() OVERRIDE; - Browser* browser_; - // The Profile that we restore sessions from. Profile* profile_; @@ -319,11 +317,10 @@ class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate { }; SessionCrashedInfoBarDelegate::SessionCrashedInfoBarDelegate( - Browser* browser, + Profile* profile, TabContents* contents) : ConfirmInfoBarDelegate(contents), - browser_(browser), - profile_(Profile::FromBrowserContext(contents->browser_context())) { + profile_(profile) { } SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() { @@ -350,14 +347,16 @@ string16 SessionCrashedInfoBarDelegate::GetButtonLabel( bool SessionCrashedInfoBarDelegate::Accept() { uint32 behavior = 0; - if (browser_->tab_count() == 1 && browser_->GetTabContentsAt(0)->GetURL() == + Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); + if (browser && browser->tab_count() == 1 + && browser->GetTabContentsAt(0)->GetURL() == GURL(chrome::kChromeUINewTabURL)) { // There is only one tab and its the new tab page, make session restore // clobber it. behavior = SessionRestore::CLOBBER_CURRENT_TAB; } SessionRestore::RestoreSession( - profile_, browser_, behavior, std::vector<GURL>()); + profile_, browser, behavior, std::vector<GURL>()); return true; } @@ -1085,13 +1084,12 @@ void BrowserInit::LaunchWithProfile::AddCrashedInfoBarIfNecessary( TabContentsWrapper* tab) { // Assume that if the user is launching incognito they were previously // running incognito so that we have nothing to restore from. - if (!profile_->DidLastSessionExitCleanly() && - !profile_->IsOffTheRecord()) { + if (!profile_->DidLastSessionExitCleanly() && !profile_->IsOffTheRecord()) { // The last session didn't exit cleanly. Show an infobar to the user // so that they can restore if they want. The delegate deletes itself when // it is closed. tab->AddInfoBar( - new SessionCrashedInfoBarDelegate(browser, tab->tab_contents())); + new SessionCrashedInfoBarDelegate(profile_, tab->tab_contents())); } } |