| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/host/usage_stats_consent.h" | 5 #include "remoting/host/usage_stats_consent.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 12 #include "base/win/registry.h" | 12 #include "base/win/registry.h" |
| 13 #include "remoting/host/constants.h" | |
| 14 | 13 |
| 15 namespace { | 14 namespace { |
| 16 | 15 |
| 17 // The following strings are used to construct the registry key names where | 16 // The following strings are used to construct the registry key names where |
| 18 // we record whether the user has consented to crash dump collection. | 17 // we record whether the user has consented to crash dump collection. |
| 19 // the user's consent to collect crash dumps is recorded. | 18 // the user's consent to collect crash dumps is recorded. |
| 20 const wchar_t kOmahaClientStateKeyFormat[] = | 19 const wchar_t kOmahaClientStateKeyFormat[] = |
| 21 L"Software\\Google\\Update\\%ls\\%ls"; | 20 L"Software\\Google\\Update\\%ls\\%ls"; |
| 22 const wchar_t kOmahaClientState[] = L"ClientState"; | 21 const wchar_t kOmahaClientState[] = L"ClientState"; |
| 23 const wchar_t kOmahaClientStateMedium[] = L"ClientStateMedium"; | 22 const wchar_t kOmahaClientStateMedium[] = L"ClientStateMedium"; |
| 24 const wchar_t kOmahaUsagestatsValue[] = L"usagestats"; | 23 const wchar_t kOmahaUsagestatsValue[] = L"usagestats"; |
| 25 | 24 |
| 25 // The Omaha Appid of the host. It should be kept in sync with $(var.OmahaAppid) |
| 26 // defined in remoting/host/installer/chromoting.wxs and the Omaha server |
| 27 // configuration. |
| 28 const wchar_t kHostOmahaAppid[] = L"{b210701e-ffc4-49e3-932b-370728c72662}"; |
| 29 |
| 26 LONG ReadUsageStatsValue(const wchar_t* state_key, DWORD* usagestats_out) { | 30 LONG ReadUsageStatsValue(const wchar_t* state_key, DWORD* usagestats_out) { |
| 27 // presubmit: allow wstring | 31 // presubmit: allow wstring |
| 28 std::wstring client_state = StringPrintf(kOmahaClientStateKeyFormat, | 32 std::wstring client_state = StringPrintf(kOmahaClientStateKeyFormat, |
| 29 state_key, | 33 state_key, |
| 30 remoting::kHostOmahaAppid); | 34 kHostOmahaAppid); |
| 31 base::win::RegKey key; | 35 base::win::RegKey key; |
| 32 LONG result = key.Open(HKEY_LOCAL_MACHINE, client_state.c_str(), KEY_READ); | 36 LONG result = key.Open(HKEY_LOCAL_MACHINE, client_state.c_str(), KEY_READ); |
| 33 if (result != ERROR_SUCCESS) { | 37 if (result != ERROR_SUCCESS) { |
| 34 return result; | 38 return result; |
| 35 } | 39 } |
| 36 | 40 |
| 37 return key.ReadValueDW(kOmahaUsagestatsValue, usagestats_out); | 41 return key.ReadValueDW(kOmahaUsagestatsValue, usagestats_out); |
| 38 } | 42 } |
| 39 | 43 |
| 40 } // namespace | 44 } // namespace |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 return true; | 89 return true; |
| 86 } | 90 } |
| 87 } | 91 } |
| 88 | 92 |
| 89 LOG_GETLASTERROR(ERROR) | 93 LOG_GETLASTERROR(ERROR) |
| 90 << "Failed to record the user's consent to crash dump reporting"; | 94 << "Failed to record the user's consent to crash dump reporting"; |
| 91 return false; | 95 return false; |
| 92 } | 96 } |
| 93 | 97 |
| 94 } // namespace remoting | 98 } // namespace remoting |
| OLD | NEW |