blob: 94b77d895d14b0a4ae827ba8c4be571599e78984 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/common/child_process_logging.h"
#include <windows.h>
#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.
if (!set_active_url) {
HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName);
if (!exe_module)
return;
set_active_url = reinterpret_cast<MainSetActiveURL>(
GetProcAddress(exe_module, "SetActiveURL"));
if (!set_active_url)
return;
}
(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
|