Skip to content

Commit

Permalink
Fixes no ads enable alert, ads are enabled by default when upgrading …
Browse files Browse the repository at this point in the history
…build from 0.62.51 to 0.67.119

Fixes brave/brave-browser#5434
  • Loading branch information
tmancey authored Aug 2, 2019
1 parent ab1394a commit e3154c5
Show file tree
Hide file tree
Showing 6 changed files with 285 additions and 107 deletions.
22 changes: 1 addition & 21 deletions components/brave_ads/browser/ads_service_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,7 @@ bool AdsServiceFactory::ServiceIsNULLWhileTesting() const {

void AdsServiceFactory::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
if (ShouldMigratePrefs(registry)) {
// prefs::kVersion should default to 1 for legacy installations so that
// preferences are migrated from version 1 to the current version
registry->RegisterIntegerPref(prefs::kVersion, 1);
} else {
registry->RegisterIntegerPref(prefs::kVersion, 2);
}
registry->RegisterIntegerPref(prefs::kVersion, prefs::kCurrentVersionNumber);

registry->RegisterBooleanPref(prefs::kEnabled, false);

Expand All @@ -113,18 +107,4 @@ void AdsServiceFactory::RegisterProfilePrefs(
prefs::kLastShownFirstLaunchNotificationTimestamp, 0);
}

bool AdsServiceFactory::ShouldMigratePrefs(
user_prefs::PrefRegistrySyncable* registry) const {
// If prefs::kEnabled does not exist then this must be a fresh installion so
// we do not need to migrate
auto pref_store = registry->defaults();

const base::Value* value = nullptr;
if (!pref_store->GetValue(prefs::kEnabled, &value)) {
return false;
}

return true;
}

} // namespace brave_ads
1 change: 0 additions & 1 deletion components/brave_ads/browser/ads_service_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class AdsServiceFactory : public BrowserContextKeyedServiceFactory {
content::BrowserContext* GetBrowserContextToUse(
content::BrowserContext* context) const override;
bool ServiceIsNULLWhileTesting() const override;
bool ShouldMigratePrefs(user_prefs::PrefRegistrySyncable* registry) const;

DISALLOW_COPY_AND_ASSIGN(AdsServiceFactory);
};
Expand Down
Loading

0 comments on commit e3154c5

Please sign in to comment.