| 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_prompt.h" | 5 #include "chrome/browser/ui/startup/session_crashed_prompt.h" |
| 6 | 6 |
| 7 #include "chrome/browser/infobars/infobar_tab_helper.h" | 7 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/sessions/session_restore.h" | 9 #include "chrome/browser/sessions/session_restore.h" |
| 10 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 10 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
| 11 #include "chrome/browser/ui/tab_contents/tab_contents.h" | |
| 12 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_finder.h" | 12 #include "chrome/browser/ui/browser_finder.h" |
| 14 #include "chrome/browser/ui/browser_tabstrip.h" | 13 #include "chrome/browser/ui/browser_tabstrip.h" |
| 14 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 15 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
| 16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 17 #include "grit/chromium_strings.h" | 17 #include "grit/chromium_strings.h" |
| 18 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
| 19 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
| 20 #include "grit/theme_resources_standard.h" | 20 #include "grit/theme_resources_standard.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 22 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // clobber it. | 79 // clobber it. |
| 80 behavior = SessionRestore::CLOBBER_CURRENT_TAB; | 80 behavior = SessionRestore::CLOBBER_CURRENT_TAB; |
| 81 } | 81 } |
| 82 SessionRestore::RestoreSession( | 82 SessionRestore::RestoreSession( |
| 83 browser->profile(), browser, behavior, std::vector<GURL>()); | 83 browser->profile(), browser, behavior, std::vector<GURL>()); |
| 84 return true; | 84 return true; |
| 85 } | 85 } |
| 86 | 86 |
| 87 } // namespace | 87 } // namespace |
| 88 | 88 |
| 89 | 89 namespace chrome { |
| 90 namespace browser { | |
| 91 | 90 |
| 92 void ShowSessionCrashedPrompt(Browser* browser) { | 91 void ShowSessionCrashedPrompt(Browser* browser) { |
| 93 // Assume that if the user is launching incognito they were previously | 92 // Assume that if the user is launching incognito they were previously |
| 94 // running incognito so that we have nothing to restore from. | 93 // running incognito so that we have nothing to restore from. |
| 95 if (browser->profile()->IsOffTheRecord()) | 94 if (browser->profile()->IsOffTheRecord()) |
| 96 return; | 95 return; |
| 97 | 96 |
| 98 // In ChromeBot tests, there might be a race. This line appears to get | 97 // In ChromeBot tests, there might be a race. This line appears to get |
| 99 // called during shutdown and |tab| can be NULL. | 98 // called during shutdown and |tab| can be NULL. |
| 100 TabContents* tab = chrome::GetActiveTabContents(browser); | 99 TabContents* tab = chrome::GetActiveTabContents(browser); |
| 101 if (!tab) | 100 if (!tab) |
| 102 return; | 101 return; |
| 103 | 102 |
| 104 // Don't show the info-bar if there are already info-bars showing. | 103 // Don't show the info-bar if there are already info-bars showing. |
| 105 if (tab->infobar_tab_helper()->infobar_count() > 0) | 104 if (tab->infobar_tab_helper()->infobar_count() > 0) |
| 106 return; | 105 return; |
| 107 | 106 |
| 108 tab->infobar_tab_helper()->AddInfoBar( | 107 tab->infobar_tab_helper()->AddInfoBar( |
| 109 new SessionCrashedInfoBarDelegate(tab->infobar_tab_helper())); | 108 new SessionCrashedInfoBarDelegate(tab->infobar_tab_helper())); |
| 110 } | 109 } |
| 111 | 110 |
| 112 } // namespace browser | 111 } // namespace chrome |
| 113 | |
| OLD | NEW |