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

Clean up Rewards auto-contribute measurement #16774

Merged
merged 1 commit into from
Jan 25, 2023
Merged
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
5 changes: 5 additions & 0 deletions browser/brave_rewards/rewards_tab_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,12 @@ bool RewardsTabHelper::BrowserHasWebContents(Browser* browser) {

void RewardsTabHelper::OnRewardsInitialized(RewardsService* rewards_service) {
MaybeSavePublisherInfo();

// When Rewards is initialized for the current profile, we need to inform the
// utility process about the currently active tab so that it can start
// measuring auto-contribute correctly.
if (rewards_service_) {
rewards_service_->OnShow(tab_id_);
rewards_service_->OnLoad(tab_id_, GetWebContents().GetLastCommittedURL());
}
}
Expand Down
4 changes: 0 additions & 4 deletions browser/net/brave_request_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "brave/browser/net/brave_stp_util.h"
#include "brave/browser/net/decentralized_dns_network_delegate_helper.h"
#include "brave/browser/net/global_privacy_control_network_delegate_helper.h"
#include "brave/components/brave_rewards/browser/net/network_delegate_helper.h"
#include "brave/components/brave_shields/common/features.h"
#include "brave/components/brave_webtorrent/browser/buildflags/buildflags.h"
#include "brave/components/constants/pref_names.h"
Expand Down Expand Up @@ -79,9 +78,6 @@ void BraveRequestHandler::SetupCallbacks() {
decentralized_dns::OnBeforeURLRequest_DecentralizedDnsPreRedirectWork);
before_url_request_callbacks_.push_back(callback);

callback = base::BindRepeating(brave_rewards::OnBeforeURLRequest);
before_url_request_callbacks_.push_back(callback);

#if BUILDFLAG(ENABLE_IPFS)
if (base::FeatureList::IsEnabled(ipfs::features::kIpfsFeature)) {
callback = base::BindRepeating(ipfs::OnBeforeURLRequest_IPFSRedirectWork);
Expand Down
2 changes: 0 additions & 2 deletions chromium_presubmit_config.json5
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@
"browser/ui/webui/private_new_tab_page/brave_private_new_tab_page_browsertest\\.cc",
"chromium_src/chrome/install_static/brave_install_util_unittest\\.cc",
"chromium_src/components/search_engines/brave_template_url_prepopulate_data_unittest\\.cc",
"components/brave_rewards/browser/net/network_delegate_helper\\.cc",
"components/brave_rewards/browser/net/network_delegate_helper\\.h",
"components/brave_rewards/browser/test/rewards_state_browsertest\\.cc",
"components/brave_shields/browser/ad_block_engine\\.cc",
"components/brave_shields/browser/https_everywhere_service\\.cc",
Expand Down
7 changes: 5 additions & 2 deletions components/brave_rewards/browser/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) 2023 The Brave Authors. All rights reserved.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at https://mozilla.org/MPL/2.0/.

import("//brave/components/ipfs/buildflags/buildflags.gni")
import("//brave/vendor/bat-native-ledger/config.gni")
import("//extensions/buildflags/buildflags.gni")
Expand All @@ -13,8 +18,6 @@ static_library("browser") {
"diagnostic_log.cc",
"diagnostic_log.h",
"logging.h",
"net/network_delegate_helper.cc",
"net/network_delegate_helper.h",
"publisher_utils.cc",
"publisher_utils.h",
"rewards_notification_service.cc",
Expand Down
69 changes: 0 additions & 69 deletions components/brave_rewards/browser/net/network_delegate_helper.cc

This file was deleted.

18 changes: 0 additions & 18 deletions components/brave_rewards/browser/net/network_delegate_helper.h

This file was deleted.

11 changes: 11 additions & 0 deletions components/brave_rewards/browser/publisher_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ absl::optional<std::string> GetPublisherIdFromURL(const GURL& url) {
if (IsMediaPlatformURL(url)) {
return absl::nullopt;
}
return GetPublisherDomainFromURL(url);
}

absl::optional<std::string> GetPublisherDomainFromURL(const GURL& url) {
#if BUILDFLAG(ENABLE_IPFS)
if (url.SchemeIs(ipfs::kIPNSScheme)) {
std::string domain = ipfs::GetRegistryDomainFromIPNS(url);
Expand All @@ -62,4 +65,12 @@ absl::optional<std::string> GetPublisherIdFromURL(const GURL& url) {
return domain;
}

bool IsAutoContributeHandledByContentScript(const GURL& url) {
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS)
return false;
#else
return IsMediaPlatformURL(url);
#endif
}

} // namespace brave_rewards
7 changes: 7 additions & 0 deletions components/brave_rewards/browser/publisher_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ namespace brave_rewards {
// platform where multiple publishers can be registered.
absl::optional<std::string> GetPublisherIdFromURL(const GURL& url);

// Returns the publisher domain for the specified URL. For social media
// platforms, the site domain will be returned (e.g "twitter.com").
absl::optional<std::string> GetPublisherDomainFromURL(const GURL& url);

// Returns a value indicating whether content scripting is used to measure AC.
bool IsAutoContributeHandledByContentScript(const GURL& url);

} // namespace brave_rewards

#endif // BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_PUBLISHER_UTILS_H_
9 changes: 0 additions & 9 deletions components/brave_rewards/browser/rewards_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ class NavigationHandle;

namespace brave_rewards {

bool IsMediaLink(const GURL& url,
const GURL& first_party_url,
const GURL& referrer);

class RewardsNotificationService;
class RewardsServiceObserver;

Expand Down Expand Up @@ -203,11 +199,6 @@ class RewardsService : public KeyedService {
const GURL& url,
const GURL& first_party_url,
const GURL& referrer) = 0;
virtual void OnPostData(SessionID tab_id,
const GURL& url,
const GURL& first_party_url,
const GURL& referrer,
const std::string& post_data) = 0;

virtual void GetReconcileStamp(GetReconcileStampCallback callback) = 0;
virtual void GetPublisherMinVisitTime(
Expand Down
Loading