Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(405)

Side by Side Diff: chrome/tools/disable_outdated_build_detector/google_update_integration.cc

Issue 2236843002: Do not rely on identical string constants having distinct pointers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/tools/disable_outdated_build_detector/google_update_integration.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/tools/disable_outdated_build_detector/google_update_integration .h" 5 #include "chrome/tools/disable_outdated_build_detector/google_update_integration .h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/win/registry.h" 9 #include "base/win/registry.h"
10 10
11 uint32_t OpenClientStateKey(bool system_level, 11 uint32_t OpenClientStateKey(bool system_level,
12 const wchar_t* app_guid, 12 App app,
13 base::win::RegKey* key) { 13 base::win::RegKey* key) {
14 #if defined(GOOGLE_CHROME_BUILD) 14 #if defined(GOOGLE_CHROME_BUILD)
15 constexpr wchar_t kChromeAppGuid[] =
16 L"{8A69D345-D564-463c-AFF1-A69D9E530F96}";
17 constexpr wchar_t kBinariesAppGuid[] =
18 L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}";
15 base::string16 path(base::StringPrintf( 19 base::string16 path(base::StringPrintf(
16 L"Software\\Google\\Update\\ClientState\\%ls", app_guid)); 20 L"Software\\Google\\Update\\ClientState\\%ls",
21 (app == App::CHROME_BINARIES ? kBinariesAppGuid : kChromeAppGuid)));
17 #else 22 #else
18 base::string16 path(app_guid == kBinariesAppGuid 23 base::string16 path(app == App::CHROME_BINARIES
19 ? L"Software\\Chromium Binaries" 24 ? L"Software\\Chromium Binaries"
20 : L"Software\\Chromium"); 25 : L"Software\\Chromium");
21 #endif 26 #endif
22 return key->Open(system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, 27 return key->Open(system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
23 path.c_str(), 28 path.c_str(),
24 KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WOW64_32KEY); 29 KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WOW64_32KEY);
25 } 30 }
26 31
27 void WriteResultInfo(bool system_level, const ResultInfo& result_info) { 32 void WriteResultInfo(bool system_level, const ResultInfo& result_info) {
28 base::win::RegKey key; 33 base::win::RegKey key;
29 uint32_t result = OpenClientStateKey(system_level, kChromeAppGuid, &key); 34 uint32_t result = OpenClientStateKey(system_level, App::CHROME_BROWSER, &key);
30 if (result != ERROR_SUCCESS) 35 if (result != ERROR_SUCCESS)
31 return; 36 return;
32 key.WriteValue(kInstallerResult, 37 key.WriteValue(kInstallerResult,
33 static_cast<uint32_t>(result_info.installer_result)); 38 static_cast<uint32_t>(result_info.installer_result));
34 key.WriteValue(kInstallerError, 39 key.WriteValue(kInstallerError,
35 static_cast<uint32_t>(result_info.installer_error)); 40 static_cast<uint32_t>(result_info.installer_error));
36 if (result_info.installer_extra_code1) { 41 if (result_info.installer_extra_code1) {
37 key.WriteValue(kInstallerExtraCode1, 42 key.WriteValue(kInstallerExtraCode1,
38 static_cast<uint32_t>(result_info.installer_error)); 43 static_cast<uint32_t>(result_info.installer_error));
39 } else { 44 } else {
(...skipping 14 matching lines...) Expand all
54 L"ECWE", L"ECWF", L"EUBB", L"EUBC", L"GGLA", L"GGLS"}; 59 L"ECWE", L"ECWF", L"EUBB", L"EUBC", L"GGLA", L"GGLS"};
55 const wchar_t* const* end = &kBrands[arraysize(kBrands)]; 60 const wchar_t* const* end = &kBrands[arraysize(kBrands)];
56 const wchar_t* const* found = std::find(&kBrands[0], end, brand); 61 const wchar_t* const* found = std::find(&kBrands[0], end, brand);
57 if (found != end) 62 if (found != end)
58 return true; 63 return true;
59 64
60 return base::StartsWith(brand, L"EUB", base::CompareCase::SENSITIVE) || 65 return base::StartsWith(brand, L"EUB", base::CompareCase::SENSITIVE) ||
61 base::StartsWith(brand, L"EUC", base::CompareCase::SENSITIVE) || 66 base::StartsWith(brand, L"EUC", base::CompareCase::SENSITIVE) ||
62 base::StartsWith(brand, L"GGR", base::CompareCase::SENSITIVE); 67 base::StartsWith(brand, L"GGR", base::CompareCase::SENSITIVE);
63 } 68 }
OLDNEW
« no previous file with comments | « chrome/tools/disable_outdated_build_detector/google_update_integration.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698