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

Unified Diff: remoting/host/usage_stats_consent_win.cc

Issue 10535082: /C++ readability/ - Make Chromoting Host report crashes to Breakpad (Windows only). The user must e… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing a bad merge. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/usage_stats_consent.h ('k') | remoting/remoting.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/usage_stats_consent_win.cc
diff --git a/remoting/host/usage_stats_consent_win.cc b/remoting/host/usage_stats_consent_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3b5b283a0c8caad47043e321c505ad5bc37aa74f
--- /dev/null
+++ b/remoting/host/usage_stats_consent_win.cc
@@ -0,0 +1,57 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/host/usage_stats_consent.h"
+
+#include <windows.h>
+#include <string>
+
+#include "base/stringprintf.h"
+#include "base/win/registry.h"
+#include "remoting/host/constants.h"
+
+namespace {
+
+// The following strings are used to construct the registry key names where
+// we record whether the user has consented to crash dump collection.
+const wchar_t kOmahaClientStateKeyFormat[] =
+ L"Software\\Google\\Update\\%ls\\%ls";
+const wchar_t kOmahaClientState[] = L"ClientState";
+const wchar_t kOmahaClientStateMedium[] = L"ClientStateMedium";
+const wchar_t kOmahaUsagestatsValue[] = L"usagestats";
+
+LONG ReadUsageStatsValue(const wchar_t* state_key, DWORD* usagestats_out) {
+ std::wstring client_state = StringPrintf(kOmahaClientStateKeyFormat,
+ state_key,
+ remoting::kHostOmahaAppid);
+ base::win::RegKey key;
+ LONG result = key.Open(HKEY_LOCAL_MACHINE, client_state.c_str(), KEY_READ);
+ if (result != ERROR_SUCCESS) {
+ return result;
+ }
+
+ return key.ReadValueDW(kOmahaUsagestatsValue, usagestats_out);
+}
+
+} // namespace
+
+namespace remoting {
+
+bool IsCrashReportingEnabled() {
+ // The user's consent to collect crash dumps is recored as the "usagestats"
+ // value in the ClientState or ClientStateMedium key. Probe
+ // the ClientStateMedium key first.
+ DWORD value = 0;
+ if (ReadUsageStatsValue(kOmahaClientStateMedium, &value) == ERROR_SUCCESS) {
+ return value != 0;
+ }
+ if (ReadUsageStatsValue(kOmahaClientState, &value) == ERROR_SUCCESS) {
+ return value != 0;
+ }
+
+ // Do not collect anything unless the user has explicitly allowed it.
+ return false;
+}
+
+} // namespace remoting
« no previous file with comments | « remoting/host/usage_stats_consent.h ('k') | remoting/remoting.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698