OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/tools/disable_outdated_build_detector/google_update_integration
.h" | |
6 | |
7 #include <stdlib.h> | |
8 | |
9 #include <algorithm> | |
10 | |
11 uint32_t OpenClientStateKey(bool system_level, App app, HKEY* key) { | |
12 #if defined(GOOGLE_CHROME_BUILD) | |
13 constexpr wchar_t kChromeAppGuid[] = | |
14 L"{8A69D345-D564-463c-AFF1-A69D9E530F96}"; | |
15 constexpr wchar_t kBinariesAppGuid[] = | |
16 L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}"; | |
17 // presubmit: allow wstring | |
18 std::wstring path(L"Software\\Google\\Update\\ClientState\\"); | |
19 path += (app == App::CHROME_BINARIES ? kBinariesAppGuid : kChromeAppGuid); | |
20 #else | |
21 // presubmit: allow wstring | |
22 std::wstring path(app == App::CHROME_BINARIES ? L"Software\\Chromium Binaries" | |
23 : L"Software\\Chromium"); | |
24 #endif | |
25 return ::RegOpenKeyEx(system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, | |
26 path.c_str(), 0 /* ulOptions */, | |
27 KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WOW64_32KEY, key); | |
28 } | |
29 | |
30 void WriteResultInfo(bool system_level, const ResultInfo& result_info) { | |
31 HKEY key = nullptr; | |
32 uint32_t result = OpenClientStateKey(system_level, App::CHROME_BROWSER, &key); | |
33 if (result != ERROR_SUCCESS) | |
34 return; | |
35 ::RegSetValueEx( | |
36 key, kInstallerResult, 0 /* Reserved */, REG_DWORD, | |
37 reinterpret_cast<const uint8_t*>(&result_info.installer_result), | |
38 sizeof(DWORD)); | |
39 ::RegSetValueEx( | |
40 key, kInstallerError, 0 /* Reserved */, REG_DWORD, | |
41 reinterpret_cast<const uint8_t*>(&result_info.installer_error), | |
42 sizeof(DWORD)); | |
43 if (result_info.installer_extra_code1) { | |
44 ::RegSetValueEx( | |
45 key, kInstallerExtraCode1, 0 /* Reserved */, REG_DWORD, | |
46 reinterpret_cast<const uint8_t*>(&result_info.installer_extra_code1), | |
47 sizeof(DWORD)); | |
48 } else { | |
49 ::RegDeleteValue(key, kInstallerExtraCode1); | |
50 } | |
51 ::RegCloseKey(key); | |
52 } | |
53 | |
54 // Copied from chrome/browser/google/google_brand.cc. | |
55 // presubmit: allow wstring | |
56 bool IsOrganic(const std::wstring& brand) { | |
57 constexpr const wchar_t* kBrands[] = { | |
58 L"CHCA", L"CHCB", L"CHCG", L"CHCH", L"CHCI", L"CHCJ", L"CHCK", L"CHCL", | |
59 L"CHFO", L"CHFT", L"CHHS", L"CHHM", L"CHMA", L"CHMB", L"CHME", L"CHMF", | |
60 L"CHMG", L"CHMH", L"CHMI", L"CHMQ", L"CHMV", L"CHNB", L"CHNC", L"CHNG", | |
61 L"CHNH", L"CHNI", L"CHOA", L"CHOB", L"CHOC", L"CHON", L"CHOO", L"CHOP", | |
62 L"CHOQ", L"CHOR", L"CHOS", L"CHOT", L"CHOU", L"CHOX", L"CHOY", L"CHOZ", | |
63 L"CHPD", L"CHPE", L"CHPF", L"CHPG", L"ECBA", L"ECBB", L"ECDA", L"ECDB", | |
64 L"ECSA", L"ECSB", L"ECVA", L"ECVB", L"ECWA", L"ECWB", L"ECWC", L"ECWD", | |
65 L"ECWE", L"ECWF", L"EUBB", L"EUBC", L"GGLA", L"GGLS"}; | |
66 const wchar_t* const* end = &kBrands[_countof(kBrands)]; | |
67 const wchar_t* const* found = std::find(&kBrands[0], end, brand); | |
68 if (found != end) | |
69 return true; | |
70 | |
71 return brand.size() > 3 && (std::equal(&brand[0], &brand[3], L"EUB") || | |
72 std::equal(&brand[0], &brand[3], L"EUC") || | |
73 std::equal(&brand[0], &brand[3], L"GGR")); | |
74 } | |
OLD | NEW |