Skip to content

Commit eff3b05

Browse files
authored
Merge pull request #5283 from brave/ntp_super_referral_images2
Reflect referrals service change to ntp background images service
2 parents 1355d4a + 84a226e commit eff3b05

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@ script/brave_license_helper.py @fmarier
4949
# Crypto Wallets
5050
browser/brave_wallet/ @bbondy @ryanml
5151
components/brave_wallet/ @bbondy @ryanml
52+
53+
# Brave Referrals Service
54+
components/brave_referrals/browser/brave_referrals_service* @simonhong

components/ntp_background_images/browser/ntp_background_images_service.cc

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,22 +218,20 @@ void NTPBackgroundImagesService::CheckSuperReferralComponent() {
218218
// If not, this install will be act as a non SR install forever.
219219
// To resolve that situation,
220220
// |kNewTabPageGetInitialSRComponentInProgress| introduced.
221-
// If |kReferralCheckedForPromoCodeFile| is true and
222-
// |kNewTabPageCheckingMappingTableInProgress| is false, this means not
223-
// first launch. So, we can mark this install as non-SR.
224-
// If both |kReferralCheckedForPromoCodeFile| and
225-
// |kNewTabPageCheckingMappingTableInProgress| are true, browser had some
226-
// trouble at first launch.
221+
// If |kReferralCheckedForPromoCodeFile| or |kReferralInitialization|
222+
// is true and |kNewTabPageCheckingMappingTableInProgress| is false,
223+
// this means not first launch. Then, we can mark this install as non-SR.
224+
// If both (|kReferralCheckedForPromoCodeFile| or |kReferralInitialization|)
225+
// and |kNewTabPageCheckingMappingTableInProgress| are true,
226+
// browser had some trouble at first run.
227227
// If |kNewTabPageGetInitialSRComponentInProgress| is true, we assume that
228-
// initial component downloading is not finished properly.
228+
// initial component downloading is in-progress
229229
// So, We will try initialization again.
230230
// If referral code is non empty, that means browser is shutdown after
231231
// getting referal code. In this case, we should start downloading mapping
232232
// table.
233-
// If both |kReferralCheckedForPromoCodeFile| and
234-
// |kNewTabPageCheckingMappingTableInProgress| are true, browser had some
235-
// troublewhile getting mapping table at first fresh launch.
236-
if (local_pref_->GetBoolean(kReferralCheckedForPromoCodeFile) &&
233+
if ((local_pref_->GetBoolean(kReferralCheckedForPromoCodeFile) ||
234+
local_pref_->GetBoolean(kReferralInitialization)) &&
237235
!local_pref_->GetBoolean(
238236
prefs::kNewTabPageGetInitialSRComponentInProgress)) {
239237
MarkThisInstallIsNotSuperReferralForever();

components/ntp_background_images/browser/ntp_background_images_service_unittest.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ TEST_F(NTPBackgroundImagesServiceTest, InternalDataTest) {
142142
service_->AddObserver(&observer);
143143

144144
pref_service_.SetBoolean(kReferralCheckedForPromoCodeFile, true);
145+
pref_service_.SetBoolean(kReferralInitialization, true);
145146

146147
// Check with json file w/o schema version with empty object.
147148
service_->si_images_data_.reset();
@@ -460,6 +461,7 @@ TEST_F(NTPBackgroundImagesServiceTest,
460461
CheckRecoverShutdownWhileMappingTableFetchingWithDefaultCode) {
461462
// Make this install has initialized super referral service.
462463
pref_service_.SetBoolean(kReferralCheckedForPromoCodeFile, true);
464+
pref_service_.SetBoolean(kReferralInitialization, true);
463465
pref_service_.SetBoolean(
464466
prefs::kNewTabPageGetInitialSRComponentInProgress, true);
465467
pref_service_.SetString(kReferralPromoCode, "BRV001");
@@ -481,6 +483,7 @@ TEST_F(NTPBackgroundImagesServiceTest,
481483
CheckRecoverShutdownWhileMappingTableFetchingWithNonDefaultCode) {
482484
// Make this install has initialized super referral service.
483485
pref_service_.SetBoolean(kReferralCheckedForPromoCodeFile, true);
486+
pref_service_.SetBoolean(kReferralInitialization, true);
484487
pref_service_.SetBoolean(
485488
prefs::kNewTabPageGetInitialSRComponentInProgress, true);
486489
pref_service_.SetString(kReferralPromoCode, "BRV003");

0 commit comments

Comments
 (0)