| 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 29 matching lines...) Expand all Loading... |
| 40 namespace sync_ui_util { | 40 namespace sync_ui_util { |
| 41 | 41 |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 // Returns the message that should be displayed when the user is authenticated | 44 // Returns the message that should be displayed when the user is authenticated |
| 45 // and can connect to the sync server. If the user hasn't yet authenticated, an | 45 // and can connect to the sync server. If the user hasn't yet authenticated, an |
| 46 // empty string is returned. | 46 // empty string is returned. |
| 47 base::string16 GetSyncedStateStatusLabel(ProfileSyncService* service, | 47 base::string16 GetSyncedStateStatusLabel(ProfileSyncService* service, |
| 48 const SigninManagerBase& signin, | 48 const SigninManagerBase& signin, |
| 49 StatusLabelStyle style) { | 49 StatusLabelStyle style) { |
| 50 base::string16 user_name = UTF8ToUTF16(signin.GetAuthenticatedUsername()); | 50 base::string16 user_name = |
| 51 base::UTF8ToUTF16(signin.GetAuthenticatedUsername()); |
| 51 | 52 |
| 52 if (!user_name.empty()) { | 53 if (!user_name.empty()) { |
| 53 if (!service || service->IsManaged()) { | 54 if (!service || service->IsManaged()) { |
| 54 // User is signed in, but sync is disabled. | 55 // User is signed in, but sync is disabled. |
| 55 return l10n_util::GetStringFUTF16(IDS_SIGNED_IN_WITH_SYNC_DISABLED, | 56 return l10n_util::GetStringFUTF16(IDS_SIGNED_IN_WITH_SYNC_DISABLED, |
| 56 user_name); | 57 user_name); |
| 57 } else if (service->IsStartSuppressed()) { | 58 } else if (service->IsStartSuppressed()) { |
| 58 // User is signed in, but sync has been stopped. | 59 // User is signed in, but sync has been stopped. |
| 59 return l10n_util::GetStringFUTF16(IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED, | 60 return l10n_util::GetStringFUTF16(IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED, |
| 60 user_name); | 61 user_name); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 71 // Message may also carry additional advice with an HTML link, if acceptable. | 72 // Message may also carry additional advice with an HTML link, if acceptable. |
| 72 switch (style) { | 73 switch (style) { |
| 73 case PLAIN_TEXT: | 74 case PLAIN_TEXT: |
| 74 return l10n_util::GetStringFUTF16( | 75 return l10n_util::GetStringFUTF16( |
| 75 IDS_SYNC_ACCOUNT_SYNCING_TO_USER, | 76 IDS_SYNC_ACCOUNT_SYNCING_TO_USER, |
| 76 user_name); | 77 user_name); |
| 77 case WITH_HTML: | 78 case WITH_HTML: |
| 78 return l10n_util::GetStringFUTF16( | 79 return l10n_util::GetStringFUTF16( |
| 79 IDS_SYNC_ACCOUNT_SYNCING_TO_USER_WITH_MANAGE_LINK, | 80 IDS_SYNC_ACCOUNT_SYNCING_TO_USER_WITH_MANAGE_LINK, |
| 80 user_name, | 81 user_name, |
| 81 ASCIIToUTF16(chrome::kSyncGoogleDashboardURL)); | 82 base::ASCIIToUTF16(chrome::kSyncGoogleDashboardURL)); |
| 82 default: | 83 default: |
| 83 NOTREACHED(); | 84 NOTREACHED(); |
| 84 return NULL; | 85 return NULL; |
| 85 } | 86 } |
| 86 } | 87 } |
| 87 | 88 |
| 88 void GetStatusForActionableError( | 89 void GetStatusForActionableError( |
| 89 const syncer::SyncProtocolError& error, | 90 const syncer::SyncProtocolError& error, |
| 90 base::string16* status_label) { | 91 base::string16* status_label) { |
| 91 DCHECK(status_label); | 92 DCHECK(status_label); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 GetStatusForActionableError(status.sync_protocol_error, | 247 GetStatusForActionableError(status.sync_protocol_error, |
| 247 status_label); | 248 status_label); |
| 248 } | 249 } |
| 249 } else if (status_label) { | 250 } else if (status_label) { |
| 250 status_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_SETUP_ERROR)); | 251 status_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_SETUP_ERROR)); |
| 251 } | 252 } |
| 252 } else if (!signin.GetAuthenticatedUsername().empty()) { | 253 } else if (!signin.GetAuthenticatedUsername().empty()) { |
| 253 // The user is signed in, but sync has been stopped. | 254 // The user is signed in, but sync has been stopped. |
| 254 if (status_label) { | 255 if (status_label) { |
| 255 base::string16 label = l10n_util::GetStringFUTF16( | 256 base::string16 label = l10n_util::GetStringFUTF16( |
| 256 IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED, | 257 IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED, |
| 257 UTF8ToUTF16(signin.GetAuthenticatedUsername())); | 258 base::UTF8ToUTF16(signin.GetAuthenticatedUsername())); |
| 258 status_label->assign(label); | 259 status_label->assign(label); |
| 259 result_type = PRE_SYNCED; | 260 result_type = PRE_SYNCED; |
| 260 } | 261 } |
| 261 } | 262 } |
| 262 } | 263 } |
| 263 return result_type; | 264 return result_type; |
| 264 } | 265 } |
| 265 | 266 |
| 266 // Returns the status info for use on the new tab page, where we want slightly | 267 // Returns the status info for use on the new tab page, where we want slightly |
| 267 // different information than in the settings panel. | 268 // different information than in the settings panel. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 base::string16 ConstructTime(int64 time_in_int) { | 364 base::string16 ConstructTime(int64 time_in_int) { |
| 364 base::Time time = base::Time::FromInternalValue(time_in_int); | 365 base::Time time = base::Time::FromInternalValue(time_in_int); |
| 365 | 366 |
| 366 // If time is null the format function returns a time in 1969. | 367 // If time is null the format function returns a time in 1969. |
| 367 if (time.is_null()) | 368 if (time.is_null()) |
| 368 return base::string16(); | 369 return base::string16(); |
| 369 return base::TimeFormatFriendlyDateAndTime(time); | 370 return base::TimeFormatFriendlyDateAndTime(time); |
| 370 } | 371 } |
| 371 | 372 |
| 372 } // namespace sync_ui_util | 373 } // namespace sync_ui_util |
| OLD | NEW |