Commit 3c0cb920 authored by Colin Blundell's avatar Colin Blundell Committed by Chromium LUCI CQ

Restructure ChromeSubresourceFilterClient::ShowNotification() impl

This CL coalesces the implementation of
ChromeSubresourceFilterClient::ShowNotification() to simplify a
followup CL that will:

- Move the bulk of this implementation into a new
  ProfileInteractionManager::MaybeShowNotification(client) method that
  the throttle manager will invoke directly, with that method calling
  client->ShowNotification() and the only remaining code in
  ChromeSubresourceFilterClient::ShowNotification() being the actual
  showing of the infobar

With that followup CL, WebLayer will then share the core logic that will
be moved into ProfileInteractionManager. In this CL, however, there is
no behavioral change.

Bug: 1116095
Change-Id: Ia9d61d6ebc8c323cfc9054a58a22acbe89e27d22
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2628992
Commit-Queue: Colin Blundell <blundell@chromium.org>
Reviewed-by: default avatarCharlie Harrison <csharrison@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844816}
parent 66d0bc00
...@@ -82,7 +82,24 @@ void ChromeSubresourceFilterClient::ShowNotification() { ...@@ -82,7 +82,24 @@ void ChromeSubresourceFilterClient::ShowNotification() {
const GURL& top_level_url = web_contents_->GetLastCommittedURL(); const GURL& top_level_url = web_contents_->GetLastCommittedURL();
if (profile_context_->settings_manager()->ShouldShowUIForSite( if (profile_context_->settings_manager()->ShouldShowUIForSite(
top_level_url)) { top_level_url)) {
ShowUI(top_level_url); #if defined(OS_ANDROID)
InfoBarService* infobar_service =
InfoBarService::FromWebContents(web_contents_);
subresource_filter::AdsBlockedInfobarDelegate::Create(infobar_service);
#endif
// TODO(https://crbug.com/1103176): Plumb the actual frame reference here
// (it comes from
// ContentSubresourceFilterThrottleManager::DidDisallowFirstSubresource,
// which comes from a specific frame).
content_settings::PageSpecificContentSettings* content_settings =
content_settings::PageSpecificContentSettings::GetForFrame(
web_contents_->GetMainFrame());
content_settings->OnContentBlocked(ContentSettingsType::ADS);
subresource_filter::ContentSubresourceFilterThrottleManager::LogAction(
subresource_filter::SubresourceFilterAction::kUIShown);
profile_context_->settings_manager()->OnDidShowUI(top_level_url);
} else { } else {
subresource_filter::ContentSubresourceFilterThrottleManager::LogAction( subresource_filter::ContentSubresourceFilterThrottleManager::LogAction(
subresource_filter::SubresourceFilterAction::kUISuppressed); subresource_filter::SubresourceFilterAction::kUISuppressed);
...@@ -101,23 +118,3 @@ subresource_filter::ProfileInteractionManager* ...@@ -101,23 +118,3 @@ subresource_filter::ProfileInteractionManager*
ChromeSubresourceFilterClient::GetProfileInteractionManager() { ChromeSubresourceFilterClient::GetProfileInteractionManager() {
return profile_interaction_manager_.get(); return profile_interaction_manager_.get();
} }
void ChromeSubresourceFilterClient::ShowUI(const GURL& url) {
#if defined(OS_ANDROID)
InfoBarService* infobar_service =
InfoBarService::FromWebContents(web_contents_);
subresource_filter::AdsBlockedInfobarDelegate::Create(infobar_service);
#endif
// TODO(https://crbug.com/1103176): Plumb the actual frame reference here
// (it comes from
// ContentSubresourceFilterThrottleManager::DidDisallowFirstSubresource, which
// comes from a specific frame).
content_settings::PageSpecificContentSettings* content_settings =
content_settings::PageSpecificContentSettings::GetForFrame(
web_contents_->GetMainFrame());
content_settings->OnContentBlocked(ContentSettingsType::ADS);
subresource_filter::ContentSubresourceFilterThrottleManager::LogAction(
subresource_filter::SubresourceFilterAction::kUIShown);
profile_context_->settings_manager()->OnDidShowUI(url);
}
...@@ -12,8 +12,6 @@ ...@@ -12,8 +12,6 @@
#include "components/content_settings/core/common/content_settings.h" #include "components/content_settings/core/common/content_settings.h"
#include "components/subresource_filter/content/browser/subresource_filter_client.h" #include "components/subresource_filter/content/browser/subresource_filter_client.h"
class GURL;
namespace content { namespace content {
class WebContents; class WebContents;
} // namespace content } // namespace content
...@@ -51,8 +49,6 @@ class ChromeSubresourceFilterClient ...@@ -51,8 +49,6 @@ class ChromeSubresourceFilterClient
override; override;
private: private:
void ShowUI(const GURL& url);
content::WebContents* web_contents_; content::WebContents* web_contents_;
std::unique_ptr<subresource_filter::ContentSubresourceFilterThrottleManager> std::unique_ptr<subresource_filter::ContentSubresourceFilterThrottleManager>
......
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