-
Notifications
You must be signed in to change notification settings - Fork 873
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
Add support for referral promos #428
Conversation
// on to setup.exe | ||
AppendCommandLineFlags(configuration.command_line(), &cmd_line); | ||
|
||
+#if defined(BRAVE_CHROMIUM_BUILD) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to implement this via a chromium_src override, but RunSetup
is both defined and called in this file so it wasn't working correctly. My other thought was to provide our own implementation of CreateProcess
, which is called exactly once in this file and has the argument that I need to override.
727758e
to
08a5167
Compare
718b5af
to
84a4955
Compare
31ce3cf
to
f713eb1
Compare
7fdbb2a
to
bb8787f
Compare
bb8787f
to
87d5e6f
Compare
@emerick can you do a brain dump on where this is at? Thanks! |
2346225
to
7780d5c
Compare
After parsing the referral code, we pass it to setup.exe via the --brave-referral-code flag. The setup program will write the referral code out to user-data-dir.
The mini installer passes the referral code to setup via the --brave-referral-code command line option
When run against the release channel, this creates a signed install pkg that parses a referral code (if any) from its filename and writes it to user-data-dir. When run against any other channel, no pkg is created.
Retrieving the time is a blocking operation and will trigger an assertion on the main thread. Instead, post a task to retrieve the first run time and when it completes post tasks back to the main thread to perform associated bookkeeping (these need to run on the main thread as they interact with the preference service).
7780d5c
to
a0c1a7e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non-security/privacy question: are we planning on migrating referral codes from muon brave to brave-core?
std::unique_ptr<network::SimpleURLLoader> referral_headers_loader_; | ||
std::unique_ptr<network::SimpleURLLoader> referral_init_loader_; | ||
std::unique_ptr<network::SimpleURLLoader> referral_finalization_check_loader_; | ||
std::unique_ptr<base::RepeatingTimer> fetch_referral_headers_timer_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Privacy review] We should add a randomized delay to the timing so as to prevent the server from being able to correlate these requests as being from the same user. The same goes for all Brave requests that occur on a regular interval.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, I'll get that in there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added 0649d184e33c070625c2a537d70a95ec662100ef to address this.
# (who may not be an admin). | ||
sudo chmod -R 775 "$installationAppPath" | ||
sudo chown -R $userName "$installationAppPath" | ||
sudo chgrp -R admin "$installationAppPath" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Security review] How does this compare to Chrome's directory permissions? In general we want to match that (or be more restrictive)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how Chrome installs in my /Applications
folder on Mac:
$ ls -l | grep Chrome
drwxrwxr-x@ 3 emerick admin 96 Sep 15 04:30 Google Chrome.app/
So I think we're exactly matching the permissions/owner/group of Chrome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is correct, as far as I know- @petemill did the initial work on this (browser-laptop) and I remember digging in with him. We wanted to match Chrome
@@ -35,6 +35,8 @@ int OnBeforeURLRequest_StaticRedirectWork( | |||
static std::vector<URLPattern> allowed_patterns({ | |||
// Brave updates | |||
URLPattern(URLPattern::SCHEME_HTTPS, "https://go-updater.brave.com/*"), | |||
// Brave updates staging | |||
URLPattern(URLPattern::SCHEME_HTTPS, "https://laptop-updates-staging.herokuapp.com/*"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big deal since this is just for debugging right now, but can we add a way to restrict whitelisting of staging endpoints to non-prod builds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only problem is that we also rely on this URL for unit tests, but maybe we can add a define for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, now that I'm looking closer at this code I noticed that it's wrapped in the following:
#if !defined(NDEBUG)
#endif
So it will only be called in debug versions. There's a comment at the end of the block to turn this into a DCHECK eventually, but that would also mean this block is compiled out in release builds.
We normally fetch every 24 hours, this will add a random delay to prevent the server from being able to correlate these requests as coming from the same user.
0649d18
to
c87b146
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feedback addressed; LGTM! Re-approving 😄
comments addressed. @evq will take a quick look but lgtm otherwise.
Add support for referral promos
WHOOOOOOOOO!!!! 🎉 |
q i had which i don't think was addressed: what is the plan for migrating referred users from b-l-b? for instance if someone had downloaded a Dow Jones promo build and then updates to brave-core, do their promo benefits continue? |
@diracdeltas That's a really good question. If we do want to migrate, I think we could import the local_state settings without too much trouble as I followed the b-l-b state settings pretty closely. @bsclifton Any thoughts here? |
@diracdeltas good question- I captured brave/brave-browser#1294 to address this 😄 |
Fixes brave/brave-browser#287
Also relies on brave/brave-browser#1244
Submitter Checklist:
git rebase -i
to squash commits (if needed).Automated Test Plan
npm run test -- brave_unit_tests --filter=BraveReferralsNetworkDelegateHelperTest.*
Test Plan:
promoCode
file is inuser-data-directory
and contains the appropriate code. Also verify that this works as expected when the installer is run from a folder containing spaces.promoCode
file is deleted after promo code is read and stored inlocal_state
preferences.Reviewer Checklist: