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/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // status_label and link_label must either be both NULL or both non-NULL. | 133 // status_label and link_label must either be both NULL or both non-NULL. |
134 MessageType GetStatusInfo(ProfileSyncService* service, | 134 MessageType GetStatusInfo(ProfileSyncService* service, |
135 const SigninManagerBase& signin, | 135 const SigninManagerBase& signin, |
136 StatusLabelStyle style, | 136 StatusLabelStyle style, |
137 base::string16* status_label, | 137 base::string16* status_label, |
138 base::string16* link_label) { | 138 base::string16* link_label) { |
139 DCHECK_EQ(status_label == NULL, link_label == NULL); | 139 DCHECK_EQ(status_label == NULL, link_label == NULL); |
140 | 140 |
141 MessageType result_type(SYNCED); | 141 MessageType result_type(SYNCED); |
142 | 142 |
143 if (signin.GetAuthenticatedUsername().empty()) | 143 if (!signin.IsAuthenticated()) |
144 return PRE_SYNCED; | 144 return PRE_SYNCED; |
145 | 145 |
146 if (!service || service->IsManaged() || service->HasSyncSetupCompleted() || | 146 if (!service || service->IsManaged() || service->HasSyncSetupCompleted() || |
147 service->IsStartSuppressed()) { | 147 service->IsStartSuppressed()) { |
148 // The order or priority is going to be: 1. Unrecoverable errors. | 148 // The order or priority is going to be: 1. Unrecoverable errors. |
149 // 2. Auth errors. 3. Protocol errors. 4. Passphrase errors. | 149 // 2. Auth errors. 3. Protocol errors. 4. Passphrase errors. |
150 | 150 |
151 if (service && service->HasUnrecoverableError()) { | 151 if (service && service->HasUnrecoverableError()) { |
152 if (status_label) { | 152 if (status_label) { |
153 status_label->assign(l10n_util::GetStringFUTF16( | 153 status_label->assign(l10n_util::GetStringFUTF16( |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 ProfileSyncService::Status status; | 258 ProfileSyncService::Status status; |
259 service->QueryDetailedSyncStatus(&status); | 259 service->QueryDetailedSyncStatus(&status); |
260 if (ShouldShowActionOnUI(status.sync_protocol_error)) { | 260 if (ShouldShowActionOnUI(status.sync_protocol_error)) { |
261 if (status_label) { | 261 if (status_label) { |
262 GetStatusForActionableError(status.sync_protocol_error, | 262 GetStatusForActionableError(status.sync_protocol_error, |
263 status_label); | 263 status_label); |
264 } | 264 } |
265 } else if (status_label) { | 265 } else if (status_label) { |
266 status_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_SETUP_ERROR)); | 266 status_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_SETUP_ERROR)); |
267 } | 267 } |
268 } else if (!signin.GetAuthenticatedUsername().empty()) { | 268 } else if (signin.IsAuthenticated()) { |
269 // The user is signed in, but sync has been stopped. | 269 // The user is signed in, but sync has been stopped. |
270 if (status_label) { | 270 if (status_label) { |
271 base::string16 label = l10n_util::GetStringFUTF16( | 271 base::string16 label = l10n_util::GetStringFUTF16( |
272 IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED, | 272 IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED, |
273 base::UTF8ToUTF16(signin.GetAuthenticatedUsername())); | 273 base::UTF8ToUTF16(signin.GetAuthenticatedUsername())); |
274 status_label->assign(label); | 274 status_label->assign(label); |
275 result_type = PRE_SYNCED; | 275 result_type = PRE_SYNCED; |
276 } | 276 } |
277 } | 277 } |
278 } | 278 } |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 base::string16 ConstructTime(int64 time_in_int) { | 379 base::string16 ConstructTime(int64 time_in_int) { |
380 base::Time time = base::Time::FromInternalValue(time_in_int); | 380 base::Time time = base::Time::FromInternalValue(time_in_int); |
381 | 381 |
382 // If time is null the format function returns a time in 1969. | 382 // If time is null the format function returns a time in 1969. |
383 if (time.is_null()) | 383 if (time.is_null()) |
384 return base::string16(); | 384 return base::string16(); |
385 return base::TimeFormatFriendlyDateAndTime(time); | 385 return base::TimeFormatFriendlyDateAndTime(time); |
386 } | 386 } |
387 | 387 |
388 } // namespace sync_ui_util | 388 } // namespace sync_ui_util |
OLD | NEW |