diff options
Diffstat (limited to 'chrome/common/child_process_logging_win.cc')
-rw-r--r-- | chrome/common/child_process_logging_win.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/chrome/common/child_process_logging_win.cc b/chrome/common/child_process_logging_win.cc index e8ddd02..94b77d8 100644 --- a/chrome/common/child_process_logging_win.cc +++ b/chrome/common/child_process_logging_win.cc @@ -8,12 +8,16 @@ #include "base/string_util.h" #include "chrome/common/chrome_constants.h" +#include "chrome/installer/util/google_update_settings.h" #include "googleurl/src/gurl.h" namespace child_process_logging { // exported in breakpad_win.cc: void __declspec(dllexport) __cdecl SetActiveURL. typedef void (__cdecl *MainSetActiveURL)(const wchar_t*); +// exported in breakpad_win.cc: void __declspec(dllexport) __cdecl SetClientId. +typedef void (__cdecl *MainSetClientId)(const wchar_t*); + void SetActiveURL(const GURL& url) { static MainSetActiveURL set_active_url = NULL; // note: benign race condition on set_active_url. @@ -30,4 +34,31 @@ void SetActiveURL(const GURL& url) { (set_active_url)(UTF8ToWide(url.possibly_invalid_spec()).c_str()); } +void SetClientId(const std::string& client_id) { + std::string str(client_id); + // Remove all instance of '-' char from the GUID. So BCD-WXY becomes BCDWXY. + ReplaceSubstringsAfterOffset(&str, 0, "-", ""); + + if (str.empty()) + return; + + std::wstring wstr = ASCIIToWide(str); + std::wstring old_wstr; + if (!GoogleUpdateSettings::GetMetricsId(&old_wstr) || + wstr != old_wstr) + GoogleUpdateSettings::SetMetricsId(wstr); + + static MainSetClientId set_client_id = NULL; + if (!set_client_id) { + HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); + if (!exe_module) + return; + set_client_id = reinterpret_cast<MainSetClientId>( + GetProcAddress(exe_module, "SetClientId")); + if (!set_client_id) + return; + } + (set_client_id)(wstr.c_str()); +} + } // namespace child_process_logging |