Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ads] Fixes NotifyTab[Text|Html]ContentDidChange are not triggered for domains blocked by aggressive tracker and ad blocking #25976

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions browser/brave_ads/tabs/ads_tab_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "components/sessions/content/session_tab_helper.h"
#include "components/sessions/core/session_id.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/page.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "net/http/http_response_headers.h"
Expand Down Expand Up @@ -327,6 +328,18 @@ void AdsTabHelper::MaybeNotifyTabdidClose() {
}
}

void AdsTabHelper::PrimaryPageChanged(content::Page& page) {
if (!ads_service_) {
// No-op if the ads service is unavailable.
return;
}

// Calling `ResetNavigationState` from `DidStartNavigation` causes an issue
// where `NotifyTab[Text|Html]ContentDidChange` is not triggered when a user
// enables aggressive tracker and ad blocking, then proceeds to the page.
ResetNavigationState();
}

void AdsTabHelper::DidStartNavigation(
content::NavigationHandle* navigation_handle) {
if (!ads_service_ || !navigation_handle->IsInPrimaryMainFrame()) {
Expand All @@ -337,8 +350,6 @@ void AdsTabHelper::DidStartNavigation(
navigation_handle->GetRestoreType() == content::RestoreType::kRestored;

is_new_navigation_ = IsNewNavigation(navigation_handle);

ResetNavigationState();
}

void AdsTabHelper::DidFinishNavigation(
Expand Down
1 change: 1 addition & 0 deletions browser/brave_ads/tabs/ads_tab_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class AdsTabHelper : public content::WebContentsObserver,
void MaybeNotifyTabdidClose();

// content::WebContentsObserver:
void PrimaryPageChanged(content::Page& page) override;
void DidStartNavigation(
content::NavigationHandle* navigation_handle) override;
void DidFinishNavigation(
Expand Down
Loading