OLD | NEW |
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 <string.h> | 9 #include <string.h> |
10 | 10 |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 // If reading the value failed, treat it as though sampling isn't in effect, | 405 // If reading the value failed, treat it as though sampling isn't in effect, |
406 // implicitly meaning this install is in the sample. | 406 // implicitly meaning this install is in the sample. |
407 return true; | 407 return true; |
408 } | 408 } |
409 return out_value == 1; | 409 return out_value == 1; |
410 } | 410 } |
411 | 411 |
412 bool SetCollectStatsInSample(bool in_sample) { | 412 bool SetCollectStatsInSample(bool in_sample) { |
413 std::wstring registry_path = GetChromeInstallRegistryPath(); | 413 std::wstring registry_path = GetChromeInstallRegistryPath(); |
414 | 414 |
415 HANDLE key_handle = INVALID_HANDLE_VALUE; | 415 nt::ScopedRegKeyHANDLE key = nt::CreateRegKey( |
416 if (!nt::CreateRegKey(nt::HKCU, registry_path.c_str(), | 416 nt::HKCU, registry_path.c_str(), KEY_SET_VALUE | KEY_WOW64_32KEY); |
417 KEY_SET_VALUE | KEY_WOW64_32KEY, &key_handle)) { | 417 if (!key.is_valid()) |
418 return false; | 418 return false; |
419 } | |
420 | 419 |
421 bool success = nt::SetRegValueDWORD(key_handle, kRegValueChromeStatsSample, | 420 return nt::SetRegValueDWORD(key.get(), kRegValueChromeStatsSample, |
422 in_sample ? 1 : 0); | 421 in_sample ? 1 : 0); |
423 nt::CloseRegKey(key_handle); | |
424 return success; | |
425 } | 422 } |
426 | 423 |
427 bool ReportingIsEnforcedByPolicy(bool* crash_reporting_enabled) { | 424 bool ReportingIsEnforcedByPolicy(bool* crash_reporting_enabled) { |
428 std::wstring policies_path = L"SOFTWARE\\Policies\\"; | 425 std::wstring policies_path = L"SOFTWARE\\Policies\\"; |
429 AppendChromeInstallSubDirectory(&policies_path, false /* !include_suffix */); | 426 AppendChromeInstallSubDirectory(&policies_path, false /* !include_suffix */); |
430 DWORD value = 0; | 427 DWORD value = 0; |
431 | 428 |
432 // First, try HKLM. | 429 // First, try HKLM. |
433 if (nt::QueryRegValueDWORD(nt::HKLM, nt::NONE, policies_path.c_str(), | 430 if (nt::QueryRegValueDWORD(nt::HKLM, nt::NONE, policies_path.c_str(), |
434 kMetricsReportingEnabled, &value)) { | 431 kMetricsReportingEnabled, &value)) { |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 case ChannelStrategy::ADDITIONAL_PARAMETERS: | 705 case ChannelStrategy::ADDITIONAL_PARAMETERS: |
709 return ChannelFromAdditionalParameters(mode, system_level, multi_install); | 706 return ChannelFromAdditionalParameters(mode, system_level, multi_install); |
710 case ChannelStrategy::FIXED: | 707 case ChannelStrategy::FIXED: |
711 return mode.default_channel_name; | 708 return mode.default_channel_name; |
712 } | 709 } |
713 | 710 |
714 return std::wstring(); | 711 return std::wstring(); |
715 } | 712 } |
716 | 713 |
717 } // namespace install_static | 714 } // namespace install_static |
OLD | NEW |