OLD | NEW |
(Empty) | |
| 1 // Copyright 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 IOS_CHROME_BROWSER_WEB_BLOCKED_POPUP_HANDLER_H_ |
| 6 #define IOS_CHROME_BROWSER_WEB_BLOCKED_POPUP_HANDLER_H_ |
| 7 |
| 8 #import <UIKit/UIKit.h> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "base/scoped_observer.h" |
| 13 #include "components/infobars/core/infobar_manager.h" |
| 14 #include "ios/web/web_state/blocked_popup_info.h" |
| 15 #include "url/gurl.h" |
| 16 |
| 17 namespace ios { |
| 18 class ChromeBrowserState; |
| 19 } |
| 20 |
| 21 @protocol BlockedPopupHandlerDelegate; |
| 22 |
| 23 // Handles blocked popups. Will display an infobar informing the user and |
| 24 // allowing the user to add an exception and navigate to the site. |
| 25 class BlockedPopupHandler : public infobars::InfoBarManager::Observer { |
| 26 public: |
| 27 explicit BlockedPopupHandler(ios::ChromeBrowserState* browser_state); |
| 28 ~BlockedPopupHandler() override; |
| 29 |
| 30 void SetDelegate(id<BlockedPopupHandlerDelegate> delegate); |
| 31 |
| 32 // Show the popup blocker infobar for the given popup. |
| 33 void HandlePopup(const web::BlockedPopupInfo& blocked_popup_info); |
| 34 |
| 35 // infobars::InfoBarManager::Observer implementation. |
| 36 void OnInfoBarRemoved(infobars::InfoBar* infobar, bool animate) override; |
| 37 void OnManagerShuttingDown( |
| 38 infobars::InfoBarManager* infobar_manager) override; |
| 39 |
| 40 private: |
| 41 // Show the infobar for the current popups. Will also handle replacing an |
| 42 // existing infobar with the updated count. |
| 43 void ShowInfoBar(); |
| 44 |
| 45 // The user browser state. |
| 46 ios::ChromeBrowserState* browser_state_; |
| 47 // The delegate that will display the infobar. |
| 48 id<BlockedPopupHandlerDelegate> delegate_; |
| 49 // The currently displayed infobar. |
| 50 infobars::InfoBar* infobar_; |
| 51 // The popups to open. |
| 52 std::vector<web::BlockedPopupInfo> popups_; |
| 53 // For management of infobars::InfoBarManager::Observer registration. |
| 54 ScopedObserver<infobars::InfoBarManager, infobars::InfoBarManager::Observer> |
| 55 scoped_observer_; |
| 56 |
| 57 DISALLOW_COPY_AND_ASSIGN(BlockedPopupHandler); |
| 58 }; |
| 59 |
| 60 // Methods implemented by the delegate of the BlockedPopupHandler. |
| 61 @protocol BlockedPopupHandlerDelegate |
| 62 |
| 63 // Returns the infobars::InfoBarManager. |
| 64 - (infobars::InfoBarManager*)infoBarManager; |
| 65 |
| 66 @end |
| 67 |
| 68 #endif // IOS_CHROME_BROWSER_WEB_BLOCKED_POPUP_HANDLER_H_ |
OLD | NEW |