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()->GetWebContents())) { | 63 browser_(chrome::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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // Don't show the info-bar if there are already info-bars showing. | 147 // Don't show the info-bar if there are already info-bars showing. |
148 InfoBarTabHelper* infobar_tab_helper = InfoBarTabHelper::FromWebContents(tab); | 148 InfoBarTabHelper* infobar_tab_helper = InfoBarTabHelper::FromWebContents(tab); |
149 if (infobar_tab_helper->GetInfoBarCount() > 0) | 149 if (infobar_tab_helper->GetInfoBarCount() > 0) |
150 return; | 150 return; |
151 | 151 |
152 infobar_tab_helper->AddInfoBar( | 152 infobar_tab_helper->AddInfoBar( |
153 new SessionCrashedInfoBarDelegate(infobar_tab_helper)); | 153 new SessionCrashedInfoBarDelegate(infobar_tab_helper)); |
154 } | 154 } |
155 | 155 |
156 } // namespace chrome | 156 } // namespace chrome |
OLD | NEW |