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/api/infobars/confirm_infobar_delegate.h" | 7 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" |
8 #include "chrome/browser/infobars/infobar_tab_helper.h" | 8 #include "chrome/browser/infobars/infobar_tab_helper.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/sessions/session_restore.h" | 10 #include "chrome/browser/sessions/session_restore.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 Browser* browser_; | 53 Browser* browser_; |
54 | 54 |
55 DISALLOW_COPY_AND_ASSIGN(SessionCrashedInfoBarDelegate); | 55 DISALLOW_COPY_AND_ASSIGN(SessionCrashedInfoBarDelegate); |
56 }; | 56 }; |
57 | 57 |
58 SessionCrashedInfoBarDelegate::SessionCrashedInfoBarDelegate( | 58 SessionCrashedInfoBarDelegate::SessionCrashedInfoBarDelegate( |
59 InfoBarTabHelper* infobar_helper) | 59 InfoBarTabHelper* infobar_helper) |
60 : ConfirmInfoBarDelegate(infobar_helper), | 60 : ConfirmInfoBarDelegate(infobar_helper), |
61 accepted_(false), | 61 accepted_(false), |
62 removed_notification_received_(false), | 62 removed_notification_received_(false), |
63 browser_(browser::FindBrowserWithWebContents(owner()->web_contents())) { | 63 browser_(browser::FindBrowserWithWebContents(owner()->GetWebContents())) { |
64 // TODO(pkasting,marja): Once InfoBars own they delegates, this is not needed | 64 // TODO(pkasting,marja): Once InfoBars own they delegates, this is not needed |
65 // any more. Then we can rely on delegates getting destroyed, and we can | 65 // any more. Then we can rely on delegates getting destroyed, and we can |
66 // initiate the session storage scavenging only in the destructor. (Currently, | 66 // initiate the session storage scavenging only in the destructor. (Currently, |
67 // info bars are leaked if they get closed while they're in background tabs.) | 67 // info bars are leaked if they get closed while they're in background tabs.) |
68 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, | 68 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, |
69 content::NotificationService::AllSources()); | 69 content::NotificationService::AllSources()); |
70 } | 70 } |
71 | 71 |
72 SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() { | 72 SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() { |
73 // If the info bar wasn't accepted, it was either dismissed or expired. In | 73 // If the info bar wasn't accepted, it was either dismissed or expired. In |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 if (browser->profile()->IsOffTheRecord()) | 137 if (browser->profile()->IsOffTheRecord()) |
138 return; | 138 return; |
139 | 139 |
140 // In ChromeBot tests, there might be a race. This line appears to get | 140 // In ChromeBot tests, there might be a race. This line appears to get |
141 // called during shutdown and |tab| can be NULL. | 141 // called during shutdown and |tab| can be NULL. |
142 TabContents* tab = chrome::GetActiveTabContents(browser); | 142 TabContents* tab = chrome::GetActiveTabContents(browser); |
143 if (!tab) | 143 if (!tab) |
144 return; | 144 return; |
145 | 145 |
146 // Don't show the info-bar if there are already info-bars showing. | 146 // Don't show the info-bar if there are already info-bars showing. |
147 if (tab->infobar_tab_helper()->infobar_count() > 0) | 147 if (tab->infobar_tab_helper()->GetInfoBarCount() > 0) |
148 return; | 148 return; |
149 | 149 |
150 tab->infobar_tab_helper()->AddInfoBar( | 150 tab->infobar_tab_helper()->AddInfoBar( |
151 new SessionCrashedInfoBarDelegate(tab->infobar_tab_helper())); | 151 new SessionCrashedInfoBarDelegate(tab->infobar_tab_helper())); |
152 } | 152 } |
153 | 153 |
154 } // namespace chrome | 154 } // namespace chrome |
OLD | NEW |