~ubuntu-branches/ubuntu/oneiric/mozc/oneiric

« back to all changes in this revision

Viewing changes to base/stats_config_util.cc

  • Committer: Bazaar Package Importer
  • Author(s): Nobuhiro Iwamatsu
  • Date: 2010-07-14 03:26:47 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100714032647-13qjisj6m8cm8jdx
Tags: 0.12.410.102-1
* New upstream release (Closes: #588971).
  - Add mozc-server, mozc-utils-gui and scim-mozc packages.
* Update debian/rules.
  Add --gypdir option to build_mozc.py.
* Update debian/control.
  - Bumped standards-version to 3.9.0.
  - Update description.
* Add mozc icon (Closes: #588972).
* Add patch which revises issue 18.
  ibus_mozc_issue18.patch
* kFreeBSD build support.
  support_kfreebsd.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
93
93
// |*disabled_by_hkcu| will be set to |true| if the user disabled the usagestats
94
94
// by the registry key under HKUC.  The caller should behave as if the
95
95
// usagestats is disabled regardless of the settings under HKLM.
96
 
void FixupUserstatsSettingsUnderHKCU(bool *disabled_by_hkcu) {
 
96
void FixupUsagestatsSettingsUnderHKCU(bool *disabled_by_hkcu) {
97
97
  bool dummy = false;
98
98
  bool &usagestats_disabled_by_hkcu =
99
99
      (disabled_by_hkcu != NULL ? *disabled_by_hkcu : dummy);
186
186
bool WinStatsConfigUtilImpl::IsEnabled() {
187
187
  // Try to clean the registry if wrongly set.
188
188
  bool disabled_by_hkcu = false;
189
 
  FixupUserstatsSettingsUnderHKCU(&disabled_by_hkcu);
 
189
  FixupUsagestatsSettingsUnderHKCU(&disabled_by_hkcu);
190
190
#ifdef CHANNEL_DEV
191
191
  return true;
192
192
#else
230
230
#ifdef CHANNEL_DEV
231
231
  // On Dev channel, usage stats and crash report should be always sent.
232
232
  val = true;
 
233
  // We always returns true in DevChannel.
 
234
  const bool kReturnCodeInError = true;
233
235
#else
 
236
  const bool kReturnCodeInError = false;
 
237
#endif  // CHANNEL_DEV
 
238
 
234
239
  CRegKey key;
235
240
  const REGSAM sam_desired = KEY_WRITE |
236
241
      (mozc::Util::IsWindowsX64() ? KEY_WOW64_32KEY : 0);
238
243
                           REG_NONE, REG_OPTION_NON_VOLATILE,
239
244
                           sam_desired);
240
245
  if (ERROR_SUCCESS != result) {
241
 
    return false;
 
246
    return kReturnCodeInError;
242
247
  }
 
248
 
243
249
  result = key.SetDWORDValue(kSendStatsName, val ? 1 : 0);
244
250
  if (ERROR_SUCCESS != result) {
245
 
    return false;
246
 
  }
247
 
#endif  // CHANNEL_DEV
 
251
    return kReturnCodeInError;
 
252
  }
 
253
 
 
254
  // We've successfully set 1 to the proper entry.
 
255
  // Remove the corresponding entry under "ClientStateMedium" just in case.
 
256
  CRegKey key_medium;
 
257
  result = key_medium.Open(HKEY_LOCAL_MACHINE,
 
258
                           kOmahaUsageKeyForEveryone,
 
259
                           sam_desired);
 
260
  if (result == ERROR_SUCCESS && key_medium) {
 
261
    // We do not check the result here.
 
262
    key_medium.DeleteValue(kSendStatsName);
 
263
  }
248
264
  return true;
249
265
}
 
266
 
250
267
#endif  // OS_WINDOWS
251
268
 
252
269
#ifdef OS_MACOSX
263
280
};
264
281
 
265
282
MacStatsConfigUtilImpl::MacStatsConfigUtilImpl() {
266
 
  string dir;
267
 
  dir = MacUtil::GetApplicationSupportDirectory();
268
 
  // "~/Library/Application Support"
269
 
  dir += "/Google";
270
 
  ::mkdir(dir.c_str(), 0755);
271
 
  dir += "/JapaneseInput";
272
 
  ::mkdir(dir.c_str(), 0755);
273
 
  // TODO(toshiyuki): this is duplicate code of Util
274
 
 
275
 
  config_file_ = dir + "/.usagestats.db";  // hidden file
 
283
  config_file_ =
 
284
      Util::GetUserProfileDirectory() + "/.usagestats.db";  // hidden file
276
285
}
277
286
 
278
287
MacStatsConfigUtilImpl::~MacStatsConfigUtilImpl() {}