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

Side by Side Diff: remoting/host/breakpad_win.cc

Issue 10537182: The user's consent to crash dumps reporting can now be set via the UI (Windows only). The checkbox … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
OLDNEW
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/breakpad.h" 5 #include "remoting/host/breakpad.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/logging.h"
9 #include "base/string16.h" 10 #include "base/string16.h"
10 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
11 #include "base/win/registry.h" 12 #include "base/win/registry.h"
12 #include "remoting/host/constants.h" 13 #include "remoting/host/constants.h"
13 14
14 namespace { 15 namespace {
15 16
16 // The following strings are used to construct the registry key names where 17 // The following strings are used to construct the registry key names where
17 // the user's consent to collect crash dumps is recorded. 18 // the user's consent to collect crash dumps is recorded.
18 const wchar_t kOmahaClientStateKeyFormat[] = L"Google\\Update\\%ls\\%ls"; 19 const wchar_t kOmahaClientStateKeyFormat[] =
20 L"Software\\Google\\Update\\%ls\\%ls";
19 const wchar_t kOmahaClientState[] = L"ClientState"; 21 const wchar_t kOmahaClientState[] = L"ClientState";
20 const wchar_t kOmahaClientStateMedium[] = L"ClientStateMedium"; 22 const wchar_t kOmahaClientStateMedium[] = L"ClientStateMedium";
21 const wchar_t kOmahaUsagestatsValue[] = L"usagestats"; 23 const wchar_t kOmahaUsagestatsValue[] = L"usagestats";
22 24
23 } // namespace 25 } // namespace
24 26
25 namespace remoting { 27 namespace remoting {
26 28
27 bool IsCrashReportingEnabled() { 29 bool GetUsageStatsConsent(bool* set_by_policy_opt, bool* allowed) {
Jamie 2012/06/14 23:43:56 Is the _opt suffix intended to signify that the pa
alexeypa (please no reviews) 2012/06/19 23:27:29 Done.
28 // The user's consent to collect crash dumps is recored as the "usagestats" 30 // The user's consent to collect crash dumps is recored as the "usagestats"
29 // value in the ClientState or ClientStateMedium key. Probe 31 // value in the ClientState or ClientStateMedium key. Probe
30 // the ClientStateMedium key first. 32 // the ClientStateMedium key first.
31 string16 client_state = StringPrintf(kOmahaClientStateKeyFormat, 33 string16 client_state = StringPrintf(kOmahaClientStateKeyFormat,
32 kOmahaClientStateMedium, 34 kOmahaClientStateMedium,
33 remoting::kHostOmahaAppid); 35 remoting::kHostOmahaAppid);
34 base::win::RegKey key; 36 base::win::RegKey key;
35 LONG result = key.Open(HKEY_LOCAL_MACHINE, client_state.c_str(), KEY_READ); 37 LONG result = key.Open(HKEY_LOCAL_MACHINE, client_state.c_str(), KEY_READ);
36 if (result == ERROR_SUCCESS) { 38 if (result == ERROR_SUCCESS) {
37 DWORD value = 0; 39 DWORD value = 0;
38 result = key.ReadValueDW(kOmahaUsagestatsValue, &value); 40 result = key.ReadValueDW(kOmahaUsagestatsValue, &value);
39 if (result == ERROR_SUCCESS) { 41 if (result == ERROR_SUCCESS) {
40 return value != 0; 42 if (set_by_policy_opt != NULL) {
43 *set_by_policy_opt = false;
44 }
45 *allowed = (value != 0);
46 return true;
41 } 47 }
42 } 48 }
43 49
44 client_state = StringPrintf(kOmahaClientStateKeyFormat, 50 client_state = StringPrintf(kOmahaClientStateKeyFormat,
45 kOmahaClientState, 51 kOmahaClientState,
46 remoting::kHostOmahaAppid); 52 remoting::kHostOmahaAppid);
47 result = key.Open(HKEY_LOCAL_MACHINE, client_state.c_str(), KEY_READ); 53 result = key.Open(HKEY_LOCAL_MACHINE, client_state.c_str(), KEY_READ);
48 if (result == ERROR_SUCCESS) { 54 if (result == ERROR_SUCCESS) {
49 DWORD value = 0; 55 DWORD value = 0;
50 result = key.ReadValueDW(kOmahaUsagestatsValue, &value); 56 result = key.ReadValueDW(kOmahaUsagestatsValue, &value);
51 if (result == ERROR_SUCCESS) { 57 if (result == ERROR_SUCCESS) {
52 return value != 0; 58 if (set_by_policy_opt != NULL) {
59 *set_by_policy_opt = false;
Jamie 2012/06/14 23:43:56 You're setting |set_by_policy_opt| to false in bot
alexeypa (please no reviews) 2012/06/19 23:27:29 Yes. set_by_policy is not really used in this CL.
60 }
61 *allowed = (value != 0);
62 return true;
53 } 63 }
54 } 64 }
55 65
56 // Do not collect anything unless the user has explicitly allowed it.
57 return false; 66 return false;
58 } 67 }
59 68
69 bool SetUsageStatsConsent(bool allowed) {
70 DWORD value = allowed;
71 string16 client_state = StringPrintf(kOmahaClientStateKeyFormat,
72 kOmahaClientStateMedium,
73 remoting::kHostOmahaAppid);
74 base::win::RegKey key;
75 LONG result = key.Open(HKEY_LOCAL_MACHINE, client_state.c_str(),
76 KEY_SET_VALUE);
77 if (result == ERROR_SUCCESS) {
78 result = key.WriteValue(kOmahaUsagestatsValue, value);
79 if (result == ERROR_SUCCESS) {
80 return true;
81 }
82 }
83
84 LOG_GETLASTERROR(ERROR)
85 << "Failed to record the user's consent to crash dump reporting";
86 return false;
87 }
88
60 } // namespace remoting 89 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698