diff options
-rw-r--r-- | chrome/browser/gtk/bookmark_bar_gtk.cc | 1 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_toolbar_gtk.cc | 3 | ||||
-rw-r--r-- | chrome/browser/sync/sync_ui_util.cc | 70 | ||||
-rw-r--r-- | chrome/browser/sync/sync_ui_util.h | 2 | ||||
-rw-r--r-- | chrome/browser/sync/sync_ui_util_mac.mm | 3 | ||||
-rw-r--r-- | chrome/browser/views/bookmark_bar_view.cc | 1 | ||||
-rw-r--r-- | chrome/browser/views/toolbar_view.cc | 3 |
7 files changed, 60 insertions, 23 deletions
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc index cac9ed4..00e11a0 100644 --- a/chrome/browser/gtk/bookmark_bar_gtk.cc +++ b/chrome/browser/gtk/bookmark_bar_gtk.cc @@ -1302,6 +1302,7 @@ bool BookmarkBarGtk::ShouldShowSyncErrorButton() { if (sync_service_ && sync_service_->HasSyncSetupCompleted()) { string16 status_text; string16 link_text; + // TODO(akalin): use sync_ui_util::GetStatus instead. sync_ui_util::MessageType sync_status; sync_status = sync_ui_util::GetStatusLabels( sync_service_, &status_text, &link_text); diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc index f59853d..e2ae78f 100644 --- a/chrome/browser/gtk/browser_toolbar_gtk.cc +++ b/chrome/browser/gtk/browser_toolbar_gtk.cc @@ -701,8 +701,7 @@ void BrowserToolbarGtk::OnStateChanged() { string16 label; string16 link; - // TODO(zork): Need a ui helper method to just get the type without - // needing labels. + // TODO(akalin): use sync_ui_util::GetStatus instead. sync_ui_util::MessageType type = sync_ui_util::GetStatusLabels( sync_service_, &label, &link); diff --git a/chrome/browser/sync/sync_ui_util.cc b/chrome/browser/sync/sync_ui_util.cc index b973362..56f6915 100644 --- a/chrome/browser/sync/sync_ui_util.cc +++ b/chrome/browser/sync/sync_ui_util.cc @@ -64,11 +64,14 @@ string16 GetSyncedStateStatusLabel(ProfileSyncService* service) { WideToUTF16(service->GetLastSyncedTimeString())); } -} // namespace +// TODO(akalin): Write unit tests for these three functions below. + +// status_label and link_label must either be both NULL or both non-NULL. +MessageType GetStatusInfo(ProfileSyncService* service, + string16* status_label, + string16* link_label) { + DCHECK_EQ(status_label == NULL, link_label == NULL); -MessageType GetStatusLabels(ProfileSyncService* service, - string16* status_label, - string16* link_label) { MessageType result_type(SYNCED); if (!service) { @@ -83,15 +86,21 @@ MessageType GetStatusLabels(ProfileSyncService* service, // or note that everything is OK with the last synced time. if (status.authenticated) { // Everything is peachy. - status_label->assign(GetSyncedStateStatusLabel(service)); + if (status_label) { + status_label->assign(GetSyncedStateStatusLabel(service)); + } DCHECK_EQ(auth_error.state(), AuthError::NONE); } else if (service->UIShouldDepictAuthInProgress()) { - status_label->assign( + if (status_label) { + status_label->assign( l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL)); + } result_type = PRE_SYNCED; } else if (auth_error.state() != AuthError::NONE) { - GetStatusLabelsForAuthError(auth_error, service, - status_label, link_label); + if (status_label && link_label) { + GetStatusLabelsForAuthError(auth_error, service, + status_label, link_label); + } result_type = SYNC_ERROR; } } else { @@ -101,29 +110,56 @@ MessageType GetStatusLabels(ProfileSyncService* service, if (service->SetupInProgress()) { ProfileSyncService::Status status(service->QueryDetailedSyncStatus()); const AuthError& auth_error = service->GetAuthError(); - status_label->assign( - l10n_util::GetStringUTF16(IDS_SYNC_NTP_SETUP_IN_PROGRESS)); - if (service->UIShouldDepictAuthInProgress()) { + if (status_label) { status_label->assign( - l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL)); + l10n_util::GetStringUTF16(IDS_SYNC_NTP_SETUP_IN_PROGRESS)); + } + if (service->UIShouldDepictAuthInProgress()) { + if (status_label) { + status_label->assign( + l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL)); + } } else if (auth_error.state() != AuthError::NONE) { - status_label->clear(); + if (status_label) { + status_label->clear(); + } GetStatusLabelsForAuthError(auth_error, service, status_label, NULL); result_type = SYNC_ERROR; } else if (!status.authenticated) { - status_label->assign( - l10n_util::GetStringUTF16(IDS_SYNC_ACCOUNT_DETAILS_NOT_ENTERED)); + if (status_label) { + status_label->assign( + l10n_util::GetStringUTF16(IDS_SYNC_ACCOUNT_DETAILS_NOT_ENTERED)); + } } } else if (service->unrecoverable_error_detected()) { result_type = SYNC_ERROR; - status_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_SETUP_ERROR)); + if (status_label) { + status_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_SETUP_ERROR)); + } } else { - status_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_NOT_SET_UP_INFO)); + if (status_label) { + status_label->assign( + l10n_util::GetStringUTF16(IDS_SYNC_NOT_SET_UP_INFO)); + } } } return result_type; } +} // namespace + +MessageType GetStatusLabels(ProfileSyncService* service, + string16* status_label, + string16* link_label) { + DCHECK(status_label); + DCHECK(link_label); + return sync_ui_util::GetStatusInfo(service, status_label, link_label); +} + +MessageType GetStatus(ProfileSyncService* service) { + return sync_ui_util::GetStatusInfo(service, NULL, NULL); +} + void OpenSyncMyBookmarksDialog( Profile* profile, ProfileSyncService::SyncEventCodes code) { ProfileSyncService* service = diff --git a/chrome/browser/sync/sync_ui_util.h b/chrome/browser/sync/sync_ui_util.h index a80359b..53f0036 100644 --- a/chrome/browser/sync/sync_ui_util.h +++ b/chrome/browser/sync/sync_ui_util.h @@ -26,6 +26,8 @@ MessageType GetStatusLabels(ProfileSyncService* service, string16* status_label, string16* link_label); +MessageType GetStatus(ProfileSyncService* service); + // Open the appropriate sync dialog for the given profile (which can be // incognito). |code| should be one of the START_FROM_* codes. void OpenSyncMyBookmarksDialog( diff --git a/chrome/browser/sync/sync_ui_util_mac.mm b/chrome/browser/sync/sync_ui_util_mac.mm index 1e04b22..4cfb6228 100644 --- a/chrome/browser/sync/sync_ui_util_mac.mm +++ b/chrome/browser/sync/sync_ui_util_mac.mm @@ -17,8 +17,7 @@ namespace sync_ui_util { void UpdateSyncItem(id syncItem, BOOL syncEnabled, Profile* profile) { ProfileSyncService* syncService = profile->GetOriginalProfile()->GetProfileSyncService(); - // TODO(timsteele): Need a ui helper method to just get the type - // without needing labels. + // TODO(akalin): use sync_ui_util::GetStatus instead. string16 label, link; sync_ui_util::MessageType status = sync_ui_util::GetStatusLabels(syncService, &label, &link); diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc index 59c85c2..2a2cece 100644 --- a/chrome/browser/views/bookmark_bar_view.cc +++ b/chrome/browser/views/bookmark_bar_view.cc @@ -1719,6 +1719,7 @@ bool BookmarkBarView::ShouldShowSyncErrorButton() { if (sync_service_ && sync_service_->HasSyncSetupCompleted()) { string16 status_text; string16 link_text; + // TODO(akalin): use sync_ui_util::GetStatus instead. sync_ui_util::MessageType sync_status; sync_status = sync_ui_util::GetStatusLabels( sync_service_, &status_text, &link_text); diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc index 8576656..6aae9df 100644 --- a/chrome/browser/views/toolbar_view.cc +++ b/chrome/browser/views/toolbar_view.cc @@ -814,8 +814,7 @@ void ToolbarView::CreateAppMenu() { if (ProfileSyncService::IsSyncEnabled()) { string16 label; string16 link; - // TODO(timsteele): Need a ui helper method to just get the type without - // needing labels. + // TODO(akalin): use sync_ui_util::GetStatus instead. sync_ui_util::MessageType type = sync_ui_util::GetStatusLabels( browser_->profile()->GetOriginalProfile()->GetProfileSyncService(), &label, &link); |