Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Unified Diff: ios/chrome/browser/web/blocked_popup_tab_helper.h

Issue 2640463002: [ios] Convert BlockedPopupHandler into a tab helper class. (Closed)
Patch Set: Review. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 59%
rename from ios/chrome/browser/web/blocked_popup_handler.h
rename to ios/chrome/browser/web/blocked_popup_tab_helper.h
index 0f03aa5ec98ef52e01612ec96d90b3b64122f19c..08d046466241fc935b31ba8b29a361e78b41ecad 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,23 +11,18 @@
#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"
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.
-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;
-
- void SetDelegate(id<BlockedPopupHandlerDelegate> delegate);
+ explicit BlockedPopupTabHelper(web::WebState* web_state);
+ ~BlockedPopupTabHelper() override;
// 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.
void HandlePopup(const web::BlockedPopupInfo& blocked_popup_info);
@@ -42,27 +37,23 @@ class BlockedPopupHandler : public infobars::InfoBarManager::Observer {
// 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();
+
+ // 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_

Powered by Google App Engine
This is Rietveld 408576698