Infobar material design refresh: layout
[chromium-blink-merge.git] / chrome / browser / ui / blocked_content / popup_blocker_tab_helper.h
blob1788b4243cecebe18f7449645005060cdc7b1b12
1 // Copyright 2013 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.
5 #ifndef CHROME_BROWSER_UI_BLOCKED_CONTENT_POPUP_BLOCKER_TAB_HELPER_H_
6 #define CHROME_BROWSER_UI_BLOCKED_CONTENT_POPUP_BLOCKER_TAB_HELPER_H_
8 #include <map>
10 #include "base/id_map.h"
11 #include "chrome/browser/ui/blocked_content/blocked_window_params.h"
12 #include "content/public/browser/web_contents_observer.h"
13 #include "content/public/browser/web_contents_user_data.h"
15 namespace chrome {
16 struct NavigateParams;
19 namespace blink {
20 struct WebWindowFeatures;
23 class GURL;
25 // Per-tab class to manage blocked popups.
26 class PopupBlockerTabHelper
27 : public content::WebContentsObserver,
28 public content::WebContentsUserData<PopupBlockerTabHelper> {
29 public:
30 // Mapping from popup IDs to blocked popup requests.
31 typedef std::map<int32, GURL> PopupIdMap;
33 ~PopupBlockerTabHelper() override;
35 // Returns true if the popup request defined by |params| should be blocked.
36 // In that case, it is also added to the |blocked_popups_| container.
37 bool MaybeBlockPopup(const chrome::NavigateParams& params,
38 const blink::WebWindowFeatures& window_features);
40 // Adds a popup request to the |blocked_popups_| container.
41 void AddBlockedPopup(const BlockedWindowParams& params);
43 // Creates the blocked popup with |popup_id|.
44 void ShowBlockedPopup(int32 popup_id);
46 // Returns the number of blocked popups.
47 size_t GetBlockedPopupsCount() const;
49 PopupIdMap GetBlockedPopupRequests();
51 // content::WebContentsObserver overrides:
52 void DidNavigateMainFrame(
53 const content::LoadCommittedDetails& details,
54 const content::FrameNavigateParams& params) override;
56 private:
57 struct BlockedRequest;
58 friend class content::WebContentsUserData<PopupBlockerTabHelper>;
60 explicit PopupBlockerTabHelper(content::WebContents* web_contents);
62 // Called when the blocked popup notification is shown or hidden.
63 void PopupNotificationVisibilityChanged(bool visible);
65 IDMap<BlockedRequest, IDMapOwnPointer> blocked_popups_;
67 DISALLOW_COPY_AND_ASSIGN(PopupBlockerTabHelper);
70 #endif // CHROME_BROWSER_UI_BLOCKED_CONTENT_POPUP_BLOCKER_TAB_HELPER_H_