OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/sync/sync_ui_util.h" | 5 #include "chrome/browser/sync/sync_ui_util.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/i18n/number_formatting.h" | 8 #include "base/i18n/number_formatting.h" |
| 9 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/sync/profile_sync_service.h" | 12 #include "chrome/browser/sync/profile_sync_service.h" |
12 #include "chrome/browser/ui/options/options_window.h" | 13 #include "chrome/browser/ui/options/options_window.h" |
13 #include "chrome/common/net/gaia/google_service_auth_error.h" | 14 #include "chrome/common/net/gaia/google_service_auth_error.h" |
14 #include "grit/chromium_strings.h" | 15 #include "grit/chromium_strings.h" |
15 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
16 | 17 |
17 typedef GoogleServiceAuthError AuthError; | 18 typedef GoogleServiceAuthError AuthError; |
18 | 19 |
(...skipping 189 matching lines...) Loading... |
208 } | 209 } |
209 | 210 |
210 void AddIntSyncDetail(ListValue* details, const std::string& stat_name, | 211 void AddIntSyncDetail(ListValue* details, const std::string& stat_name, |
211 int64 stat_value) { | 212 int64 stat_value) { |
212 DictionaryValue* val = new DictionaryValue; | 213 DictionaryValue* val = new DictionaryValue; |
213 val->SetString("stat_name", stat_name); | 214 val->SetString("stat_name", stat_name); |
214 val->SetString("stat_value", base::FormatNumber(stat_value)); | 215 val->SetString("stat_value", base::FormatNumber(stat_value)); |
215 details->Append(val); | 216 details->Append(val); |
216 } | 217 } |
217 | 218 |
| 219 std::string ConstructTime(int64 time_in_int) { |
| 220 base::Time time = base::Time::FromInternalValue(time_in_int); |
| 221 if (time.is_null()) |
| 222 return string(); |
| 223 base::Time::Exploded exploded; |
| 224 time.LocalExplode(&exploded); |
| 225 |
| 226 std::string time_in_string; |
| 227 time_in_string.append(UTF16ToUTF8( |
| 228 base::FormatNumber(static_cast<int64>(exploded.month)))); |
| 229 time_in_string.append("-"); |
| 230 time_in_string.append(UTF16ToUTF8(base::FormatNumber( |
| 231 static_cast<int64>(exploded.day_of_month)))); |
| 232 time_in_string.append("-"); |
| 233 time_in_string.append(UTF16ToUTF8(base::FormatNumber( |
| 234 static_cast<int64>(exploded.year)))); |
| 235 time_in_string.append(" "); |
| 236 time_in_string.append(UTF16ToUTF8(base::FormatNumber( |
| 237 static_cast<int64>(exploded.hour)))); |
| 238 time_in_string.append(":"); |
| 239 time_in_string.append(UTF16ToUTF8(base::FormatNumber( |
| 240 static_cast<int64>(exploded.minute)))); |
| 241 time_in_string.append(":"); |
| 242 time_in_string.append(UTF16ToUTF8(base::FormatNumber( |
| 243 static_cast<int64>(exploded.second)))); |
| 244 |
| 245 return time_in_string; |
| 246 } |
| 247 |
218 std::string MakeSyncAuthErrorText( | 248 std::string MakeSyncAuthErrorText( |
219 const GoogleServiceAuthError::State& state) { | 249 const GoogleServiceAuthError::State& state) { |
220 switch (state) { | 250 switch (state) { |
221 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: | 251 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: |
222 case GoogleServiceAuthError::ACCOUNT_DELETED: | 252 case GoogleServiceAuthError::ACCOUNT_DELETED: |
223 case GoogleServiceAuthError::ACCOUNT_DISABLED: | 253 case GoogleServiceAuthError::ACCOUNT_DISABLED: |
224 case GoogleServiceAuthError::SERVICE_UNAVAILABLE: | 254 case GoogleServiceAuthError::SERVICE_UNAVAILABLE: |
225 return "INVALID_GAIA_CREDENTIALS"; | 255 return "INVALID_GAIA_CREDENTIALS"; |
226 case GoogleServiceAuthError::USER_NOT_SIGNED_UP: | 256 case GoogleServiceAuthError::USER_NOT_SIGNED_UP: |
227 return "USER_NOT_SIGNED_UP"; | 257 return "USER_NOT_SIGNED_UP"; |
(...skipping 88 matching lines...) Loading... |
316 service->backend()->GetModelSafeRoutingInfo(&routes); | 346 service->backend()->GetModelSafeRoutingInfo(&routes); |
317 ListValue* routing_info = new ListValue(); | 347 ListValue* routing_info = new ListValue(); |
318 strings->Set("routing_info", routing_info); | 348 strings->Set("routing_info", routing_info); |
319 browser_sync::ModelSafeRoutingInfo::const_iterator it = routes.begin(); | 349 browser_sync::ModelSafeRoutingInfo::const_iterator it = routes.begin(); |
320 for (; it != routes.end(); ++it) { | 350 for (; it != routes.end(); ++it) { |
321 DictionaryValue* val = new DictionaryValue; | 351 DictionaryValue* val = new DictionaryValue; |
322 val->SetString("model_type", ModelTypeToString(it->first)); | 352 val->SetString("model_type", ModelTypeToString(it->first)); |
323 val->SetString("group", ModelSafeGroupToString(it->second)); | 353 val->SetString("group", ModelSafeGroupToString(it->second)); |
324 routing_info->Append(val); | 354 routing_info->Append(val); |
325 } | 355 } |
| 356 |
| 357 sync_ui_util::AddBoolSyncDetail(details, |
| 358 "Autofill Migrated", |
| 359 service->backend()->GetAutofillMigrationState() == |
| 360 syncable::MIGRATED); |
| 361 syncable::AutofillMigrationDebugInfo& info = |
| 362 service->backend()->GetAutofillMigrationDebugInfo(); |
| 363 |
| 364 sync_ui_util::AddIntSyncDetail(details, |
| 365 "Bookmarks created during migration", |
| 366 info.bookmarks_added_during_migration); |
| 367 sync_ui_util::AddIntSyncDetail(details, |
| 368 "Autofill entries created during migration", |
| 369 info.autofill_entries_added_during_migration); |
| 370 sync_ui_util::AddIntSyncDetail(details, |
| 371 "Autofill Profiles created during migration", |
| 372 info.autofill_profile_added_during_migration); |
| 373 |
| 374 DictionaryValue* val = new DictionaryValue; |
| 375 val->SetString("stat_name", "Autofill Migration Time"); |
| 376 val->SetString("stat_value", ConstructTime(info.autofill_migration_time)); |
| 377 details->Append(val); |
326 } | 378 } |
327 } | 379 } |
328 } | 380 } |
329 | 381 |
330 } // namespace sync_ui_util | 382 } // namespace sync_ui_util |
OLD | NEW |