Skip to content

Commit 7a73989

Browse files
committed
Re-enable the post uninstall survey on Windows
Fixes brave/brave-browser#18063
1 parent 4838dc6 commit 7a73989

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

chromium_src/chrome/installer/setup/brave_behaviors.cc

+41-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,50 @@
1111

1212
namespace installer {
1313

14+
namespace {
15+
16+
// This code is copied from `DoPostUninstallOperations` implementation in
17+
// `chrome/installer/setup/google_chrome_behaviors.cc` with the following
18+
// changes:
19+
//
20+
// - `distribution_data` not appended as Brave does not record histograms.
21+
// - `kBraveUninstallSurveyUrl` used instead of `kUninstallSurveyUrl`
22+
23+
constexpr base::WStringPiece kBraveUninstallSurveyUrl(
24+
L"https://brave.com/uninstall-survey?p=brave_uninstall_survey");
25+
26+
} // namespace
27+
1428
void DoPostUninstallOperations(const base::Version& version,
1529
const base::FilePath& local_data_path,
1630
const std::wstring& distribution_data) {
17-
// Brave browser doesn't launch uninstall survey page.
31+
// Send the Chrome version and OS version as params to the form. It would be
32+
// nice to send the locale, too, but I don't see an easy way to get that in
33+
// the existing code. It's something we can add later, if needed. We depend
34+
// on installed_version.GetString() not having spaces or other characters that
35+
// need escaping: 0.2.13.4. Should that change, we will need to escape the
36+
// string before using it in a URL.
37+
const base::win::OSInfo* os_info = base::win::OSInfo::GetInstance();
38+
base::win::OSInfo::VersionNumber version_number = os_info->version_number();
39+
std::wstring os_version =
40+
base::StringPrintf(L"%d.%d.%d", version_number.major,
41+
version_number.minor, version_number.build);
42+
43+
const std::wstring survey_url = std::wstring(kBraveUninstallSurveyUrl);
44+
#if DCHECK_IS_ON()
45+
// The URL is expected to have a query part and not end with '&'.
46+
const size_t pos = survey_url.find(L'?');
47+
DCHECK_NE(pos, std::wstring::npos);
48+
DCHECK_EQ(survey_url.find(L'?', pos + 1), std::wstring::npos);
49+
DCHECK_NE(survey_url.back(), L'&');
50+
#endif
51+
auto url = base::StringPrintf(L"%ls&crversion=%ls&os=%ls", survey_url.c_str(),
52+
base::ASCIIToWide(version.GetString()).c_str(),
53+
os_version.c_str());
54+
if (os_info->version() < base::win::Version::WIN10 ||
55+
!NavigateToUrlWithEdge(url)) {
56+
NavigateToUrlWithIExplore(url);
57+
}
1858
}
1959

2060
} // namespace installer

0 commit comments

Comments
 (0)