| 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/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.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 // |infobar_identifier| names what class triggered the infobar for metrics. |
| 23 static void Create(infobars::InfoBarManager* infobar_manager, | 24 static void Create(infobars::InfoBarManager* infobar_manager, |
| 25 const std::string& infobar_identifier, |
| 24 int icon_id, | 26 int icon_id, |
| 25 gfx::VectorIconId vector_icon_id, | 27 gfx::VectorIconId vector_icon_id, |
| 26 const base::string16& message, | 28 const base::string16& message, |
| 27 bool auto_expire); | 29 bool auto_expire); |
| 28 | 30 |
| 29 private: | 31 private: |
| 30 SimpleAlertInfoBarDelegate(int icon_id, | 32 SimpleAlertInfoBarDelegate(const std::string& infobar_identifier, |
| 33 int icon_id, |
| 31 gfx::VectorIconId vector_icon_id, | 34 gfx::VectorIconId vector_icon_id, |
| 32 const base::string16& message, | 35 const base::string16& message, |
| 33 bool auto_expire); | 36 bool auto_expire); |
| 34 ~SimpleAlertInfoBarDelegate() override; | 37 ~SimpleAlertInfoBarDelegate() override; |
| 35 | 38 |
| 36 // ConfirmInfoBarDelegate: | 39 // ConfirmInfoBarDelegate: |
| 40 std::string GetIdentifier() const override; |
| 37 int GetIconId() const override; | 41 int GetIconId() const override; |
| 38 gfx::VectorIconId GetVectorIconId() const override; | 42 gfx::VectorIconId GetVectorIconId() const override; |
| 39 bool ShouldExpire(const NavigationDetails& details) const override; | 43 bool ShouldExpire(const NavigationDetails& details) const override; |
| 40 base::string16 GetMessageText() const override; | 44 base::string16 GetMessageText() const override; |
| 41 int GetButtons() const override; | 45 int GetButtons() const override; |
| 42 | 46 |
| 47 const std::string infobar_identifier_; |
| 43 const int icon_id_; | 48 const int icon_id_; |
| 44 gfx::VectorIconId vector_icon_id_; | 49 gfx::VectorIconId vector_icon_id_; |
| 45 base::string16 message_; | 50 base::string16 message_; |
| 46 bool auto_expire_; // Should it expire automatically on navigation? | 51 bool auto_expire_; // Should it expire automatically on navigation? |
| 47 | 52 |
| 48 DISALLOW_COPY_AND_ASSIGN(SimpleAlertInfoBarDelegate); | 53 DISALLOW_COPY_AND_ASSIGN(SimpleAlertInfoBarDelegate); |
| 49 }; | 54 }; |
| 50 | 55 |
| 51 #endif // COMPONENTS_INFOBARS_CORE_SIMPLE_ALERT_INFOBAR_DELEGATE_H_ | 56 #endif // COMPONENTS_INFOBARS_CORE_SIMPLE_ALERT_INFOBAR_DELEGATE_H_ |
| OLD | NEW |