Skip to content

Commit

Permalink
Merge pull request #6607 from /issues/11223-1.15.x
Browse files Browse the repository at this point in the history
Fixes Brave Rewards service is associated to Tor Profiles - 1.15.x
  • Loading branch information
kjozwiak authored Sep 10, 2020
2 parents 5b0a155 + 345fd7f commit 1e16e0f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 22 deletions.
7 changes: 6 additions & 1 deletion browser/brave_rewards/rewards_service_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "brave/browser/brave_rewards/rewards_service_factory.h"

#include "brave/browser/profiles/brave_profile_manager.h"
#include "brave/browser/profiles/profile_util.h"
#include "brave/components/brave_rewards/browser/buildflags/buildflags.h"
#include "brave/components/brave_rewards/browser/rewards_service.h"
#include "brave/components/brave_rewards/common/pref_names.h"
Expand Down Expand Up @@ -65,6 +66,10 @@ RewardsService* RewardsServiceFactory::GetForProfile(
return testing_service_;
}

if (profile->IsOffTheRecord() || brave::IsTorProfile(profile)) {
return nullptr;
}

return static_cast<RewardsService*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
Expand Down Expand Up @@ -124,7 +129,7 @@ KeyedService* RewardsServiceFactory::BuildServiceInstanceFor(
std::move(notification_observer));
return rewards_service.release();
#else
return NULL;
return nullptr;
#endif
}

Expand Down
8 changes: 4 additions & 4 deletions browser/brave_rewards/rewards_service_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ class Profile;
namespace brave_rewards {
class RewardsService;

// Singleton that owns all RewardsService and associates them with
// Profiles.
// Singleton that owns all RewardsService and associates them with Profiles.
class RewardsServiceFactory : public BrowserContextKeyedServiceFactory,
public content::NotificationObserver {
public:
RewardsServiceFactory(const RewardsServiceFactory&) = delete;
RewardsServiceFactory& operator=(const RewardsServiceFactory&) = delete;

static brave_rewards::RewardsService* GetForProfile(Profile* profile);

static RewardsServiceFactory* GetInstance();
Expand All @@ -45,8 +47,6 @@ class RewardsServiceFactory : public BrowserContextKeyedServiceFactory,
const content::NotificationDetails& details) override;

content::NotificationRegistrar registrar_;

DISALLOW_COPY_AND_ASSIGN(RewardsServiceFactory);
};

} // namespace brave_rewards
Expand Down
10 changes: 0 additions & 10 deletions components/brave_ads/browser/ads_service_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,6 @@ KeyedService* AdsServiceFactory::BuildServiceInstanceFor(
#endif
}

content::BrowserContext* AdsServiceFactory::GetBrowserContextToUse(
content::BrowserContext* context) const {
if (context->IsOffTheRecord() || brave::IsTorProfile(context)) {
return chrome::GetBrowserContextOwnInstanceInIncognito(context);
}

// use original profile for session profiles
return chrome::GetBrowserContextRedirectedInIncognito(context);
}

bool AdsServiceFactory::ServiceIsNULLWhileTesting() const {
return false;
}
Expand Down
2 changes: 0 additions & 2 deletions components/brave_ads/browser/ads_service_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ class AdsServiceFactory : public BrowserContextKeyedServiceFactory {
// BrowserContextKeyedServiceFactory:
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* context) const override;
content::BrowserContext* GetBrowserContextToUse(
content::BrowserContext* context) const override;
bool ServiceIsNULLWhileTesting() const override;
};

Expand Down
5 changes: 0 additions & 5 deletions components/brave_rewards/browser/rewards_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2168,10 +2168,6 @@ void RewardsServiceImpl::DiagnosticLog(
return;
}

if (profile_->IsOffTheRecord()) {
return;
}

if (verbose_level > kDiagnosticLogMaxVerboseLevel) {
return;
}
Expand All @@ -2189,7 +2185,6 @@ void RewardsServiceImpl::DiagnosticLog(
AsWeakPtr()));
}


bool RewardsServiceImpl::WriteToDiagnosticLogOnFileTaskRunner(
const base::FilePath& log_path,
const int num_lines,
Expand Down

0 comments on commit 1e16e0f

Please sign in to comment.