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 #ifndef CHROME_BROWSER_UI_STARTUP_SESSION_CRASHED_INFOBAR_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_UI_STARTUP_SESSION_CRASHED_INFOBAR_DELEGATE_H_ |
6 #define CHROME_BROWSER_UI_STARTUP_SESSION_CRASHED_INFOBAR_DELEGATE_H_ | 6 #define CHROME_BROWSER_UI_STARTUP_SESSION_CRASHED_INFOBAR_DELEGATE_H_ |
7 | 7 |
| 8 #include "base/gtest_prod_util.h" |
| 9 #include "base/memory/scoped_ptr.h" |
8 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 10 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
| 11 #include "content/public/browser/notification_observer.h" |
| 12 #include "content/public/browser/notification_registrar.h" |
9 | 13 |
10 class Browser; | 14 class Browser; |
11 class Profile; | 15 class Profile; |
12 | 16 |
13 // A delegate for the InfoBar shown when the previous session has crashed. | 17 // A delegate for the InfoBar shown when the previous session has crashed. |
14 class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate { | 18 class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate, |
| 19 public content::NotificationObserver { |
15 public: | 20 public: |
16 // If |browser| is not incognito, creates a session crashed infobar and | 21 // If |browser| is not incognito, creates a session crashed infobar delegate |
17 // delegate and adds the infobar to the InfoBarService for |browser|. | 22 // and adds it to the InfoBarService for |browser|. |
18 static void Create(Browser* browser); | 23 static void Create(Browser* browser); |
19 | 24 |
20 private: | 25 private: |
21 explicit SessionCrashedInfoBarDelegate(Profile* profile); | 26 FRIEND_TEST_ALL_PREFIXES(SessionCrashedInfoBarDelegateUnitTest, |
| 27 DetachingTabWithCrashedInfoBar); |
| 28 #if defined(UNIT_TEST) |
| 29 friend struct base::DefaultDeleter<SessionCrashedInfoBarDelegate>; |
| 30 #endif |
| 31 |
| 32 SessionCrashedInfoBarDelegate(InfoBarService* infobar_service, |
| 33 Profile* profile); |
22 virtual ~SessionCrashedInfoBarDelegate(); | 34 virtual ~SessionCrashedInfoBarDelegate(); |
23 | 35 |
24 // ConfirmInfoBarDelegate: | 36 // ConfirmInfoBarDelegate: |
25 virtual int GetIconID() const OVERRIDE; | 37 virtual int GetIconID() const OVERRIDE; |
26 virtual string16 GetMessageText() const OVERRIDE; | 38 virtual string16 GetMessageText() const OVERRIDE; |
27 virtual int GetButtons() const OVERRIDE; | 39 virtual int GetButtons() const OVERRIDE; |
28 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 40 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
29 virtual bool Accept() OVERRIDE; | 41 virtual bool Accept() OVERRIDE; |
30 | 42 |
| 43 // content::NotificationObserver: |
| 44 virtual void Observe(int type, |
| 45 const content::NotificationSource& source, |
| 46 const content::NotificationDetails& details) OVERRIDE; |
| 47 |
| 48 content::NotificationRegistrar registrar_; |
31 bool accepted_; | 49 bool accepted_; |
| 50 bool removed_notification_received_; |
32 Profile* profile_; | 51 Profile* profile_; |
33 | 52 |
34 DISALLOW_COPY_AND_ASSIGN(SessionCrashedInfoBarDelegate); | 53 DISALLOW_COPY_AND_ASSIGN(SessionCrashedInfoBarDelegate); |
35 }; | 54 }; |
36 | 55 |
37 #endif // CHROME_BROWSER_UI_STARTUP_SESSION_CRASHED_INFOBAR_DELEGATE_H_ | 56 #endif // CHROME_BROWSER_UI_STARTUP_SESSION_CRASHED_INFOBAR_DELEGATE_H_ |
OLD | NEW |