Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <Foundation/Foundation.h> | |
| 6 | |
| 7 #include "chrome/installer/util/google_update_settings.h" | |
| 8 | |
| 9 #include "base/basictypes.h" | |
| 10 #include "base/logging.h" | |
| 11 #include "base/sys_string_conversions.h" | |
| 12 #include "chrome/installer/util/google_update_constants.h" | |
| 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. | |
|
John Grabowski
2009/05/18 21:49:50
Extra comments:
// If pref not set, assume yes
| |
| 26 bool GetCollectStatsConsentFromDictionary(NSDictionary *dict) { | |
|
John Grabowski
2009/05/18 21:49:50
NSDictionary * --> NSDictionary*
NSString * --> NS
| |
| 27 NSString *collect_stats_key = base::SysWideToNSString( | |
| 28 google_update::kRegUsageStatsField); | |
| 29 NSNumber *val = [dict objectForKey:collect_stats_key]; | |
| 30 | |
| 31 if (val == nil || ![val respondsToSelector:@selector(boolValue)]) { | |
|
pink (ping after 24hrs)
2009/05/18 21:21:09
nil check not needed.
| |
| 32 return true; | |
| 33 } | |
| 34 | |
| 35 return ([val boolValue] == YES); | |
| 36 } | |
| 37 | |
| 38 } // namespace google_update | |
| 39 | |
| 40 // static | |
| 41 bool GoogleUpdateSettings::GetCollectStatsConsent() { | |
| 42 // TODO(mac): This value should be read from the Chrome prefs setting. | |
| 43 // For Dev-relesae purposes, we read this value from the user's | |
| 44 // defaults. This allows easy control of the setting from the terminal. | |
| 45 // To turn stat reporting off, run the following command from the terminal: | |
| 46 // $ defaults write com.google.Chrome usagestats -bool 'NO' | |
| 47 NSUserDefaults *std_defaults = [NSUserDefaults standardUserDefaults]; | |
| 48 return google_update::GetCollectStatsConsentFromDictionary( | |
| 49 [std_defaults dictionaryRepresentation]); | |
| 50 } | |
| 51 | |
| 52 // static | |
| 53 bool GoogleUpdateSettings::SetCollectStatsConsent(bool consented) { | |
| 54 NOTIMPLEMENTED(); | |
| 55 return false; | |
| 56 } | |
| 57 | |
| 58 // static | |
| 59 bool GoogleUpdateSettings::GetBrowser(std::wstring* browser) { | |
| 60 NOTIMPLEMENTED(); | |
| 61 return false; | |
| 62 } | |
| 63 | |
| 64 // static | |
| 65 bool GoogleUpdateSettings::GetLanguage(std::wstring* language) { | |
| 66 NOTIMPLEMENTED(); | |
| 67 return false; | |
| 68 } | |
| 69 | |
| 70 // static | |
| 71 bool GoogleUpdateSettings::GetBrand(std::wstring* brand) { | |
| 72 NOTIMPLEMENTED(); | |
| 73 return false; | |
| 74 } | |
| 75 | |
| 76 // static | |
| 77 bool GoogleUpdateSettings::GetReferral(std::wstring* referral) { | |
| 78 NOTIMPLEMENTED(); | |
| 79 return false; | |
| 80 } | |
| 81 | |
| 82 // static | |
| 83 bool GoogleUpdateSettings::ClearReferral() { | |
| 84 NOTIMPLEMENTED(); | |
| 85 return false; | |
| 86 } | |
| 87 | |
| OLD | NEW |