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 // User is signed in, but sync has been stopped. |
58 return l10n_util::GetStringFUTF16(IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED, | 59 return l10n_util::GetStringFUTF16(IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED, |
59 user_name); | 60 user_name); |
60 } | 61 } |
61 } | 62 } |
62 | 63 |
63 if (!service || !service->sync_initialized()) { | 64 if (!service || !service->sync_initialized()) { |
64 // User is not signed in, or sync is still initializing. | 65 // User is not signed in, or sync is still initializing. |
65 return string16(); | 66 return string16(); |
66 } | 67 } |
67 | 68 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 status_label->assign( | 220 status_label->assign( |
220 l10n_util::GetStringUTF16(IDS_SYNC_NTP_SETUP_IN_PROGRESS)); | 221 l10n_util::GetStringUTF16(IDS_SYNC_NTP_SETUP_IN_PROGRESS)); |
221 } | 222 } |
222 if (signin.AuthInProgress()) { | 223 if (signin.AuthInProgress()) { |
223 if (status_label) { | 224 if (status_label) { |
224 status_label->assign( | 225 status_label->assign( |
225 l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL)); | 226 l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL)); |
226 } | 227 } |
227 } else if (auth_error.state() != AuthError::NONE && | 228 } else if (auth_error.state() != AuthError::NONE && |
228 auth_error.state() != AuthError::TWO_FACTOR) { | 229 auth_error.state() != AuthError::TWO_FACTOR) { |
229 if (status_label) { | 230 if (status_label && link_label) { |
230 status_label->clear(); | 231 status_label->clear(); |
231 signin_ui_util::GetStatusLabelsForAuthError( | 232 signin_ui_util::GetStatusLabelsForAuthError( |
232 signin, status_label, NULL); | 233 signin, status_label, link_label); |
233 } | 234 } |
234 result_type = SYNC_ERROR; | 235 result_type = SYNC_ERROR; |
235 } | 236 } |
236 } else if (service->HasUnrecoverableError()) { | 237 } else if (service->HasUnrecoverableError()) { |
237 result_type = SYNC_ERROR; | 238 result_type = SYNC_ERROR; |
238 ProfileSyncService::Status status; | 239 ProfileSyncService::Status status; |
239 service->QueryDetailedSyncStatus(&status); | 240 service->QueryDetailedSyncStatus(&status); |
240 if (ShouldShowActionOnUI(status.sync_protocol_error)) { | 241 if (ShouldShowActionOnUI(status.sync_protocol_error)) { |
241 if (status_label) { | 242 if (status_label) { |
242 GetStatusForActionableError(status.sync_protocol_error, | 243 GetStatusForActionableError(status.sync_protocol_error, |
243 status_label); | 244 status_label); |
244 } | 245 } |
245 } else if (status_label) { | 246 } else if (status_label) { |
246 status_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_SETUP_ERROR)); | 247 status_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_SETUP_ERROR)); |
247 } | 248 } |
| 249 } else if (!signin.GetAuthenticatedUsername().empty()) { |
| 250 // The user is signed in, but sync has been stopped. |
| 251 if (status_label) { |
| 252 string16 label = l10n_util::GetStringFUTF16( |
| 253 IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED, |
| 254 UTF8ToUTF16(signin.GetAuthenticatedUsername())); |
| 255 status_label->assign(label); |
| 256 result_type = PRE_SYNCED; |
| 257 } |
248 } | 258 } |
249 } | 259 } |
250 return result_type; | 260 return result_type; |
251 } | 261 } |
252 | 262 |
253 // Returns the status info for use on the new tab page, where we want slightly | 263 // Returns the status info for use on the new tab page, where we want slightly |
254 // different information than in the settings panel. | 264 // different information than in the settings panel. |
255 MessageType GetStatusInfoForNewTabPage(ProfileSyncService* service, | 265 MessageType GetStatusInfoForNewTabPage(ProfileSyncService* service, |
256 const SigninManagerBase& signin, | 266 const SigninManagerBase& signin, |
257 string16* status_label, | 267 string16* status_label, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 string16 ConstructTime(int64 time_in_int) { | 360 string16 ConstructTime(int64 time_in_int) { |
351 base::Time time = base::Time::FromInternalValue(time_in_int); | 361 base::Time time = base::Time::FromInternalValue(time_in_int); |
352 | 362 |
353 // If time is null the format function returns a time in 1969. | 363 // If time is null the format function returns a time in 1969. |
354 if (time.is_null()) | 364 if (time.is_null()) |
355 return string16(); | 365 return string16(); |
356 return base::TimeFormatFriendlyDateAndTime(time); | 366 return base::TimeFormatFriendlyDateAndTime(time); |
357 } | 367 } |
358 | 368 |
359 } // namespace sync_ui_util | 369 } // namespace sync_ui_util |
OLD | NEW |