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

Side by Side Diff: ios/chrome/browser/web/blocked_popup_handler.h

Issue 2640463002: [ios] Convert BlockedPopupHandler into a tab helper class. (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « ios/chrome/browser/tabs/tab.mm ('k') | ios/chrome/browser/web/blocked_popup_handler.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_HANDLER_H_
6 #define IOS_CHROME_BROWSER_WEB_BLOCKED_POPUP_HANDLER_H_ 6 #define IOS_CHROME_BROWSER_WEB_BLOCKED_POPUP_HANDLER_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 #include "ios/web/public/web_state/web_state_user_data.h"
Eugene But (OOO till 7-30) 2017/01/17 18:04:53 nit: s/include/import
rohitrao (ping after 24h) 2017/01/17 21:49:29 I thought there was a presubmit that would have ca
Eugene But (OOO till 7-30) 2017/01/17 22:10:21 Still on review :( https://codereview.chromium.org
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"
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 BlockedPopupHandler : public infobars::InfoBarManager::Observer,
21 public web::WebStateUserData<BlockedPopupHandler> {
26 public: 22 public:
27 explicit BlockedPopupHandler(ios::ChromeBrowserState* browser_state); 23 static void CreateForWebState(web::WebState* web_state);
Eugene But (OOO till 7-30) 2017/01/17 18:04:53 Do you actually need this method? WebStateUserData
rohitrao (ping after 24h) 2017/01/17 21:49:29 Done.
28 ~BlockedPopupHandler() override; 24 ~BlockedPopupHandler() override;
29 25
30 void SetDelegate(id<BlockedPopupHandlerDelegate> delegate); 26 // Initalizes this BlockedPopupHandler. Must be called after all tab helpers
Eugene But (OOO till 7-30) 2017/01/17 18:04:53 Would Sylvain's proposal work for you? Alternative
rohitrao (ping after 24h) 2017/01/17 21:49:29 Sylvain's suggestion allows me to sidestep this is
27 // have been created.
28 void Initialize();
31 29
32 // Show the popup blocker infobar for the given popup. 30 // Show the popup blocker infobar for the given popup.
33 void HandlePopup(const web::BlockedPopupInfo& blocked_popup_info); 31 void HandlePopup(const web::BlockedPopupInfo& blocked_popup_info);
34 32
35 // infobars::InfoBarManager::Observer implementation. 33 // infobars::InfoBarManager::Observer implementation.
36 void OnInfoBarRemoved(infobars::InfoBar* infobar, bool animate) override; 34 void OnInfoBarRemoved(infobars::InfoBar* infobar, bool animate) override;
37 void OnManagerShuttingDown( 35 void OnManagerShuttingDown(
38 infobars::InfoBarManager* infobar_manager) override; 36 infobars::InfoBarManager* infobar_manager) override;
39 37
40 private: 38 private:
39 explicit BlockedPopupHandler(web::WebState* web_state);
40
41 // Show the infobar for the current popups. Will also handle replacing an 41 // Show the infobar for the current popups. Will also handle replacing an
42 // existing infobar with the updated count. 42 // existing infobar with the updated count.
43 void ShowInfoBar(); 43 void ShowInfoBar();
44 44
45 // The user browser state. 45 // The WebState that this object is attached to.
46 ios::ChromeBrowserState* browser_state_; 46 web::WebState* web_state_;
47 // The delegate that will display the infobar.
48 id<BlockedPopupHandlerDelegate> delegate_;
49 // The currently displayed infobar. 47 // The currently displayed infobar.
50 infobars::InfoBar* infobar_; 48 infobars::InfoBar* infobar_;
51 // The popups to open. 49 // The popups to open.
52 std::vector<web::BlockedPopupInfo> popups_; 50 std::vector<web::BlockedPopupInfo> popups_;
53 // For management of infobars::InfoBarManager::Observer registration. 51 // For management of infobars::InfoBarManager::Observer registration.
54 ScopedObserver<infobars::InfoBarManager, infobars::InfoBarManager::Observer> 52 ScopedObserver<infobars::InfoBarManager, infobars::InfoBarManager::Observer>
55 scoped_observer_; 53 scoped_observer_;
56 54
57 DISALLOW_COPY_AND_ASSIGN(BlockedPopupHandler); 55 DISALLOW_COPY_AND_ASSIGN(BlockedPopupHandler);
58 }; 56 };
59 57
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_ 58 #endif // IOS_CHROME_BROWSER_WEB_BLOCKED_POPUP_HANDLER_H_
OLDNEW
« no previous file with comments | « ios/chrome/browser/tabs/tab.mm ('k') | ios/chrome/browser/web/blocked_popup_handler.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698