| 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/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 const SigninManagerBase& signin, | 48 const SigninManagerBase& signin, |
| 49 StatusLabelStyle style) { | 49 StatusLabelStyle style) { |
| 50 string16 user_name = UTF8ToUTF16(signin.GetAuthenticatedUsername()); | 50 string16 user_name = UTF8ToUTF16(signin.GetAuthenticatedUsername()); |
| 51 | 51 |
| 52 if (!user_name.empty()) { | 52 if (!user_name.empty()) { |
| 53 if (!service || service->IsManaged()) { | 53 if (!service || service->IsManaged()) { |
| 54 // User is signed in, but sync is disabled. | 54 // User is signed in, but sync is disabled. |
| 55 return l10n_util::GetStringFUTF16(IDS_SIGNED_IN_WITH_SYNC_DISABLED, | 55 return l10n_util::GetStringFUTF16(IDS_SIGNED_IN_WITH_SYNC_DISABLED, |
| 56 user_name); | 56 user_name); |
| 57 } else if (service->IsStartSuppressed()) { | 57 } else if (service->IsStartSuppressed()) { |
| 58 return l10n_util::GetStringFUTF16(IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED, | 58 ProfileSyncService::Status status; |
| 59 user_name); | 59 service->QueryDetailedSyncStatus(&status); |
| 60 if (status.sync_protocol_error.error_type == syncer::NOT_MY_BIRTHDAY) { |
| 61 return l10n_util::GetStringFUTF16(IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED, |
| 62 user_name); |
| 63 } else { |
| 64 return l10n_util::GetStringFUTF16(IDS_SIGNED_IN_WITH_SYNC_STOPPED, |
| 65 user_name); |
| 66 } |
| 60 } | 67 } |
| 61 } | 68 } |
| 62 | 69 |
| 63 if (!service || !service->sync_initialized()) { | 70 if (!service || !service->sync_initialized()) { |
| 64 // User is not signed in, or sync is still initializing. | 71 // User is not signed in, or sync is still initializing. |
| 65 return string16(); | 72 return string16(); |
| 66 } | 73 } |
| 67 | 74 |
| 68 DCHECK(!user_name.empty()); | 75 DCHECK(!user_name.empty()); |
| 69 | 76 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 ProfileSyncService::Status status; | 245 ProfileSyncService::Status status; |
| 239 service->QueryDetailedSyncStatus(&status); | 246 service->QueryDetailedSyncStatus(&status); |
| 240 if (ShouldShowActionOnUI(status.sync_protocol_error)) { | 247 if (ShouldShowActionOnUI(status.sync_protocol_error)) { |
| 241 if (status_label) { | 248 if (status_label) { |
| 242 GetStatusForActionableError(status.sync_protocol_error, | 249 GetStatusForActionableError(status.sync_protocol_error, |
| 243 status_label); | 250 status_label); |
| 244 } | 251 } |
| 245 } else if (status_label) { | 252 } else if (status_label) { |
| 246 status_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_SETUP_ERROR)); | 253 status_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_SETUP_ERROR)); |
| 247 } | 254 } |
| 255 } else if (!signin.GetAuthenticatedUsername().empty() && |
| 256 !service->HasSyncSetupCompleted()) { |
| 257 // The user is signed in, but sync is disabled. |
| 258 if (status_label) { |
| 259 string16 label = l10n_util::GetStringFUTF16( |
| 260 IDS_SIGNED_IN_WITH_SYNC_STOPPED, |
| 261 UTF8ToUTF16(signin.GetAuthenticatedUsername())); |
| 262 status_label->assign(label); |
| 263 result_type = PRE_SYNCED; |
| 264 } |
| 248 } | 265 } |
| 249 } | 266 } |
| 250 return result_type; | 267 return result_type; |
| 251 } | 268 } |
| 252 | 269 |
| 253 // Returns the status info for use on the new tab page, where we want slightly | 270 // Returns the status info for use on the new tab page, where we want slightly |
| 254 // different information than in the settings panel. | 271 // different information than in the settings panel. |
| 255 MessageType GetStatusInfoForNewTabPage(ProfileSyncService* service, | 272 MessageType GetStatusInfoForNewTabPage(ProfileSyncService* service, |
| 256 const SigninManagerBase& signin, | 273 const SigninManagerBase& signin, |
| 257 string16* status_label, | 274 string16* status_label, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 string16 ConstructTime(int64 time_in_int) { | 367 string16 ConstructTime(int64 time_in_int) { |
| 351 base::Time time = base::Time::FromInternalValue(time_in_int); | 368 base::Time time = base::Time::FromInternalValue(time_in_int); |
| 352 | 369 |
| 353 // If time is null the format function returns a time in 1969. | 370 // If time is null the format function returns a time in 1969. |
| 354 if (time.is_null()) | 371 if (time.is_null()) |
| 355 return string16(); | 372 return string16(); |
| 356 return base::TimeFormatFriendlyDateAndTime(time); | 373 return base::TimeFormatFriendlyDateAndTime(time); |
| 357 } | 374 } |
| 358 | 375 |
| 359 } // namespace sync_ui_util | 376 } // namespace sync_ui_util |
| OLD | NEW |