Skip to content

Commit

Permalink
Merge pull request #20205 from brave/windows-installer-promo-fix
Browse files Browse the repository at this point in the history
Fix writing promoCode file after Windows setup
  • Loading branch information
bsclifton authored Sep 19, 2023
2 parents 866ead0 + c309026 commit eee1423
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions chromium_src/chrome/installer/setup/setup_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,24 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#define wWinMain wWinMain_ChromiumImpl
#include "src/chrome/installer/setup/setup_main.cc"
#undef wWinMain
#include <string>

#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/installer/setup/setup_util.h"
#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/util_constants.h"

namespace {

const char kBraveReferralCode[] = "brave-referral-code";

int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
wchar_t* command_line, int show_command) {
int return_code = wWinMain_ChromiumImpl(instance, prev_instance, command_line,
show_command);
if (!return_code) {
void SavePromoCode(installer::InstallStatus install_status) {
if (!InstallUtil::GetInstallReturnCode(install_status)) {
const base::CommandLine& cmd_line = *base::CommandLine::ForCurrentProcess();
if (cmd_line.HasSwitch(kBraveReferralCode)) {
const std::string referral_code =
Expand All @@ -30,6 +37,12 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
}
}
}

return return_code;
}

} // namespace

#define DoLegacyCleanups \
SavePromoCode(install_status); \
DoLegacyCleanups
#include "src/chrome/installer/setup/setup_main.cc"
#undef DoLegacyCleanups

0 comments on commit eee1423

Please sign in to comment.