Commit bb1de628 authored by Charlie Harrison's avatar Charlie Harrison Committed by Commit Bot

Introduce the UrlListManager

This CL introduces the skeleton of a class which can drive the UI
of "blocked URL" lists (i.e. the popup and redirect setting bubbles).

Currently, it only exposes an observer interface to unify how popup
and redirect UI surfaces receive updates about new URLs that were
blocked.

Follow-up CLs can add functionality including storing the actual
blocked URLs within the manager.

Bug: 895555
Change-Id: I6e95cd4ca3c8d6109cbfdb770516dc6d18c98554
Reviewed-on: https://chromium-review.googlesource.com/c/1334420
Commit-Queue: Charlie Harrison <csharrison@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610035}
parent a4432b96
...@@ -91,6 +91,8 @@ jumbo_split_static_library("ui") { ...@@ -91,6 +91,8 @@ jumbo_split_static_library("ui") {
"blocked_content/scoped_visibility_tracker.h", "blocked_content/scoped_visibility_tracker.h",
"blocked_content/tab_under_navigation_throttle.cc", "blocked_content/tab_under_navigation_throttle.cc",
"blocked_content/tab_under_navigation_throttle.h", "blocked_content/tab_under_navigation_throttle.h",
"blocked_content/url_list_manager.cc",
"blocked_content/url_list_manager.h",
"bookmarks/bookmark_bar.h", "bookmarks/bookmark_bar.h",
"bookmarks/bookmark_bubble_observer.h", "bookmarks/bookmark_bubble_observer.h",
"bookmarks/bookmark_editor.cc", "bookmarks/bookmark_editor.cc",
......
...@@ -28,9 +28,7 @@ void FramebustBlockTabHelper::AddBlockedUrl(const GURL& blocked_url, ...@@ -28,9 +28,7 @@ void FramebustBlockTabHelper::AddBlockedUrl(const GURL& blocked_url,
callbacks_.push_back(std::move(click_callback)); callbacks_.push_back(std::move(click_callback));
DCHECK_EQ(blocked_urls_.size(), callbacks_.size()); DCHECK_EQ(blocked_urls_.size(), callbacks_.size());
for (Observer& observer : observers_) { manager_.NotifyObservers(0 /* id */, blocked_url);
observer.OnBlockedUrlAdded(blocked_url);
}
UpdateLocationBarUI(web_contents()); UpdateLocationBarUI(web_contents());
} }
...@@ -49,14 +47,6 @@ void FramebustBlockTabHelper::OnBlockedUrlClicked(size_t index) { ...@@ -49,14 +47,6 @@ void FramebustBlockTabHelper::OnBlockedUrlClicked(size_t index) {
ui::PAGE_TRANSITION_LINK, false)); ui::PAGE_TRANSITION_LINK, false));
} }
void FramebustBlockTabHelper::AddObserver(Observer* observer) {
observers_.AddObserver(observer);
}
void FramebustBlockTabHelper::RemoveObserver(const Observer* observer) {
observers_.RemoveObserver(observer);
}
FramebustBlockTabHelper::FramebustBlockTabHelper( FramebustBlockTabHelper::FramebustBlockTabHelper(
content::WebContents* web_contents) content::WebContents* web_contents)
: content::WebContentsObserver(web_contents) {} : content::WebContentsObserver(web_contents) {}
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/observer_list.h" #include "chrome/browser/ui/blocked_content/url_list_manager.h"
#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h" #include "content/public/browser/web_contents_user_data.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -27,16 +27,6 @@ class FramebustBlockTabHelper ...@@ -27,16 +27,6 @@ class FramebustBlockTabHelper
using ClickCallback = base::OnceCallback< using ClickCallback = base::OnceCallback<
void(const GURL&, size_t /* index */, size_t /* total_size */)>; void(const GURL&, size_t /* index */, size_t /* total_size */)>;
// There is expected to be at most one observer at a time.
class Observer {
public:
// Called whenever a new URL was blocked.
virtual void OnBlockedUrlAdded(const GURL& blocked_url) = 0;
protected:
virtual ~Observer() = default;
};
~FramebustBlockTabHelper() override; ~FramebustBlockTabHelper() override;
// Shows the blocked Framebust icon in the Omnibox for the |blocked_url|. // Shows the blocked Framebust icon in the Omnibox for the |blocked_url|.
...@@ -52,12 +42,11 @@ class FramebustBlockTabHelper ...@@ -52,12 +42,11 @@ class FramebustBlockTabHelper
// vector of blocked URLs. // vector of blocked URLs.
void OnBlockedUrlClicked(size_t index); void OnBlockedUrlClicked(size_t index);
void AddObserver(Observer* observer);
void RemoveObserver(const Observer* observer);
// Returns all of the currently blocked URLs. // Returns all of the currently blocked URLs.
const std::vector<GURL>& blocked_urls() const { return blocked_urls_; } const std::vector<GURL>& blocked_urls() const { return blocked_urls_; }
UrlListManager* manager() { return &manager_; }
private: private:
friend class content::WebContentsUserData<FramebustBlockTabHelper>; friend class content::WebContentsUserData<FramebustBlockTabHelper>;
...@@ -67,6 +56,8 @@ class FramebustBlockTabHelper ...@@ -67,6 +56,8 @@ class FramebustBlockTabHelper
void DidFinishNavigation( void DidFinishNavigation(
content::NavigationHandle* navigation_handle) override; content::NavigationHandle* navigation_handle) override;
UrlListManager manager_;
// Remembers all the currently blocked URLs. This is cleared on each // Remembers all the currently blocked URLs. This is cleared on each
// navigation. // navigation.
std::vector<GURL> blocked_urls_; std::vector<GURL> blocked_urls_;
...@@ -75,8 +66,6 @@ class FramebustBlockTabHelper ...@@ -75,8 +66,6 @@ class FramebustBlockTabHelper
// distribution of the URLs in blocked_urls(). // distribution of the URLs in blocked_urls().
std::vector<ClickCallback> callbacks_; std::vector<ClickCallback> callbacks_;
base::ObserverList<Observer>::Unchecked observers_;
DISALLOW_COPY_AND_ASSIGN(FramebustBlockTabHelper); DISALLOW_COPY_AND_ASSIGN(FramebustBlockTabHelper);
}; };
......
...@@ -54,14 +54,6 @@ PopupBlockerTabHelper::PopupBlockerTabHelper(content::WebContents* web_contents) ...@@ -54,14 +54,6 @@ PopupBlockerTabHelper::PopupBlockerTabHelper(content::WebContents* web_contents)
PopupBlockerTabHelper::~PopupBlockerTabHelper() { PopupBlockerTabHelper::~PopupBlockerTabHelper() {
} }
void PopupBlockerTabHelper::AddObserver(Observer* observer) {
observers_.AddObserver(observer);
}
void PopupBlockerTabHelper::RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer);
}
void PopupBlockerTabHelper::DidFinishNavigation( void PopupBlockerTabHelper::DidFinishNavigation(
content::NavigationHandle* navigation_handle) { content::NavigationHandle* navigation_handle) {
// Clear all page actions, blocked content notifications and browser actions // Clear all page actions, blocked content notifications and browser actions
...@@ -101,8 +93,7 @@ void PopupBlockerTabHelper::AddBlockedPopup( ...@@ -101,8 +93,7 @@ void PopupBlockerTabHelper::AddBlockedPopup(
std::move(*params), window_features, block_type); std::move(*params), window_features, block_type);
TabSpecificContentSettings::FromWebContents(web_contents())-> TabSpecificContentSettings::FromWebContents(web_contents())->
OnContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS); OnContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS);
for (auto& observer : observers_) manager_.NotifyObservers(id, blocked_popups_[id]->params.url);
observer.BlockedPopupAdded(id, blocked_popups_[id]->params.url);
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
// Should replace existing popup infobars, with an updated count of how many // Should replace existing popup infobars, with an updated count of how many
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
#include <memory> #include <memory>
#include "base/macros.h" #include "base/macros.h"
#include "base/observer_list.h"
#include "chrome/browser/ui/blocked_content/blocked_window_params.h" #include "chrome/browser/ui/blocked_content/blocked_window_params.h"
#include "chrome/browser/ui/blocked_content/popup_blocker.h" #include "chrome/browser/ui/blocked_content/popup_blocker.h"
#include "chrome/browser/ui/blocked_content/url_list_manager.h"
#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h" #include "content/public/browser/web_contents_user_data.h"
#include "ui/base/window_open_disposition.h" #include "ui/base/window_open_disposition.h"
...@@ -52,19 +52,8 @@ class PopupBlockerTabHelper ...@@ -52,19 +52,8 @@ class PopupBlockerTabHelper
kMaxValue = kClickedThroughAbusive kMaxValue = kClickedThroughAbusive
}; };
class Observer {
public:
virtual void BlockedPopupAdded(int32_t id, const GURL& url) {}
protected:
virtual ~Observer() = default;
};
~PopupBlockerTabHelper() override; ~PopupBlockerTabHelper() override;
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
// Returns the number of blocked popups. // Returns the number of blocked popups.
size_t GetBlockedPopupsCount() const; size_t GetBlockedPopupsCount() const;
...@@ -87,6 +76,8 @@ class PopupBlockerTabHelper ...@@ -87,6 +76,8 @@ class PopupBlockerTabHelper
// Logs a histogram measuring popup blocker actions. // Logs a histogram measuring popup blocker actions.
static void LogAction(Action action); static void LogAction(Action action);
UrlListManager* manager() { return &manager_; }
private: private:
struct BlockedRequest; struct BlockedRequest;
friend class content::WebContentsUserData<PopupBlockerTabHelper>; friend class content::WebContentsUserData<PopupBlockerTabHelper>;
...@@ -96,12 +87,12 @@ class PopupBlockerTabHelper ...@@ -96,12 +87,12 @@ class PopupBlockerTabHelper
// Called when the blocked popup notification is hidden. // Called when the blocked popup notification is hidden.
void HidePopupNotification(); void HidePopupNotification();
UrlListManager manager_;
// Note, this container should be sorted based on the position in the popup // Note, this container should be sorted based on the position in the popup
// list, so it is keyed by an id which is continually increased. // list, so it is keyed by an id which is continually increased.
std::map<int32_t, std::unique_ptr<BlockedRequest>> blocked_popups_; std::map<int32_t, std::unique_ptr<BlockedRequest>> blocked_popups_;
base::ObserverList<Observer>::Unchecked observers_;
int32_t next_id_ = 0; int32_t next_id_ = 0;
DISALLOW_COPY_AND_ASSIGN(PopupBlockerTabHelper); DISALLOW_COPY_AND_ASSIGN(PopupBlockerTabHelper);
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/blocked_content/url_list_manager.h"
UrlListManager::UrlListManager() = default;
UrlListManager::~UrlListManager() = default;
void UrlListManager::AddObserver(Observer* observer) {
observers_.AddObserver(observer);
}
void UrlListManager::RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer);
}
void UrlListManager::NotifyObservers(int32_t id, const GURL& url) {
for (auto& observer : observers_) {
observer.BlockedUrlAdded(id, url);
}
}
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_BLOCKED_CONTENT_URL_LIST_MANAGER_H_
#define CHROME_BROWSER_UI_BLOCKED_CONTENT_URL_LIST_MANAGER_H_
#include <stdint.h>
#include "base/macros.h"
#include "base/observer_list.h"
class GURL;
// This class manages lists of blocked URLs in order to drive UI surfaces.
// Currently it is used by the redirect / popup blocked UIs.
//
// TODO(csharrison): Currently this object is composed within the framebust /
// popup tab helpers. Eventually those objects could be replaced almost entirely
// by shared logic here.
class UrlListManager {
public:
class Observer {
public:
virtual ~Observer() {}
virtual void BlockedUrlAdded(int32_t id, const GURL& url) = 0;
};
UrlListManager();
~UrlListManager();
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
void NotifyObservers(int32_t id, const GURL& url);
private:
base::ObserverList<Observer>::Unchecked observers_;
DISALLOW_COPY_AND_ASSIGN(UrlListManager);
};
#endif // CHROME_BROWSER_UI_BLOCKED_CONTENT_URL_LIST_MANAGER_H_
...@@ -955,7 +955,7 @@ void ContentSettingCookiesBubbleModel::OnCustomLinkClicked() { ...@@ -955,7 +955,7 @@ void ContentSettingCookiesBubbleModel::OnCustomLinkClicked() {
// ContentSettingPopupBubbleModel ---------------------------------------------- // ContentSettingPopupBubbleModel ----------------------------------------------
class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup, class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup,
public PopupBlockerTabHelper::Observer { public UrlListManager::Observer {
public: public:
ContentSettingPopupBubbleModel(Delegate* delegate, ContentSettingPopupBubbleModel(Delegate* delegate,
WebContents* web_contents, WebContents* web_contents,
...@@ -966,7 +966,7 @@ class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup, ...@@ -966,7 +966,7 @@ class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup,
void CommitChanges() override; void CommitChanges() override;
// PopupBlockerTabHelper::Observer: // PopupBlockerTabHelper::Observer:
void BlockedPopupAdded(int32_t id, const GURL& url) override; void BlockedUrlAdded(int32_t id, const GURL& url) override;
// content::NotificationObserver: // content::NotificationObserver:
void Observe(int type, void Observe(int type,
...@@ -980,8 +980,7 @@ class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup, ...@@ -980,8 +980,7 @@ class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup,
return bubble_content().list_items[index].item_id; return bubble_content().list_items[index].item_id;
} }
ScopedObserver<PopupBlockerTabHelper, PopupBlockerTabHelper::Observer> ScopedObserver<UrlListManager, UrlListManager::Observer> url_list_observer_;
popup_blocker_observer_;
DISALLOW_COPY_AND_ASSIGN(ContentSettingPopupBubbleModel); DISALLOW_COPY_AND_ASSIGN(ContentSettingPopupBubbleModel);
}; };
...@@ -994,7 +993,7 @@ ContentSettingPopupBubbleModel::ContentSettingPopupBubbleModel( ...@@ -994,7 +993,7 @@ ContentSettingPopupBubbleModel::ContentSettingPopupBubbleModel(
web_contents, web_contents,
profile, profile,
CONTENT_SETTINGS_TYPE_POPUPS), CONTENT_SETTINGS_TYPE_POPUPS),
popup_blocker_observer_(this) { url_list_observer_(this) {
if (!web_contents) if (!web_contents)
return; return;
...@@ -1006,13 +1005,13 @@ ContentSettingPopupBubbleModel::ContentSettingPopupBubbleModel( ...@@ -1006,13 +1005,13 @@ ContentSettingPopupBubbleModel::ContentSettingPopupBubbleModel(
for (const auto& blocked_popup : blocked_popups) for (const auto& blocked_popup : blocked_popups)
AddListItem(CreateUrlListItem(blocked_popup.first, blocked_popup.second)); AddListItem(CreateUrlListItem(blocked_popup.first, blocked_popup.second));
popup_blocker_observer_.Add(helper); url_list_observer_.Add(helper->manager());
content_settings::RecordPopupsAction( content_settings::RecordPopupsAction(
content_settings::POPUPS_ACTION_DISPLAYED_BUBBLE); content_settings::POPUPS_ACTION_DISPLAYED_BUBBLE);
} }
void ContentSettingPopupBubbleModel::BlockedPopupAdded(int32_t id, void ContentSettingPopupBubbleModel::BlockedUrlAdded(int32_t id,
const GURL& url) { const GURL& url) {
AddListItem(CreateUrlListItem(id, url)); AddListItem(CreateUrlListItem(id, url));
} }
...@@ -1022,7 +1021,7 @@ void ContentSettingPopupBubbleModel::Observe( ...@@ -1022,7 +1021,7 @@ void ContentSettingPopupBubbleModel::Observe(
const content::NotificationDetails& details) { const content::NotificationDetails& details) {
ContentSettingSingleRadioGroup::Observe(type, source, details); ContentSettingSingleRadioGroup::Observe(type, source, details);
if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED)
popup_blocker_observer_.RemoveAll(); url_list_observer_.RemoveAll();
} }
void ContentSettingPopupBubbleModel::OnListItemClicked(int index, void ContentSettingPopupBubbleModel::OnListItemClicked(int index,
...@@ -1047,12 +1046,7 @@ void ContentSettingPopupBubbleModel::CommitChanges() { ...@@ -1047,12 +1046,7 @@ void ContentSettingPopupBubbleModel::CommitChanges() {
ContentSettingSingleRadioGroup::CommitChanges(); ContentSettingSingleRadioGroup::CommitChanges();
} }
ContentSettingPopupBubbleModel::~ContentSettingPopupBubbleModel() { ContentSettingPopupBubbleModel::~ContentSettingPopupBubbleModel() = default;
if (web_contents()) {
auto* helper = PopupBlockerTabHelper::FromWebContents(web_contents());
helper->RemoveObserver(this);
}
}
// ContentSettingMediaStreamBubbleModel ---------------------------------------- // ContentSettingMediaStreamBubbleModel ----------------------------------------
...@@ -1565,7 +1559,8 @@ ContentSettingFramebustBlockBubbleModel:: ...@@ -1565,7 +1559,8 @@ ContentSettingFramebustBlockBubbleModel::
: ContentSettingSingleRadioGroup(delegate, : ContentSettingSingleRadioGroup(delegate,
web_contents, web_contents,
profile, profile,
CONTENT_SETTINGS_TYPE_POPUPS) { CONTENT_SETTINGS_TYPE_POPUPS),
url_list_observer_(this) {
if (!web_contents) if (!web_contents)
return; return;
...@@ -1576,27 +1571,18 @@ ContentSettingFramebustBlockBubbleModel:: ...@@ -1576,27 +1571,18 @@ ContentSettingFramebustBlockBubbleModel::
for (const auto& blocked_url : helper->blocked_urls()) for (const auto& blocked_url : helper->blocked_urls())
AddListItem(CreateUrlListItem(0 /* id */, blocked_url)); AddListItem(CreateUrlListItem(0 /* id */, blocked_url));
helper->AddObserver(this); url_list_observer_.Add(helper->manager());
} }
ContentSettingFramebustBlockBubbleModel:: ContentSettingFramebustBlockBubbleModel::
~ContentSettingFramebustBlockBubbleModel() { ~ContentSettingFramebustBlockBubbleModel() = default;
if (web_contents()) {
FramebustBlockTabHelper::FromWebContents(web_contents())
->RemoveObserver(this);
}
}
void ContentSettingFramebustBlockBubbleModel::Observe( void ContentSettingFramebustBlockBubbleModel::Observe(
int type, int type,
const content::NotificationSource& source, const content::NotificationSource& source,
const content::NotificationDetails& details) { const content::NotificationDetails& details) {
// The order is important because ContentSettingBubbleModel::Observer() clears if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED)
// the value of |web_contents()|. url_list_observer_.RemoveAll();
if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) {
FramebustBlockTabHelper::FromWebContents(web_contents())
->RemoveObserver(this);
}
ContentSettingSingleRadioGroup::Observe(type, source, details); ContentSettingSingleRadioGroup::Observe(type, source, details);
} }
...@@ -1615,7 +1601,8 @@ ContentSettingFramebustBlockBubbleModel::AsFramebustBlockBubbleModel() { ...@@ -1615,7 +1601,8 @@ ContentSettingFramebustBlockBubbleModel::AsFramebustBlockBubbleModel() {
return this; return this;
} }
void ContentSettingFramebustBlockBubbleModel::OnBlockedUrlAdded( void ContentSettingFramebustBlockBubbleModel::BlockedUrlAdded(
int32_t id,
const GURL& blocked_url) { const GURL& blocked_url) {
AddListItem(CreateUrlListItem(0 /* id */, blocked_url)); AddListItem(CreateUrlListItem(0 /* id */, blocked_url));
} }
......
...@@ -14,10 +14,12 @@ ...@@ -14,10 +14,12 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/scoped_observer.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h"
#include "chrome/browser/ui/blocked_content/framebust_block_tab_helper.h" #include "chrome/browser/ui/blocked_content/framebust_block_tab_helper.h"
#include "chrome/browser/ui/blocked_content/url_list_manager.h"
#include "chrome/common/custom_handlers/protocol_handler.h" #include "chrome/common/custom_handlers/protocol_handler.h"
#include "components/content_settings/core/common/content_settings.h" #include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_types.h" #include "components/content_settings/core/common/content_settings_types.h"
...@@ -477,7 +479,7 @@ class ContentSettingSingleRadioGroup : public ContentSettingSimpleBubbleModel { ...@@ -477,7 +479,7 @@ class ContentSettingSingleRadioGroup : public ContentSettingSimpleBubbleModel {
// The model for the blocked Framebust bubble. // The model for the blocked Framebust bubble.
class ContentSettingFramebustBlockBubbleModel class ContentSettingFramebustBlockBubbleModel
: public ContentSettingSingleRadioGroup, : public ContentSettingSingleRadioGroup,
public FramebustBlockTabHelper::Observer { public UrlListManager::Observer {
public: public:
ContentSettingFramebustBlockBubbleModel(Delegate* delegate, ContentSettingFramebustBlockBubbleModel(Delegate* delegate,
content::WebContents* web_contents, content::WebContents* web_contents,
...@@ -495,12 +497,14 @@ class ContentSettingFramebustBlockBubbleModel ...@@ -495,12 +497,14 @@ class ContentSettingFramebustBlockBubbleModel
ContentSettingFramebustBlockBubbleModel* AsFramebustBlockBubbleModel() ContentSettingFramebustBlockBubbleModel* AsFramebustBlockBubbleModel()
override; override;
// FramebustBlockTabHelper::Observer: // UrlListManager::Observer:
void OnBlockedUrlAdded(const GURL& blocked_url) override; void BlockedUrlAdded(int32_t id, const GURL& blocked_url) override;
private: private:
ListItem CreateListItem(const GURL& url); ListItem CreateListItem(const GURL& url);
ScopedObserver<UrlListManager, UrlListManager::Observer> url_list_observer_;
DISALLOW_COPY_AND_ASSIGN(ContentSettingFramebustBlockBubbleModel); DISALLOW_COPY_AND_ASSIGN(ContentSettingFramebustBlockBubbleModel);
}; };
#endif // !defined(OS_ANDROID) #endif // !defined(OS_ANDROID)
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h" #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/ui/blocked_content/framebust_block_tab_helper.h" #include "chrome/browser/ui/blocked_content/framebust_block_tab_helper.h"
#include "chrome/browser/ui/blocked_content/url_list_manager.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h"
#include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_finder.h"
...@@ -42,7 +43,7 @@ const int kDisallowRadioButtonIndex = 1; ...@@ -42,7 +43,7 @@ const int kDisallowRadioButtonIndex = 1;
} // namespace } // namespace
class FramebustBlockBrowserTest : public InProcessBrowserTest, class FramebustBlockBrowserTest : public InProcessBrowserTest,
public FramebustBlockTabHelper::Observer { public UrlListManager::Observer {
public: public:
FramebustBlockBrowserTest() { FramebustBlockBrowserTest() {
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
...@@ -55,11 +56,12 @@ class FramebustBlockBrowserTest : public InProcessBrowserTest, ...@@ -55,11 +56,12 @@ class FramebustBlockBrowserTest : public InProcessBrowserTest,
ASSERT_TRUE(embedded_test_server()->Start()); ASSERT_TRUE(embedded_test_server()->Start());
current_browser_ = InProcessBrowserTest::browser(); current_browser_ = InProcessBrowserTest::browser();
FramebustBlockTabHelper::FromWebContents(GetWebContents()) FramebustBlockTabHelper::FromWebContents(GetWebContents())
->manager()
->AddObserver(this); ->AddObserver(this);
} }
// FramebustBlockTabHelper::Observer: // UrlListManager::Observer:
void OnBlockedUrlAdded(const GURL& blocked_url) override { void BlockedUrlAdded(int32_t id, const GURL& blocked_url) override {
if (!blocked_url_added_closure_.is_null()) if (!blocked_url_added_closure_.is_null())
std::move(blocked_url_added_closure_).Run(); std::move(blocked_url_added_closure_).Run();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment