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

Side by Side Diff: chrome/browser/google_update_settings_mac.mm

Issue 173020: Make Mac first run store sentinel in Profile directory. (Closed)
Patch Set: spelling Created 11 years, 4 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <Foundation/Foundation.h> 5 #include <Foundation/Foundation.h>
6 6
7 #include "chrome/installer/util/google_update_settings.h" 7 #include "chrome/installer/util/google_update_settings.h"
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/sys_string_conversions.h" 11 #include "base/sys_string_conversions.h"
12 #include "chrome/installer/util/google_update_constants.h" 12 #include "chrome/installer/util/google_update_constants.h"
13 13
14 namespace google_update {
15
16 // This is copied from chrome/installer/util/google_update_constants.cc
17 // Reasons duplication acceptable:
18 // 1. At the time of this writing, this code is a one-off for the dev release.
19 // 2. The value of this constant is unlikely to change and even if it does
20 // that negates the point of reusing it in the Mac version.
21 // 3. To make x-platform usage fo the constants in google_update_constants.cc
22 // we probably want to split them up into windows-only and x-platform strings.
23 const wchar_t kRegUsageStatsField[] = L"usagestats";
24
25 // Declared in a public namespace for testing purposes.
26 // If pref not set, assume false.
27 bool GetCollectStatsConsentFromDictionary(NSDictionary* dict) {
28 NSString* collect_stats_key = base::SysWideToNSString(
29 google_update::kRegUsageStatsField);
30 NSNumber* val = [dict objectForKey:collect_stats_key];
31
32 if (![val respondsToSelector:@selector(boolValue)]) {
33 return false;
34 }
35
36 return ([val boolValue] == YES);
37 }
38
39 } // namespace google_update
40
41 // static
42 bool GoogleUpdateSettings::GetCollectStatsConsent() {
43 // TODO(mac): This value should be read from the Chrome prefs setting.
44 // For Dev-release purposes, we read this value from the user's
45 // defaults. This allows easy control of the setting from the terminal.
46 // To turn stat reporting off, run the following command from the terminal:
47 // $ defaults write com.google.Chrome usagestats -bool 'NO'
48 NSUserDefaults* std_defaults = [NSUserDefaults standardUserDefaults];
49 return google_update::GetCollectStatsConsentFromDictionary(
50 [std_defaults dictionaryRepresentation]);
51 }
52
53 // static
54 bool GoogleUpdateSettings::SetCollectStatsConsent(bool consented) {
55 NSString* collect_stats_key = base::SysWideToNSString(
56 google_update::kRegUsageStatsField);
57 NSUserDefaults* std_defaults = [NSUserDefaults standardUserDefaults];
58 BOOL val_to_store = consented ? YES : NO;
59 [std_defaults setBool:val_to_store forKey:collect_stats_key];
60 return [std_defaults synchronize];
61 }
62
63 // static 14 // static
64 bool GoogleUpdateSettings::GetBrowser(std::wstring* browser) { 15 bool GoogleUpdateSettings::GetBrowser(std::wstring* browser) {
65 NOTIMPLEMENTED(); 16 NOTIMPLEMENTED();
66 return false; 17 return false;
67 } 18 }
68 19
69 // static 20 // static
70 bool GoogleUpdateSettings::GetLanguage(std::wstring* language) { 21 bool GoogleUpdateSettings::GetLanguage(std::wstring* language) {
71 NOTIMPLEMENTED(); 22 NOTIMPLEMENTED();
72 return false; 23 return false;
(...skipping 10 matching lines...) Expand all
83 NOTIMPLEMENTED(); 34 NOTIMPLEMENTED();
84 return false; 35 return false;
85 } 36 }
86 37
87 // static 38 // static
88 bool GoogleUpdateSettings::ClearReferral() { 39 bool GoogleUpdateSettings::ClearReferral() {
89 NOTIMPLEMENTED(); 40 NOTIMPLEMENTED();
90 return false; 41 return false;
91 } 42 }
92 43
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698