| 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 "build/build_config.h" | 7 #include "build/build_config.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 21 matching lines...) Expand all Loading... |
| 32 // Also, in ChromeBot tests, there might be a race. This code appears to be | 32 // Also, in ChromeBot tests, there might be a race. This code appears to be |
| 33 // called during shutdown when there is no active WebContents. | 33 // called during shutdown when there is no active WebContents. |
| 34 Profile* profile = browser->profile(); | 34 Profile* profile = browser->profile(); |
| 35 content::WebContents* web_contents = | 35 content::WebContents* web_contents = |
| 36 browser->tab_strip_model()->GetActiveWebContents(); | 36 browser->tab_strip_model()->GetActiveWebContents(); |
| 37 if (profile->IsOffTheRecord() || !web_contents) | 37 if (profile->IsOffTheRecord() || !web_contents) |
| 38 return; | 38 return; |
| 39 | 39 |
| 40 InfoBarService* infobar_service = | 40 InfoBarService* infobar_service = |
| 41 InfoBarService::FromWebContents(web_contents); | 41 InfoBarService::FromWebContents(web_contents); |
| 42 infobar_service->AddInfoBar( | 42 infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( |
| 43 infobar_service->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( | 43 std::unique_ptr<ConfirmInfoBarDelegate>( |
| 44 new SessionCrashedInfoBarDelegate(profile)))); | 44 new SessionCrashedInfoBarDelegate(profile)))); |
| 45 } | 45 } |
| 46 | 46 |
| 47 SessionCrashedInfoBarDelegate::SessionCrashedInfoBarDelegate(Profile* profile) | 47 SessionCrashedInfoBarDelegate::SessionCrashedInfoBarDelegate(Profile* profile) |
| 48 : ConfirmInfoBarDelegate(), | 48 : ConfirmInfoBarDelegate(), |
| 49 accepted_(false), | 49 accepted_(false), |
| 50 profile_(profile) { | 50 profile_(profile) { |
| 51 } | 51 } |
| 52 | 52 |
| 53 SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() { | 53 SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON); | 90 return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON); |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool SessionCrashedInfoBarDelegate::Accept() { | 93 bool SessionCrashedInfoBarDelegate::Accept() { |
| 94 Browser* browser = chrome::FindBrowserWithWebContents( | 94 Browser* browser = chrome::FindBrowserWithWebContents( |
| 95 InfoBarService::WebContentsFromInfoBar(infobar())); | 95 InfoBarService::WebContentsFromInfoBar(infobar())); |
| 96 SessionRestore::RestoreSessionAfterCrash(browser); | 96 SessionRestore::RestoreSessionAfterCrash(browser); |
| 97 accepted_ = true; | 97 accepted_ = true; |
| 98 return true; | 98 return true; |
| 99 } | 99 } |
| OLD | NEW |