Skip to content

Commit

Permalink
Merge pull request #15816 from brave/bn-subscribe-load-time-uplift
Browse files Browse the repository at this point in the history
[Uplift] [Brave News]: Detect more feeds by running the feed detector after DOMContentLoaded fires
  • Loading branch information
kjozwiak authored Nov 7, 2022
2 parents c9700a5 + 32f6d99 commit 0f4afc7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 7 additions & 3 deletions browser/brave_news/brave_news_tab_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,18 @@ void BraveNewsTabHelper::AvailableFeedsChanged() {
void BraveNewsTabHelper::PrimaryPageChanged(content::Page& page) {
// Invalidate all weak pointers - we're on a new page now.
weak_ptr_factory_.InvalidateWeakPtrs();

rss_page_feeds_.clear();
AvailableFeedsChanged();
}

void BraveNewsTabHelper::DOMContentLoaded(content::RenderFrameHost* rfh) {
if (GetWebContents().GetPrimaryMainFrame() != rfh) {
return;
}
feed::FetchRssLinks(GetWebContents().GetLastCommittedURL(), &GetWebContents(),
base::BindOnce(&BraveNewsTabHelper::OnReceivedRssUrls,
weak_ptr_factory_.GetWeakPtr(),
GetWebContents().GetLastCommittedURL()));

AvailableFeedsChanged();
}

void BraveNewsTabHelper::OnPublishersUpdated(
Expand Down
5 changes: 5 additions & 0 deletions browser/brave_news/brave_news_tab_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"

namespace content {
class RenderFrameHost;
}

class BraveNewsTabHelper
: public content::WebContentsUserData<BraveNewsTabHelper>,
public content::WebContentsObserver,
Expand Down Expand Up @@ -54,6 +58,7 @@ class BraveNewsTabHelper

// content::WebContentsObserver:
void PrimaryPageChanged(content::Page& page) override;
void DOMContentLoaded(content::RenderFrameHost* rfh) override;

// brave_news::PublisherController::Observer:
void OnPublishersUpdated(
Expand Down

0 comments on commit 0f4afc7

Please sign in to comment.