Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "remoting/host/breakpad.h" | |
| 6 | |
| 7 #include <windows.h> | |
| 8 | |
| 9 #include "base/string16.h" | |
| 10 #include "base/stringprintf.h" | |
| 11 #include "base/win/registry.h" | |
| 12 #include "remoting/host/constants.h" | |
| 13 | |
| 14 namespace { | |
| 15 | |
| 16 // The following strings are used to construct the registry key names where | |
| 17 // the user's consent to collect crash dumps is recorded. | |
|
Peter Kasting
2012/06/14 20:16:27
Nit: "...where we record whether the user has cons
alexeypa (please no reviews)
2012/06/15 18:45:49
Done.
| |
| 18 const wchar_t kOmahaClientStateKeyFormat[] = L"Google\\Update\\%ls\\%ls"; | |
| 19 const wchar_t kOmahaClientState[] = L"ClientState"; | |
| 20 const wchar_t kOmahaClientStateMedium[] = L"ClientStateMedium"; | |
| 21 const wchar_t kOmahaUsagestatsValue[] = L"usagestats"; | |
| 22 | |
| 23 } // namespace | |
| 24 | |
| 25 namespace remoting { | |
| 26 | |
| 27 bool IsCrashReportingEnabled() { | |
| 28 // The user's consent to collect crash dumps is recored as the "usagestats" | |
| 29 // value in the ClientState or ClientStateMedium key. Probe | |
| 30 // the ClientStateMedium key first. | |
| 31 string16 client_state = StringPrintf(kOmahaClientStateKeyFormat, | |
|
Peter Kasting
2012/06/14 20:16:27
|client_state| should be a std::wstring given the
alexeypa (please no reviews)
2012/06/15 18:45:49
Done.
| |
| 32 kOmahaClientStateMedium, | |
| 33 remoting::kHostOmahaAppid); | |
| 34 base::win::RegKey key; | |
| 35 LONG result = key.Open(HKEY_LOCAL_MACHINE, client_state.c_str(), KEY_READ); | |
| 36 if (result == ERROR_SUCCESS) { | |
| 37 DWORD value = 0; | |
| 38 result = key.ReadValueDW(kOmahaUsagestatsValue, &value); | |
| 39 if (result == ERROR_SUCCESS) { | |
|
Peter Kasting
2012/06/14 20:16:27
Nit: If you like, you may omit {} on one-line cond
alexeypa (please no reviews)
2012/06/15 18:45:49
I tend to keep {} even for one-liners because they
Peter Kasting
2012/06/15 19:02:42
That's fine. Just make sure you're consistent wit
| |
| 40 return value != 0; | |
| 41 } | |
| 42 } | |
| 43 | |
| 44 client_state = StringPrintf(kOmahaClientStateKeyFormat, | |
| 45 kOmahaClientState, | |
| 46 remoting::kHostOmahaAppid); | |
| 47 result = key.Open(HKEY_LOCAL_MACHINE, client_state.c_str(), KEY_READ); | |
| 48 if (result == ERROR_SUCCESS) { | |
| 49 DWORD value = 0; | |
| 50 result = key.ReadValueDW(kOmahaUsagestatsValue, &value); | |
| 51 if (result == ERROR_SUCCESS) { | |
| 52 return value != 0; | |
| 53 } | |
| 54 } | |
| 55 | |
| 56 // Do not collect anything unless the user has explicitly allowed it. | |
| 57 return false; | |
| 58 } | |
| 59 | |
| 60 } // namespace remoting | |
| OLD | NEW |