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

Side by Side Diff: chrome/browser/sync/sync_ui_util.cc

Issue 5159001: Rest of the autofill work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Autofill code after fixing the lint errors. Created 10 years 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 | Annotate | Revision Log
OLDNEW
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...) Expand 10 before | Expand all | Expand 10 after
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::FromTimeT(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
236 return time_in_string;
237 }
238
218 std::string MakeSyncAuthErrorText( 239 std::string MakeSyncAuthErrorText(
219 const GoogleServiceAuthError::State& state) { 240 const GoogleServiceAuthError::State& state) {
220 switch (state) { 241 switch (state) {
221 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: 242 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS:
222 case GoogleServiceAuthError::ACCOUNT_DELETED: 243 case GoogleServiceAuthError::ACCOUNT_DELETED:
223 case GoogleServiceAuthError::ACCOUNT_DISABLED: 244 case GoogleServiceAuthError::ACCOUNT_DISABLED:
224 case GoogleServiceAuthError::SERVICE_UNAVAILABLE: 245 case GoogleServiceAuthError::SERVICE_UNAVAILABLE:
225 return "INVALID_GAIA_CREDENTIALS"; 246 return "INVALID_GAIA_CREDENTIALS";
226 case GoogleServiceAuthError::USER_NOT_SIGNED_UP: 247 case GoogleServiceAuthError::USER_NOT_SIGNED_UP:
227 return "USER_NOT_SIGNED_UP"; 248 return "USER_NOT_SIGNED_UP";
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 service->backend()->GetModelSafeRoutingInfo(&routes); 337 service->backend()->GetModelSafeRoutingInfo(&routes);
317 ListValue* routing_info = new ListValue(); 338 ListValue* routing_info = new ListValue();
318 strings->Set("routing_info", routing_info); 339 strings->Set("routing_info", routing_info);
319 browser_sync::ModelSafeRoutingInfo::const_iterator it = routes.begin(); 340 browser_sync::ModelSafeRoutingInfo::const_iterator it = routes.begin();
320 for (; it != routes.end(); ++it) { 341 for (; it != routes.end(); ++it) {
321 DictionaryValue* val = new DictionaryValue; 342 DictionaryValue* val = new DictionaryValue;
322 val->SetString("model_type", ModelTypeToString(it->first)); 343 val->SetString("model_type", ModelTypeToString(it->first));
323 val->SetString("group", ModelSafeGroupToString(it->second)); 344 val->SetString("group", ModelSafeGroupToString(it->second));
324 routing_info->Append(val); 345 routing_info->Append(val);
325 } 346 }
347
348 sync_ui_util::AddBoolSyncDetail(details,
349 "Autofill Migrated",
350 service->backend()->GetAutofillMigrationState() ==
351 syncable::Directory::PersistedKernelInfo::MIGRATED);
352 syncable::AutofillMigrationDebugInfo& info =
353 service->backend()->GetAutofillMigrationDebugInfo();
354
355 sync_ui_util::AddIntSyncDetail(details,
356 "Bookmarks created during migration",
357 info.bookmarks_added_during_migration);
358 sync_ui_util::AddIntSyncDetail(details,
359 "Autofill entries created during migration",
360 info.autofill_entries_added_during_migration);
361 sync_ui_util::AddIntSyncDetail(details,
362 "Autofill Profiles created during migration",
363 info.autofill_profile_added_during_migration);
364
365 DictionaryValue* val = new DictionaryValue;
366 val->SetString("stat_name", "Autofill Migration Time");
367 val->SetString("stat_value", ConstructTime(info.autofill_migration_time));
368 details->Append(val);
326 } 369 }
327 } 370 }
328 } 371 }
329 372
330 } // namespace sync_ui_util 373 } // namespace sync_ui_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698