| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <string> |
| 10 |
| 9 #include "base/i18n/number_formatting.h" | 11 #include "base/i18n/number_formatting.h" |
| 10 #include "base/i18n/time_formatting.h" | 12 #include "base/i18n/time_formatting.h" |
| 11 #include "base/metrics/field_trial.h" | 13 #include "base/metrics/field_trial.h" |
| 12 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 14 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
| 17 #include "chrome/browser/signin/signin_error_controller_factory.h" | 19 #include "chrome/browser/signin/signin_error_controller_factory.h" |
| 18 #include "chrome/browser/signin/signin_ui_util.h" | 20 #include "chrome/browser/signin/signin_ui_util.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 if (!signin.IsAuthenticated()) | 161 if (!signin.IsAuthenticated()) |
| 160 return PRE_SYNCED; | 162 return PRE_SYNCED; |
| 161 | 163 |
| 162 if (!service || service->IsManaged() || service->IsFirstSetupComplete() || | 164 if (!service || service->IsManaged() || service->IsFirstSetupComplete() || |
| 163 !service->IsSyncRequested()) { | 165 !service->IsSyncRequested()) { |
| 164 // The order or priority is going to be: 1. Unrecoverable errors. | 166 // The order or priority is going to be: 1. Unrecoverable errors. |
| 165 // 2. Auth errors. 3. Protocol errors. 4. Passphrase errors. | 167 // 2. Auth errors. 3. Protocol errors. 4. Passphrase errors. |
| 166 | 168 |
| 167 if (service && service->HasUnrecoverableError()) { | 169 if (service && service->HasUnrecoverableError()) { |
| 168 if (status_label) { | 170 if (status_label) { |
| 169 status_label->assign(l10n_util::GetStringFUTF16( | 171 // Unrecoverable error is sometimes accompanied by actionable error. |
| 170 IDS_SYNC_STATUS_UNRECOVERABLE_ERROR, | 172 // If actionable error is set then display corresponding message, |
| 171 l10n_util::GetStringUTF16(IDS_SYNC_UNRECOVERABLE_ERROR_HELP_URL))); | 173 // otherwise show generic unrecoverable error message. |
| 174 ProfileSyncService::Status status; |
| 175 service->QueryDetailedSyncStatus(&status); |
| 176 if (ShouldShowActionOnUI(status.sync_protocol_error)) { |
| 177 GetStatusForActionableError(status.sync_protocol_error, status_label); |
| 178 } else { |
| 179 status_label->assign(l10n_util::GetStringFUTF16( |
| 180 IDS_SYNC_STATUS_UNRECOVERABLE_ERROR, |
| 181 l10n_util::GetStringUTF16( |
| 182 IDS_SYNC_UNRECOVERABLE_ERROR_HELP_URL))); |
| 183 } |
| 172 } | 184 } |
| 173 return SYNC_ERROR; | 185 return SYNC_ERROR; |
| 174 } | 186 } |
| 175 | 187 |
| 176 // For auth errors first check if an auth is in progress. | 188 // For auth errors first check if an auth is in progress. |
| 177 if (signin.AuthInProgress()) { | 189 if (signin.AuthInProgress()) { |
| 178 if (status_label) { | 190 if (status_label) { |
| 179 status_label->assign( | 191 status_label->assign( |
| 180 l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL)); | 192 l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL)); |
| 181 } | 193 } |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 base::string16 ConstructTime(int64_t time_in_int) { | 410 base::string16 ConstructTime(int64_t time_in_int) { |
| 399 base::Time time = base::Time::FromInternalValue(time_in_int); | 411 base::Time time = base::Time::FromInternalValue(time_in_int); |
| 400 | 412 |
| 401 // If time is null the format function returns a time in 1969. | 413 // If time is null the format function returns a time in 1969. |
| 402 if (time.is_null()) | 414 if (time.is_null()) |
| 403 return base::string16(); | 415 return base::string16(); |
| 404 return base::TimeFormatFriendlyDateAndTime(time); | 416 return base::TimeFormatFriendlyDateAndTime(time); |
| 405 } | 417 } |
| 406 | 418 |
| 407 } // namespace sync_ui_util | 419 } // namespace sync_ui_util |
| OLD | NEW |