summaryrefslogtreecommitdiffstats
path: root/chrome/browser/google_update_settings_mac.mm
diff options
context:
space:
mode:
authorjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-18 22:17:36 +0000
committerjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-18 22:17:36 +0000
commit3090eeb5afd49e828739b492eb400d8fcf734784 (patch)
treeaddbf256e9a4773ea27edb4718102e49bd133c69 /chrome/browser/google_update_settings_mac.mm
parent1b4d44eb423ebb40c716ae0c44cdb60accef1e37 (diff)
downloadchromium_src-3090eeb5afd49e828739b492eb400d8fcf734784.zip
chromium_src-3090eeb5afd49e828739b492eb400d8fcf734784.tar.gz
chromium_src-3090eeb5afd49e828739b492eb400d8fcf734784.tar.bz2
Hook up stats reporting via default system on OS X.
Allow enabling/disabling stats via user defaults. Fix breakpad to read from global stats setting. To disable stats, type the following in the terminal: defaults write com.google.Chrome usagestats -bool NO BUG=12046 Review URL: http://codereview.chromium.org/113549 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16333 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/google_update_settings_mac.mm')
-rw-r--r--chrome/browser/google_update_settings_mac.mm88
1 files changed, 88 insertions, 0 deletions
diff --git a/chrome/browser/google_update_settings_mac.mm b/chrome/browser/google_update_settings_mac.mm
new file mode 100644
index 0000000..a246803
--- /dev/null
+++ b/chrome/browser/google_update_settings_mac.mm
@@ -0,0 +1,88 @@
+// Copyright (c) 2009 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 <Foundation/Foundation.h>
+
+#include "chrome/installer/util/google_update_settings.h"
+
+#include "base/basictypes.h"
+#include "base/logging.h"
+#include "base/sys_string_conversions.h"
+#include "chrome/installer/util/google_update_constants.h"
+
+namespace google_update {
+
+// This is copied from chrome/installer/util/google_update_constants.cc
+// Reasons duplication acceptable:
+// 1. At the time of this writing, this code is a one-off for the dev release.
+// 2. The value of this constant is unlikely to change and even if it does
+// that negates the point of reusing it in the Mac version.
+// 3. To make x-platform usage fo the constants in google_update_constants.cc
+// we probably want to split them up into windows-only and x-platform strings.
+const wchar_t kRegUsageStatsField[] = L"usagestats";
+
+// Declared in a public namespace for testing purposes.
+// If pref not set, assume true.
+bool GetCollectStatsConsentFromDictionary(NSDictionary* dict) {
+ NSString* collect_stats_key = base::SysWideToNSString(
+ google_update::kRegUsageStatsField);
+ NSNumber* val = [dict objectForKey:collect_stats_key];
+
+ if (![val respondsToSelector:@selector(boolValue)]) {
+ return true;
+ }
+
+ return ([val boolValue] == YES);
+}
+
+} // namespace google_update
+
+// static
+bool GoogleUpdateSettings::GetCollectStatsConsent() {
+ // TODO(mac): This value should be read from the Chrome prefs setting.
+ // For Dev-relesae purposes, we read this value from the user's
+ // defaults. This allows easy control of the setting from the terminal.
+ // To turn stat reporting off, run the following command from the terminal:
+ // $ defaults write com.google.Chrome usagestats -bool 'NO'
+ NSUserDefaults* std_defaults = [NSUserDefaults standardUserDefaults];
+ return google_update::GetCollectStatsConsentFromDictionary(
+ [std_defaults dictionaryRepresentation]);
+}
+
+// static
+bool GoogleUpdateSettings::SetCollectStatsConsent(bool consented) {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+// static
+bool GoogleUpdateSettings::GetBrowser(std::wstring* browser) {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+// static
+bool GoogleUpdateSettings::GetLanguage(std::wstring* language) {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+// static
+bool GoogleUpdateSettings::GetBrand(std::wstring* brand) {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+// static
+bool GoogleUpdateSettings::GetReferral(std::wstring* referral) {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+// static
+bool GoogleUpdateSettings::ClearReferral() {
+ NOTIMPLEMENTED();
+ return false;
+}
+