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

Side by Side Diff: chrome/install_static/install_util.cc

Issue 2797433002: Include Google Update integration details in crash keys and about:version. (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/install_static/install_util.h" 5 #include "chrome/install_static/install_util.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <assert.h> 8 #include <assert.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // Chrome channel display names. 51 // Chrome channel display names.
52 constexpr wchar_t kChromeChannelDev[] = L"dev"; 52 constexpr wchar_t kChromeChannelDev[] = L"dev";
53 constexpr wchar_t kChromeChannelBeta[] = L"beta"; 53 constexpr wchar_t kChromeChannelBeta[] = L"beta";
54 constexpr wchar_t kChromeChannelStableExplicit[] = L"stable"; 54 constexpr wchar_t kChromeChannelStableExplicit[] = L"stable";
55 55
56 // TODO(ananta) 56 // TODO(ananta)
57 // http://crbug.com/604923 57 // http://crbug.com/604923
58 // These constants are defined in the chrome/installer directory as well. We 58 // These constants are defined in the chrome/installer directory as well. We
59 // need to unify them. 59 // need to unify them.
60 constexpr wchar_t kRegValueAp[] = L"ap"; 60 constexpr wchar_t kRegValueAp[] = L"ap";
61 constexpr wchar_t kRegValueName[] = L"name";
61 constexpr wchar_t kRegValueUsageStats[] = L"usagestats"; 62 constexpr wchar_t kRegValueUsageStats[] = L"usagestats";
62 constexpr wchar_t kMetricsReportingEnabled[] = L"MetricsReportingEnabled"; 63 constexpr wchar_t kMetricsReportingEnabled[] = L"MetricsReportingEnabled";
63 64
64 void Trace(const wchar_t* format_string, ...) { 65 void Trace(const wchar_t* format_string, ...) {
65 static const int kMaxLogBufferSize = 1024; 66 static const int kMaxLogBufferSize = 1024;
66 static wchar_t buffer[kMaxLogBufferSize] = {}; 67 static wchar_t buffer[kMaxLogBufferSize] = {};
67 68
68 va_list args = {}; 69 va_list args = {};
69 70
70 va_start(args, format_string); 71 va_start(args, format_string);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 std::vector<StringType> tokens; 244 std::vector<StringType> tokens;
244 std::basic_istringstream<typename StringType::value_type> buffer(str); 245 std::basic_istringstream<typename StringType::value_type> buffer(str);
245 for (StringType token; std::getline(buffer, token, delimiter);) { 246 for (StringType token; std::getline(buffer, token, delimiter);) {
246 if (trim_spaces) 247 if (trim_spaces)
247 TrimT<StringType>(&token); 248 TrimT<StringType>(&token);
248 tokens.push_back(token); 249 tokens.push_back(token);
249 } 250 }
250 return tokens; 251 return tokens;
251 } 252 }
252 253
254 // Returns Chrome's update channel name based on the contents of the "ap" value
255 // found in Chrome's ClientState key. |update_ap|, if not null, is set to the
256 // raw value read from the registry.
253 std::wstring ChannelFromAdditionalParameters(const InstallConstants& mode, 257 std::wstring ChannelFromAdditionalParameters(const InstallConstants& mode,
254 bool system_level, 258 bool system_level,
255 bool from_binaries) { 259 bool from_binaries,
260 std::wstring* update_ap) {
256 assert(kUseGoogleUpdateIntegration); 261 assert(kUseGoogleUpdateIntegration);
257 // InitChannelInfo in google_update_settings.cc only reports a failure when 262 // InitChannelInfo in google_update_settings.cc only reports a failure when
258 // Chrome's ClientState key exists but that the "ap" value therein cannot be 263 // Chrome's ClientState key exists but that the "ap" value therein cannot be
259 // read due to some reason *other* than it not being present. This should be 264 // read due to some reason *other* than it not being present. This should be
260 // exceedingly rare. For simplicity's sake, use an empty |value| in case of 265 // exceedingly rare. For simplicity's sake, use an empty |value| in case of
261 // any error whatsoever here. 266 // any error whatsoever here.
262 std::wstring value; 267 std::wstring value;
263 nt::QueryRegValueSZ(system_level ? nt::HKLM : nt::HKCU, nt::WOW6432, 268 nt::QueryRegValueSZ(system_level ? nt::HKLM : nt::HKCU, nt::WOW6432,
264 from_binaries 269 from_binaries
265 ? GetBinariesClientStateKeyPath().c_str() 270 ? GetBinariesClientStateKeyPath().c_str()
266 : GetClientStateKeyPath(mode.app_guid).c_str(), 271 : GetClientStateKeyPath(mode.app_guid).c_str(),
267 kRegValueAp, &value); 272 kRegValueAp, &value);
273 if (update_ap)
274 *update_ap = value;
268 275
269 static constexpr wchar_t kChromeChannelBetaPattern[] = L"1?1-*"; 276 static constexpr wchar_t kChromeChannelBetaPattern[] = L"1?1-*";
270 static constexpr wchar_t kChromeChannelBetaX64Pattern[] = L"*x64-beta*"; 277 static constexpr wchar_t kChromeChannelBetaX64Pattern[] = L"*x64-beta*";
271 static constexpr wchar_t kChromeChannelDevPattern[] = L"2?0-d*"; 278 static constexpr wchar_t kChromeChannelDevPattern[] = L"2?0-d*";
272 static constexpr wchar_t kChromeChannelDevX64Pattern[] = L"*x64-dev*"; 279 static constexpr wchar_t kChromeChannelDevX64Pattern[] = L"*x64-dev*";
273 280
274 std::transform(value.begin(), value.end(), value.begin(), ::tolower); 281 std::transform(value.begin(), value.end(), value.begin(), ::tolower);
275 282
276 // Empty channel names or those containing "stable" should be reported as 283 // Empty channel names or those containing "stable" should be reported as
277 // an empty string. 284 // an empty string.
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 return false; 795 return false;
789 } 796 }
790 } 797 }
791 return true; 798 return true;
792 } 799 }
793 800
794 // This function takes these inputs rather than accessing the module's 801 // This function takes these inputs rather than accessing the module's
795 // InstallDetails instance since it is used to bootstrap InstallDetails. 802 // InstallDetails instance since it is used to bootstrap InstallDetails.
796 std::wstring DetermineChannel(const InstallConstants& mode, 803 std::wstring DetermineChannel(const InstallConstants& mode,
797 bool system_level, 804 bool system_level,
798 bool from_binaries) { 805 bool from_binaries,
806 std::wstring* update_ap,
807 std::wstring* update_cohort_name) {
799 if (!kUseGoogleUpdateIntegration) 808 if (!kUseGoogleUpdateIntegration)
800 return std::wstring(); 809 return std::wstring();
801 810
811 if (update_cohort_name) {
812 // Cache the cohort name.
813 std::wstring path(from_binaries ? GetBinariesClientStateKeyPath()
814 : GetClientStateKeyPath(mode.app_guid));
815 path.append(L"\\cohort");
816 nt::QueryRegValueSZ(system_level ? nt::HKLM : nt::HKCU, nt::WOW6432,
817 path.c_str(), kRegValueName, update_cohort_name);
818 }
819
802 switch (mode.channel_strategy) { 820 switch (mode.channel_strategy) {
803 case ChannelStrategy::UNSUPPORTED: 821 case ChannelStrategy::UNSUPPORTED:
804 assert(false); 822 assert(false);
805 break; 823 break;
806 case ChannelStrategy::ADDITIONAL_PARAMETERS: 824 case ChannelStrategy::ADDITIONAL_PARAMETERS:
807 return ChannelFromAdditionalParameters(mode, system_level, from_binaries); 825 return ChannelFromAdditionalParameters(mode, system_level, from_binaries,
826 update_ap);
808 case ChannelStrategy::FIXED: 827 case ChannelStrategy::FIXED:
809 return mode.default_channel_name; 828 return mode.default_channel_name;
810 } 829 }
811 830
812 return std::wstring(); 831 return std::wstring();
813 } 832 }
814 833
815 } // namespace install_static 834 } // namespace install_static
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698