Skip to content

Commit

Permalink
Re-enable the post uninstall survey on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
bsclifton committed Sep 16, 2021
1 parent 4838dc6 commit 7a73989
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion chromium_src/chrome/installer/setup/brave_behaviors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,50 @@

namespace installer {

namespace {

// This code is copied from `DoPostUninstallOperations` implementation in
// `chrome/installer/setup/google_chrome_behaviors.cc` with the following
// changes:
//
// - `distribution_data` not appended as Brave does not record histograms.
// - `kBraveUninstallSurveyUrl` used instead of `kUninstallSurveyUrl`

constexpr base::WStringPiece kBraveUninstallSurveyUrl(
L"https://brave.com/uninstall-survey?p=brave_uninstall_survey");

} // namespace

void DoPostUninstallOperations(const base::Version& version,
const base::FilePath& local_data_path,
const std::wstring& distribution_data) {
// Brave browser doesn't launch uninstall survey page.
// Send the Chrome version and OS version as params to the form. It would be
// nice to send the locale, too, but I don't see an easy way to get that in
// the existing code. It's something we can add later, if needed. We depend
// on installed_version.GetString() not having spaces or other characters that
// need escaping: 0.2.13.4. Should that change, we will need to escape the
// string before using it in a URL.
const base::win::OSInfo* os_info = base::win::OSInfo::GetInstance();
base::win::OSInfo::VersionNumber version_number = os_info->version_number();
std::wstring os_version =
base::StringPrintf(L"%d.%d.%d", version_number.major,
version_number.minor, version_number.build);

const std::wstring survey_url = std::wstring(kBraveUninstallSurveyUrl);
#if DCHECK_IS_ON()
// The URL is expected to have a query part and not end with '&'.
const size_t pos = survey_url.find(L'?');
DCHECK_NE(pos, std::wstring::npos);
DCHECK_EQ(survey_url.find(L'?', pos + 1), std::wstring::npos);
DCHECK_NE(survey_url.back(), L'&');
#endif
auto url = base::StringPrintf(L"%ls&crversion=%ls&os=%ls", survey_url.c_str(),
base::ASCIIToWide(version.GetString()).c_str(),
os_version.c_str());
if (os_info->version() < base::win::Version::WIN10 ||
!NavigateToUrlWithEdge(url)) {
NavigateToUrlWithIExplore(url);
}
}

} // namespace installer

0 comments on commit 7a73989

Please sign in to comment.