popup_blocked_infobar_delegate.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2013 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. #ifndef COMPONENTS_BLOCKED_CONTENT_ANDROID_POPUP_BLOCKED_INFOBAR_DELEGATE_H_
  5. #define COMPONENTS_BLOCKED_CONTENT_ANDROID_POPUP_BLOCKED_INFOBAR_DELEGATE_H_
  6. #include "base/callback.h"
  7. #include "base/memory/raw_ptr.h"
  8. #include "components/infobars/core/confirm_infobar_delegate.h"
  9. #include "url/gurl.h"
  10. namespace infobars {
  11. class ContentInfoBarManager;
  12. }
  13. class HostContentSettingsMap;
  14. namespace blocked_content {
  15. class PopupBlockedInfoBarDelegate : public ConfirmInfoBarDelegate {
  16. public:
  17. // Creates a popup blocked infobar and delegate and adds the infobar to
  18. // |infobar_manager|. Returns true if the infobar was created, and false if it
  19. // replaced an existing popup infobar. |on_accept_callback| will be run if the
  20. // accept button is pressed on the infobar.
  21. static bool Create(infobars::ContentInfoBarManager* infobar_manager,
  22. int num_popups,
  23. HostContentSettingsMap* settings_map,
  24. base::OnceClosure on_accept_callback);
  25. ~PopupBlockedInfoBarDelegate() override;
  26. PopupBlockedInfoBarDelegate(const PopupBlockedInfoBarDelegate&) = delete;
  27. PopupBlockedInfoBarDelegate& operator=(const PopupBlockedInfoBarDelegate&) =
  28. delete;
  29. private:
  30. PopupBlockedInfoBarDelegate(int num_popups,
  31. const GURL& url,
  32. HostContentSettingsMap* map,
  33. base::OnceClosure on_accept_callback);
  34. // ConfirmInfoBarDelegate:
  35. infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override;
  36. int GetIconId() const override;
  37. PopupBlockedInfoBarDelegate* AsPopupBlockedInfoBarDelegate() override;
  38. std::u16string GetMessageText() const override;
  39. int GetButtons() const override;
  40. std::u16string GetButtonLabel(InfoBarButton button) const override;
  41. bool Accept() override;
  42. const int num_popups_;
  43. const GURL url_;
  44. raw_ptr<HostContentSettingsMap> map_;
  45. bool can_show_popups_;
  46. base::OnceClosure on_accept_callback_;
  47. };
  48. } // namespace blocked_content
  49. #endif // COMPONENTS_BLOCKED_CONTENT_ANDROID_POPUP_BLOCKED_INFOBAR_DELEGATE_H_