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
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_UI_STARTUP_SESSION_CRASHED_INFOBAR_DELEGATE_H_
6#define CHROME_BROWSER_UI_STARTUP_SESSION_CRASHED_INFOBAR_DELEGATE_H_
7
8#include "base/gtest_prod_util.h"
9#include "base/memory/scoped_ptr.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"
13
14class Browser;
15class Profile;
16
17// A delegate for the InfoBar shown when the previous session has crashed.
18class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate,
19                                      public content::NotificationObserver {
20 public:
21  // If |browser| is not incognito, creates a session crashed infobar delegate
22  // and adds it to the InfoBarService for |browser|.
23  static void Create(Browser* browser);
24
25 private:
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);
34  virtual ~SessionCrashedInfoBarDelegate();
35
36  // ConfirmInfoBarDelegate:
37  virtual int GetIconID() const OVERRIDE;
38  virtual string16 GetMessageText() const OVERRIDE;
39  virtual int GetButtons() const OVERRIDE;
40  virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
41  virtual bool Accept() OVERRIDE;
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_;
49  bool accepted_;
50  bool removed_notification_received_;
51  Profile* profile_;
52
53  DISALLOW_COPY_AND_ASSIGN(SessionCrashedInfoBarDelegate);
54};
55
56#endif  // CHROME_BROWSER_UI_STARTUP_SESSION_CRASHED_INFOBAR_DELEGATE_H_
57