| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/startup/session_crashed_infobar_delegate.h" | 5 #include "chrome/browser/ui/startup/session_crashed_infobar_delegate.h" |
| 6 | 6 |
| 7 #include "chrome/browser/infobars/infobar.h" | 7 #include "chrome/browser/infobars/infobar.h" |
| 8 #include "chrome/browser/infobars/infobar_service.h" | 8 #include "chrome/browser/infobars/infobar_service.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/search/search.h" | 10 #include "chrome/browser/search/search.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 } | 66 } |
| 67 | 67 |
| 68 base::string16 SessionCrashedInfoBarDelegate::GetButtonLabel( | 68 base::string16 SessionCrashedInfoBarDelegate::GetButtonLabel( |
| 69 InfoBarButton button) const { | 69 InfoBarButton button) const { |
| 70 DCHECK_EQ(BUTTON_OK, button); | 70 DCHECK_EQ(BUTTON_OK, button); |
| 71 return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON); | 71 return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON); |
| 72 } | 72 } |
| 73 | 73 |
| 74 bool SessionCrashedInfoBarDelegate::Accept() { | 74 bool SessionCrashedInfoBarDelegate::Accept() { |
| 75 uint32 behavior = 0; | 75 uint32 behavior = 0; |
| 76 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); | 76 content::WebContents* web_contents = |
| 77 InfoBarService::WebContentsFromInfoBar(infobar()); |
| 78 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
| 77 if (browser->tab_strip_model()->count() == 1) { | 79 if (browser->tab_strip_model()->count() == 1) { |
| 78 const content::WebContents* active_tab = | 80 const content::WebContents* active_tab = |
| 79 browser->tab_strip_model()->GetWebContentsAt(0); | 81 browser->tab_strip_model()->GetWebContentsAt(0); |
| 80 if (active_tab->GetURL() == GURL(chrome::kChromeUINewTabURL) || | 82 if (active_tab->GetURL() == GURL(chrome::kChromeUINewTabURL) || |
| 81 chrome::IsInstantNTP(active_tab)) { | 83 chrome::IsInstantNTP(active_tab)) { |
| 82 // There is only one tab and its the new tab page, make session restore | 84 // There is only one tab and its the new tab page, make session restore |
| 83 // clobber it. | 85 // clobber it. |
| 84 behavior = SessionRestore::CLOBBER_CURRENT_TAB; | 86 behavior = SessionRestore::CLOBBER_CURRENT_TAB; |
| 85 } | 87 } |
| 86 } | 88 } |
| 87 SessionRestore::RestoreSession(browser->profile(), browser, | 89 SessionRestore::RestoreSession(browser->profile(), browser, |
| 88 browser->host_desktop_type(), behavior, | 90 browser->host_desktop_type(), behavior, |
| 89 std::vector<GURL>()); | 91 std::vector<GURL>()); |
| 90 accepted_ = true; | 92 accepted_ = true; |
| 91 return true; | 93 return true; |
| 92 } | 94 } |
| OLD | NEW |