| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/i18n/number_formatting.h" | 7 #include "base/i18n/number_formatting.h" |
| 8 #include "base/i18n/time_formatting.h" | 8 #include "base/i18n/time_formatting.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/prefs/pref_service.h" | 11 #include "chrome/browser/prefs/pref_service.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "chrome/browser/sync/profile_sync_service.h" | 14 #include "chrome/browser/sync/profile_sync_service.h" |
| 15 #include "chrome/browser/sync/profile_sync_service_factory.h" | 15 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 16 #include "chrome/browser/sync/protocol/proto_enum_conversions.h" | 16 #include "chrome/browser/sync/protocol/proto_enum_conversions.h" |
| 17 #include "chrome/browser/sync/protocol/sync_protocol_error.h" | 17 #include "chrome/browser/sync/protocol/sync_protocol_error.h" |
| 18 #include "chrome/browser/sync/syncable/model_type.h" | 18 #include "chrome/browser/sync/syncable/model_type.h" |
| 19 #include "chrome/browser/sync/sessions/session_state.h" | 19 #include "chrome/browser/sync/sessions/session_state.h" |
| 20 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 21 #include "chrome/browser/ui/browser_window.h" | 21 #include "chrome/browser/ui/browser_window.h" |
| 22 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 23 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| 22 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
| 23 #include "chrome/common/chrome_version_info.h" | 25 #include "chrome/common/chrome_version_info.h" |
| 24 #include "chrome/common/net/gaia/google_service_auth_error.h" | 26 #include "chrome/common/net/gaia/google_service_auth_error.h" |
| 25 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
| 26 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
| 27 #include "grit/browser_resources.h" | 29 #include "grit/browser_resources.h" |
| 28 #include "grit/chromium_strings.h" | 30 #include "grit/chromium_strings.h" |
| 29 #include "grit/generated_resources.h" | 31 #include "grit/generated_resources.h" |
| 30 #include "grit/locale_settings.h" | 32 #include "grit/locale_settings.h" |
| 31 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 MessageType type = GetStatus(service); | 444 MessageType type = GetStatus(service); |
| 443 | 445 |
| 444 if (type == sync_ui_util::SYNCED) | 446 if (type == sync_ui_util::SYNCED) |
| 445 return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNCED_LABEL); | 447 return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNCED_LABEL); |
| 446 else if (type == sync_ui_util::SYNC_ERROR) | 448 else if (type == sync_ui_util::SYNC_ERROR) |
| 447 return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNC_ERROR_LABEL); | 449 return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNC_ERROR_LABEL); |
| 448 else | 450 else |
| 449 return l10n_util::GetStringUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL); | 451 return l10n_util::GetStringUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL); |
| 450 } | 452 } |
| 451 | 453 |
| 452 void OpenSyncMyBookmarksDialog(Profile* profile, | |
| 453 Browser* browser, | |
| 454 ProfileSyncService::SyncEventCodes code) { | |
| 455 ProfileSyncService* service = | |
| 456 ProfileSyncServiceFactory::GetInstance()->GetForProfile( | |
| 457 profile->GetOriginalProfile()); | |
| 458 if (!service || !service->IsSyncEnabled()) { | |
| 459 LOG(DFATAL) << "OpenSyncMyBookmarksDialog called with sync disabled"; | |
| 460 return; | |
| 461 } | |
| 462 | |
| 463 if (service->HasSyncSetupCompleted()) { | |
| 464 bool create_window = browser == NULL; | |
| 465 if (create_window) | |
| 466 browser = Browser::Create(profile); | |
| 467 browser->ShowOptionsTab(chrome::kPersonalOptionsSubPage); | |
| 468 if (create_window) | |
| 469 browser->window()->Show(); | |
| 470 } else { | |
| 471 service->ShowLoginDialog(); | |
| 472 ProfileSyncService::SyncEvent(code); // UMA stats | |
| 473 } | |
| 474 } | |
| 475 | |
| 476 void AddBoolSyncDetail(ListValue* details, | 454 void AddBoolSyncDetail(ListValue* details, |
| 477 const std::string& stat_name, | 455 const std::string& stat_name, |
| 478 bool stat_value) { | 456 bool stat_value) { |
| 479 DictionaryValue* val = new DictionaryValue; | 457 DictionaryValue* val = new DictionaryValue; |
| 480 val->SetString("stat_name", stat_name); | 458 val->SetString("stat_name", stat_name); |
| 481 val->SetBoolean("stat_value", stat_value); | 459 val->SetBoolean("stat_value", stat_value); |
| 482 details->Append(val); | 460 details->Append(val); |
| 483 } | 461 } |
| 484 | 462 |
| 485 void AddStringSyncDetails(ListValue* details, const std::string& stat_name, | 463 void AddStringSyncDetails(ListValue* details, const std::string& stat_name, |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 } | 707 } |
| 730 } else { | 708 } else { |
| 731 version_modifier = " " + version_modifier; | 709 version_modifier = " " + version_modifier; |
| 732 } | 710 } |
| 733 return chrome_version.Name() + " " + chrome_version.OSType() + " " + | 711 return chrome_version.Name() + " " + chrome_version.OSType() + " " + |
| 734 chrome_version.Version() + " (" + chrome_version.LastChange() + ")" + | 712 chrome_version.Version() + " (" + chrome_version.LastChange() + ")" + |
| 735 version_modifier; | 713 version_modifier; |
| 736 } | 714 } |
| 737 | 715 |
| 738 } // namespace sync_ui_util | 716 } // namespace sync_ui_util |
| OLD | NEW |