Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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 IOS_CHROME_BROWSER_WEB_BLOCKED_POPUP_HANDLER_H_ | 5 #ifndef IOS_CHROME_BROWSER_WEB_BLOCKED_POPUP_TAB_HELPER_H_ |
| 6 #define IOS_CHROME_BROWSER_WEB_BLOCKED_POPUP_HANDLER_H_ | 6 #define IOS_CHROME_BROWSER_WEB_BLOCKED_POPUP_TAB_HELPER_H_ |
| 7 | 7 |
| 8 #import <UIKit/UIKit.h> | 8 #import <UIKit/UIKit.h> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/scoped_observer.h" | 12 #include "base/scoped_observer.h" |
| 13 #include "components/infobars/core/infobar_manager.h" | 13 #include "components/infobars/core/infobar_manager.h" |
| 14 #import "ios/web/public/web_state/web_state_user_data.h" | |
| 14 #include "ios/web/web_state/blocked_popup_info.h" | 15 #include "ios/web/web_state/blocked_popup_info.h" |
| 15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
|
Eugene But (OOO till 7-30)
2017/01/17 22:10:21
nit: is this include still needed?
rohitrao (ping after 24h)
2017/01/23 15:30:29
Done.
| |
| 16 | 17 |
| 17 namespace ios { | |
| 18 class ChromeBrowserState; | |
| 19 } | |
| 20 | |
| 21 @protocol BlockedPopupHandlerDelegate; | |
| 22 | |
| 23 // Handles blocked popups. Will display an infobar informing the user and | 18 // Handles blocked popups. Will display an infobar informing the user and |
| 24 // allowing the user to add an exception and navigate to the site. | 19 // allowing the user to add an exception and navigate to the site. |
| 25 class BlockedPopupHandler : public infobars::InfoBarManager::Observer { | 20 class BlockedPopupTabHelper |
| 21 : public infobars::InfoBarManager::Observer, | |
| 22 public web::WebStateUserData<BlockedPopupTabHelper> { | |
| 26 public: | 23 public: |
| 27 explicit BlockedPopupHandler(ios::ChromeBrowserState* browser_state); | 24 explicit BlockedPopupTabHelper(web::WebState* web_state); |
| 28 ~BlockedPopupHandler() override; | 25 ~BlockedPopupTabHelper() override; |
| 29 | |
| 30 void SetDelegate(id<BlockedPopupHandlerDelegate> delegate); | |
| 31 | 26 |
| 32 // Show the popup blocker infobar for the given popup. | 27 // Show the popup blocker infobar for the given popup. |
|
Eugene But (OOO till 7-30)
2017/01/17 22:10:21
nit: s/Show/Shows
rohitrao (ping after 24h)
2017/01/23 15:30:29
Done.
| |
| 33 void HandlePopup(const web::BlockedPopupInfo& blocked_popup_info); | 28 void HandlePopup(const web::BlockedPopupInfo& blocked_popup_info); |
| 34 | 29 |
| 35 // infobars::InfoBarManager::Observer implementation. | 30 // infobars::InfoBarManager::Observer implementation. |
| 36 void OnInfoBarRemoved(infobars::InfoBar* infobar, bool animate) override; | 31 void OnInfoBarRemoved(infobars::InfoBar* infobar, bool animate) override; |
| 37 void OnManagerShuttingDown( | 32 void OnManagerShuttingDown( |
| 38 infobars::InfoBarManager* infobar_manager) override; | 33 infobars::InfoBarManager* infobar_manager) override; |
| 39 | 34 |
| 40 private: | 35 private: |
| 41 // Show the infobar for the current popups. Will also handle replacing an | 36 // Show the infobar for the current popups. Will also handle replacing an |
|
Eugene But (OOO till 7-30)
2017/01/17 22:10:21
ditto
rohitrao (ping after 24h)
2017/01/23 15:30:29
Done.
| |
| 42 // existing infobar with the updated count. | 37 // existing infobar with the updated count. |
| 43 void ShowInfoBar(); | 38 void ShowInfoBar(); |
| 44 | 39 |
| 45 // The user browser state. | 40 // Registers this object as an observer for the InfoBarManager associated with |
| 46 ios::ChromeBrowserState* browser_state_; | 41 // |web_state_|. Does nothing if already registered. |
| 47 // The delegate that will display the infobar. | 42 void RegisterAsInfoBarManagerObserverIfNeeded(); |
| 48 id<BlockedPopupHandlerDelegate> delegate_; | 43 |
| 44 // The WebState that this object is attached to. | |
| 45 web::WebState* web_state_; | |
| 49 // The currently displayed infobar. | 46 // The currently displayed infobar. |
| 50 infobars::InfoBar* infobar_; | 47 infobars::InfoBar* infobar_; |
| 51 // The popups to open. | 48 // The popups to open. |
| 52 std::vector<web::BlockedPopupInfo> popups_; | 49 std::vector<web::BlockedPopupInfo> popups_; |
| 53 // For management of infobars::InfoBarManager::Observer registration. | 50 // For management of infobars::InfoBarManager::Observer registration. This |
| 51 // object will not start observing the InfoBarManager until ShowInfoBars() is | |
| 52 // called. | |
| 54 ScopedObserver<infobars::InfoBarManager, infobars::InfoBarManager::Observer> | 53 ScopedObserver<infobars::InfoBarManager, infobars::InfoBarManager::Observer> |
| 55 scoped_observer_; | 54 scoped_observer_; |
| 56 | 55 |
| 57 DISALLOW_COPY_AND_ASSIGN(BlockedPopupHandler); | 56 DISALLOW_COPY_AND_ASSIGN(BlockedPopupTabHelper); |
| 58 }; | 57 }; |
| 59 | 58 |
| 60 // Methods implemented by the delegate of the BlockedPopupHandler. | 59 #endif // IOS_CHROME_BROWSER_WEB_BLOCKED_POPUP_TAB_HELPER_H_ |
| 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 |