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 "base/strings/string_util.h" |
| 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/win/registry.h" |
| 10 |
| 11 uint32_t OpenClientStateKey(bool system_level, |
| 12 const wchar_t* app_guid, |
| 13 base::win::RegKey* key) { |
| 14 #if defined(GOOGLE_CHROME_BUILD) |
| 15 base::string16 path(base::StringPrintf( |
| 16 L"Software\\Google\\Update\\ClientState\\%ls", app_guid)); |
| 17 #else |
| 18 base::string16 path(app_guid == kBinariesAppGuid |
| 19 ? L"Software\\Chromium Binaries" |
| 20 : L"Software\\Chromium"); |
| 21 #endif |
| 22 return key->Open(system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, |
| 23 path.c_str(), |
| 24 KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WOW64_32KEY); |
| 25 } |
| 26 |
| 27 void WriteResultInfo(bool system_level, const ResultInfo& result_info) { |
| 28 base::win::RegKey key; |
| 29 uint32_t result = OpenClientStateKey(system_level, kChromeAppGuid, &key); |
| 30 if (result != ERROR_SUCCESS) |
| 31 return; |
| 32 key.WriteValue(kInstallerResult, |
| 33 static_cast<uint32_t>(result_info.installer_result)); |
| 34 key.WriteValue(kInstallerError, |
| 35 static_cast<uint32_t>(result_info.installer_error)); |
| 36 if (result_info.installer_extra_code1) { |
| 37 key.WriteValue(kInstallerExtraCode1, |
| 38 static_cast<uint32_t>(result_info.installer_error)); |
| 39 } else { |
| 40 key.DeleteValue(kInstallerExtraCode1); |
| 41 } |
| 42 } |
| 43 |
| 44 // Copied from chrome/browser/google/google_brand.cc. |
| 45 bool IsOrganic(const base::string16& brand) { |
| 46 static const wchar_t* const kBrands[] = { |
| 47 L"CHCA", L"CHCB", L"CHCG", L"CHCH", L"CHCI", L"CHCJ", L"CHCK", L"CHCL", |
| 48 L"CHFO", L"CHFT", L"CHHS", L"CHHM", L"CHMA", L"CHMB", L"CHME", L"CHMF", |
| 49 L"CHMG", L"CHMH", L"CHMI", L"CHMQ", L"CHMV", L"CHNB", L"CHNC", L"CHNG", |
| 50 L"CHNH", L"CHNI", L"CHOA", L"CHOB", L"CHOC", L"CHON", L"CHOO", L"CHOP", |
| 51 L"CHOQ", L"CHOR", L"CHOS", L"CHOT", L"CHOU", L"CHOX", L"CHOY", L"CHOZ", |
| 52 L"CHPD", L"CHPE", L"CHPF", L"CHPG", L"ECBA", L"ECBB", L"ECDA", L"ECDB", |
| 53 L"ECSA", L"ECSB", L"ECVA", L"ECVB", L"ECWA", L"ECWB", L"ECWC", L"ECWD", |
| 54 L"ECWE", L"ECWF", L"EUBB", L"EUBC", L"GGLA", L"GGLS"}; |
| 55 const wchar_t* const* end = &kBrands[arraysize(kBrands)]; |
| 56 const wchar_t* const* found = std::find(&kBrands[0], end, brand); |
| 57 if (found != end) |
| 58 return true; |
| 59 |
| 60 return base::StartsWith(brand, L"EUB", base::CompareCase::SENSITIVE) || |
| 61 base::StartsWith(brand, L"EUC", base::CompareCase::SENSITIVE) || |
| 62 base::StartsWith(brand, L"GGR", base::CompareCase::SENSITIVE); |
| 63 } |
OLD | NEW |