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 COMPONENTS_INFOBARS_CORE_SIMPLE_ALERT_INFOBAR_DELEGATE_H_ | 5 #ifndef COMPONENTS_INFOBARS_CORE_SIMPLE_ALERT_INFOBAR_DELEGATE_H_ |
6 #define COMPONENTS_INFOBARS_CORE_SIMPLE_ALERT_INFOBAR_DELEGATE_H_ | 6 #define COMPONENTS_INFOBARS_CORE_SIMPLE_ALERT_INFOBAR_DELEGATE_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
11 #include "components/infobars/core/confirm_infobar_delegate.h" | 11 #include "components/infobars/core/confirm_infobar_delegate.h" |
12 #include "ui/gfx/vector_icons_public.h" | 12 #include "ui/gfx/vector_icons_public.h" |
13 | 13 |
14 namespace infobars { | 14 namespace infobars { |
15 class InfoBarManager; | 15 class InfoBarManager; |
16 } | 16 } |
17 | 17 |
18 class SimpleAlertInfoBarDelegate : public ConfirmInfoBarDelegate { | 18 class SimpleAlertInfoBarDelegate : public ConfirmInfoBarDelegate { |
19 public: | 19 public: |
20 // Creates a simple alert infobar and delegate and adds the infobar to | 20 // Creates a simple alert infobar and delegate and adds the infobar to |
21 // |infobar_manager|. If |vector_icon_id| is not VECTOR_ICON_NONE, it will be | 21 // |infobar_manager|. If |vector_icon_id| is not VECTOR_ICON_NONE, it will be |
22 // shown; otherwise, |icon_id| (if present) will be used as the icon. | 22 // shown; otherwise, |icon_id| (if present) will be used as the icon. |
23 static void Create(infobars::InfoBarManager* infobar_manager, | 23 // |infobar_identifier| names what class triggered the infobar for metrics. |
24 int icon_id, | 24 static void Create( |
25 gfx::VectorIconId vector_icon_id, | 25 infobars::InfoBarManager* infobar_manager, |
26 const base::string16& message, | 26 infobars::InfoBarDelegate::InfoBarIdentifier infobar_identifier, |
27 bool auto_expire); | 27 int icon_id, |
| 28 gfx::VectorIconId vector_icon_id, |
| 29 const base::string16& message, |
| 30 bool auto_expire); |
28 | 31 |
29 private: | 32 private: |
30 SimpleAlertInfoBarDelegate(int icon_id, | 33 SimpleAlertInfoBarDelegate( |
31 gfx::VectorIconId vector_icon_id, | 34 infobars::InfoBarDelegate::InfoBarIdentifier infobar_identifier, |
32 const base::string16& message, | 35 int icon_id, |
33 bool auto_expire); | 36 gfx::VectorIconId vector_icon_id, |
| 37 const base::string16& message, |
| 38 bool auto_expire); |
34 ~SimpleAlertInfoBarDelegate() override; | 39 ~SimpleAlertInfoBarDelegate() override; |
35 | 40 |
36 // ConfirmInfoBarDelegate: | 41 // ConfirmInfoBarDelegate: |
| 42 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; |
37 int GetIconId() const override; | 43 int GetIconId() const override; |
38 gfx::VectorIconId GetVectorIconId() const override; | 44 gfx::VectorIconId GetVectorIconId() const override; |
39 bool ShouldExpire(const NavigationDetails& details) const override; | 45 bool ShouldExpire(const NavigationDetails& details) const override; |
40 base::string16 GetMessageText() const override; | 46 base::string16 GetMessageText() const override; |
41 int GetButtons() const override; | 47 int GetButtons() const override; |
42 | 48 |
| 49 infobars::InfoBarDelegate::InfoBarIdentifier infobar_identifier_; |
43 const int icon_id_; | 50 const int icon_id_; |
44 gfx::VectorIconId vector_icon_id_; | 51 gfx::VectorIconId vector_icon_id_; |
45 base::string16 message_; | 52 base::string16 message_; |
46 bool auto_expire_; // Should it expire automatically on navigation? | 53 bool auto_expire_; // Should it expire automatically on navigation? |
47 | 54 |
48 DISALLOW_COPY_AND_ASSIGN(SimpleAlertInfoBarDelegate); | 55 DISALLOW_COPY_AND_ASSIGN(SimpleAlertInfoBarDelegate); |
49 }; | 56 }; |
50 | 57 |
51 #endif // COMPONENTS_INFOBARS_CORE_SIMPLE_ALERT_INFOBAR_DELEGATE_H_ | 58 #endif // COMPONENTS_INFOBARS_CORE_SIMPLE_ALERT_INFOBAR_DELEGATE_H_ |
OLD | NEW |