Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: chrome/browser/ui/startup/session_crashed_prompt.cc

Issue 10830353: Introduce InfoBarTabService API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to review comments Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 Browser* browser_; 52 Browser* browser_;
53 53
54 DISALLOW_COPY_AND_ASSIGN(SessionCrashedInfoBarDelegate); 54 DISALLOW_COPY_AND_ASSIGN(SessionCrashedInfoBarDelegate);
55 }; 55 };
56 56
57 SessionCrashedInfoBarDelegate::SessionCrashedInfoBarDelegate( 57 SessionCrashedInfoBarDelegate::SessionCrashedInfoBarDelegate(
58 InfoBarTabHelper* infobar_helper) 58 InfoBarTabHelper* infobar_helper)
59 : ConfirmInfoBarDelegate(infobar_helper), 59 : ConfirmInfoBarDelegate(infobar_helper),
60 accepted_(false), 60 accepted_(false),
61 removed_notification_received_(false), 61 removed_notification_received_(false),
62 browser_(browser::FindBrowserWithWebContents(owner()->web_contents())) { 62 browser_(browser::FindBrowserWithWebContents(owner()->GetWebContents())) {
63 // TODO(pkasting,marja): Once InfoBars own they delegates, this is not needed 63 // TODO(pkasting,marja): Once InfoBars own they delegates, this is not needed
64 // any more. Then we can rely on delegates getting destroyed, and we can 64 // any more. Then we can rely on delegates getting destroyed, and we can
65 // initiate the session storage scavenging only in the destructor. (Currently, 65 // initiate the session storage scavenging only in the destructor. (Currently,
66 // info bars are leaked if they get closed while they're in background tabs.) 66 // info bars are leaked if they get closed while they're in background tabs.)
67 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, 67 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
68 content::NotificationService::AllSources()); 68 content::NotificationService::AllSources());
69 } 69 }
70 70
71 SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() { 71 SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() {
72 // If the info bar wasn't accepted, it was either dismissed or expired. In 72 // 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
136 if (browser->profile()->IsOffTheRecord()) 136 if (browser->profile()->IsOffTheRecord())
137 return; 137 return;
138 138
139 // In ChromeBot tests, there might be a race. This line appears to get 139 // In ChromeBot tests, there might be a race. This line appears to get
140 // called during shutdown and |tab| can be NULL. 140 // called during shutdown and |tab| can be NULL.
141 TabContents* tab = chrome::GetActiveTabContents(browser); 141 TabContents* tab = chrome::GetActiveTabContents(browser);
142 if (!tab) 142 if (!tab)
143 return; 143 return;
144 144
145 // Don't show the info-bar if there are already info-bars showing. 145 // Don't show the info-bar if there are already info-bars showing.
146 if (tab->infobar_tab_helper()->infobar_count() > 0) 146 if (tab->infobar_tab_helper()->GetInfoBarCount() > 0)
147 return; 147 return;
148 148
149 tab->infobar_tab_helper()->AddInfoBar( 149 tab->infobar_tab_helper()->AddInfoBar(
150 new SessionCrashedInfoBarDelegate(tab->infobar_tab_helper())); 150 new SessionCrashedInfoBarDelegate(tab->infobar_tab_helper()));
151 } 151 }
152 152
153 } // namespace chrome 153 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698