| Index: ios/chrome/browser/web/blocked_popup_tab_helper.h
|
| diff --git a/ios/chrome/browser/web/blocked_popup_handler.h b/ios/chrome/browser/web/blocked_popup_tab_helper.h
|
| similarity index 51%
|
| rename from ios/chrome/browser/web/blocked_popup_handler.h
|
| rename to ios/chrome/browser/web/blocked_popup_tab_helper.h
|
| index 0f03aa5ec98ef52e01612ec96d90b3b64122f19c..357d9c5d17a8086c9255885ba48551cfe77bea00 100644
|
| --- a/ios/chrome/browser/web/blocked_popup_handler.h
|
| +++ b/ios/chrome/browser/web/blocked_popup_tab_helper.h
|
| @@ -2,8 +2,8 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef IOS_CHROME_BROWSER_WEB_BLOCKED_POPUP_HANDLER_H_
|
| -#define IOS_CHROME_BROWSER_WEB_BLOCKED_POPUP_HANDLER_H_
|
| +#ifndef IOS_CHROME_BROWSER_WEB_BLOCKED_POPUP_TAB_HELPER_H_
|
| +#define IOS_CHROME_BROWSER_WEB_BLOCKED_POPUP_TAB_HELPER_H_
|
|
|
| #import <UIKit/UIKit.h>
|
| #include <vector>
|
| @@ -11,25 +11,19 @@
|
| #include "base/macros.h"
|
| #include "base/scoped_observer.h"
|
| #include "components/infobars/core/infobar_manager.h"
|
| +#import "ios/web/public/web_state/web_state_user_data.h"
|
| #include "ios/web/web_state/blocked_popup_info.h"
|
| -#include "url/gurl.h"
|
| -
|
| -namespace ios {
|
| -class ChromeBrowserState;
|
| -}
|
| -
|
| -@protocol BlockedPopupHandlerDelegate;
|
|
|
| // Handles blocked popups. Will display an infobar informing the user and
|
| // allowing the user to add an exception and navigate to the site.
|
| -class BlockedPopupHandler : public infobars::InfoBarManager::Observer {
|
| +class BlockedPopupTabHelper
|
| + : public infobars::InfoBarManager::Observer,
|
| + public web::WebStateUserData<BlockedPopupTabHelper> {
|
| public:
|
| - explicit BlockedPopupHandler(ios::ChromeBrowserState* browser_state);
|
| - ~BlockedPopupHandler() override;
|
| + explicit BlockedPopupTabHelper(web::WebState* web_state);
|
| + ~BlockedPopupTabHelper() override;
|
|
|
| - void SetDelegate(id<BlockedPopupHandlerDelegate> delegate);
|
| -
|
| - // Show the popup blocker infobar for the given popup.
|
| + // Shows the popup blocker infobar for the given popup.
|
| void HandlePopup(const web::BlockedPopupInfo& blocked_popup_info);
|
|
|
| // infobars::InfoBarManager::Observer implementation.
|
| @@ -38,31 +32,30 @@ class BlockedPopupHandler : public infobars::InfoBarManager::Observer {
|
| infobars::InfoBarManager* infobar_manager) override;
|
|
|
| private:
|
| - // Show the infobar for the current popups. Will also handle replacing an
|
| + friend class BlockedPopupTabHelperTest;
|
| +
|
| + // Shows the infobar for the current popups. Will also handle replacing an
|
| // existing infobar with the updated count.
|
| void ShowInfoBar();
|
|
|
| - // The user browser state.
|
| - ios::ChromeBrowserState* browser_state_;
|
| - // The delegate that will display the infobar.
|
| - id<BlockedPopupHandlerDelegate> delegate_;
|
| + // Registers this object as an observer for the InfoBarManager associated with
|
| + // |web_state_|. Does nothing if already registered.
|
| + void RegisterAsInfoBarManagerObserverIfNeeded(
|
| + infobars::InfoBarManager* infobar_manager);
|
| +
|
| + // The WebState that this object is attached to.
|
| + web::WebState* web_state_;
|
| // The currently displayed infobar.
|
| infobars::InfoBar* infobar_;
|
| // The popups to open.
|
| std::vector<web::BlockedPopupInfo> popups_;
|
| - // For management of infobars::InfoBarManager::Observer registration.
|
| + // For management of infobars::InfoBarManager::Observer registration. This
|
| + // object will not start observing the InfoBarManager until ShowInfoBars() is
|
| + // called.
|
| ScopedObserver<infobars::InfoBarManager, infobars::InfoBarManager::Observer>
|
| scoped_observer_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(BlockedPopupHandler);
|
| + DISALLOW_COPY_AND_ASSIGN(BlockedPopupTabHelper);
|
| };
|
|
|
| -// Methods implemented by the delegate of the BlockedPopupHandler.
|
| -@protocol BlockedPopupHandlerDelegate
|
| -
|
| -// Returns the infobars::InfoBarManager.
|
| -- (infobars::InfoBarManager*)infoBarManager;
|
| -
|
| -@end
|
| -
|
| -#endif // IOS_CHROME_BROWSER_WEB_BLOCKED_POPUP_HANDLER_H_
|
| +#endif // IOS_CHROME_BROWSER_WEB_BLOCKED_POPUP_TAB_HELPER_H_
|
|
|