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) { | |
Andrew T Wilson (Slow)
2013/05/15 15:01:24
If you clear the sync dashboard, then restart chro
Raghu Simha
2013/05/16 02:13:20
I just checked -- birthday errors are not persiste
| |
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 status_label->assign( | 226 status_label->assign( |
220 l10n_util::GetStringUTF16(IDS_SYNC_NTP_SETUP_IN_PROGRESS)); | 227 l10n_util::GetStringUTF16(IDS_SYNC_NTP_SETUP_IN_PROGRESS)); |
221 } | 228 } |
222 if (signin.AuthInProgress()) { | 229 if (signin.AuthInProgress()) { |
223 if (status_label) { | 230 if (status_label) { |
224 status_label->assign( | 231 status_label->assign( |
225 l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL)); | 232 l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL)); |
226 } | 233 } |
227 } else if (auth_error.state() != AuthError::NONE && | 234 } else if (auth_error.state() != AuthError::NONE && |
228 auth_error.state() != AuthError::TWO_FACTOR) { | 235 auth_error.state() != AuthError::TWO_FACTOR) { |
229 if (status_label) { | 236 if (status_label && link_label) { |
Andrew T Wilson (Slow)
2013/05/15 15:01:24
Are we sure this is OK? Aren't there callers that
Raghu Simha
2013/05/16 02:13:20
Yes, this is okay. There's a check on line 129 tha
| |
230 status_label->clear(); | 237 status_label->clear(); |
231 signin_ui_util::GetStatusLabelsForAuthError( | 238 signin_ui_util::GetStatusLabelsForAuthError( |
232 signin, status_label, NULL); | 239 signin, status_label, link_label); |
233 } | 240 } |
234 result_type = SYNC_ERROR; | 241 result_type = SYNC_ERROR; |
235 } | 242 } |
236 } else if (service->HasUnrecoverableError()) { | 243 } else if (service->HasUnrecoverableError()) { |
237 result_type = SYNC_ERROR; | 244 result_type = SYNC_ERROR; |
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. | |
Andrew T Wilson (Slow)
2013/05/15 15:01:24
Hmmm. Do you need the !service->HasSyncSetupComple
Raghu Simha
2013/05/16 02:13:20
You're right. I've removed the redundant check.
| |
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 |