Chromium Code Reviews| 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 25 matching lines...) Expand all Loading... | |
| 36 #if defined(OS_CHROMEOS) | 36 #if defined(OS_CHROMEOS) |
| 37 #include "components/user_manager/user_manager.h" | 37 #include "components/user_manager/user_manager.h" |
| 38 #endif // defined(OS_CHROMEOS) | 38 #endif // defined(OS_CHROMEOS) |
| 39 | 39 |
| 40 typedef GoogleServiceAuthError AuthError; | 40 typedef GoogleServiceAuthError AuthError; |
| 41 | 41 |
| 42 namespace sync_ui_util { | 42 namespace sync_ui_util { |
| 43 | 43 |
| 44 namespace { | 44 namespace { |
| 45 | 45 |
| 46 bool IsChromeAwayFromChromeEnabled() { | |
|
Nicolas Zea
2015/03/05 21:41:35
nit: use IsChromeDashboardEnabled instead
| |
| 47 const std::string group_name = | |
| 48 base::FieldTrialList::FindFullName("ChromeDashboard"); | |
|
Nicolas Zea
2015/03/05 21:41:35
It's good style to #include any libraries you depe
| |
| 49 return group_name == "Enabled"; | |
| 50 } | |
| 51 | |
| 46 // Returns the message that should be displayed when the user is authenticated | 52 // Returns the message that should be displayed when the user is authenticated |
| 47 // and can connect to the sync server. If the user hasn't yet authenticated, an | 53 // and can connect to the sync server. If the user hasn't yet authenticated, an |
| 48 // empty string is returned. | 54 // empty string is returned. |
| 49 base::string16 GetSyncedStateStatusLabel(ProfileSyncService* service, | 55 base::string16 GetSyncedStateStatusLabel(ProfileSyncService* service, |
| 50 const SigninManagerBase& signin, | 56 const SigninManagerBase& signin, |
| 51 StatusLabelStyle style) { | 57 StatusLabelStyle style) { |
| 52 std::string user_display_name = signin.GetAuthenticatedUsername(); | 58 std::string user_display_name = signin.GetAuthenticatedUsername(); |
| 53 | 59 |
| 54 #if defined(OS_CHROMEOS) | 60 #if defined(OS_CHROMEOS) |
| 55 if (user_manager::UserManager::IsInitialized()) { | 61 if (user_manager::UserManager::IsInitialized()) { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 81 | 87 |
| 82 DCHECK(!user_name.empty()); | 88 DCHECK(!user_name.empty()); |
| 83 | 89 |
| 84 // Message may also carry additional advice with an HTML link, if acceptable. | 90 // Message may also carry additional advice with an HTML link, if acceptable. |
| 85 switch (style) { | 91 switch (style) { |
| 86 case PLAIN_TEXT: | 92 case PLAIN_TEXT: |
| 87 return l10n_util::GetStringFUTF16( | 93 return l10n_util::GetStringFUTF16( |
| 88 IDS_SYNC_ACCOUNT_SYNCING_TO_USER, | 94 IDS_SYNC_ACCOUNT_SYNCING_TO_USER, |
| 89 user_name); | 95 user_name); |
| 90 case WITH_HTML: | 96 case WITH_HTML: |
| 97 if (IsChromeAwayFromChromeEnabled()) { | |
| 98 return l10n_util::GetStringFUTF16( | |
| 99 IDS_SYNC_ACCOUNT_SYNCING_TO_USER_WITH_MANAGE_LINK_NEW, | |
| 100 user_name, | |
| 101 base::ASCIIToUTF16(chrome::kSyncChromeDashboardURL)); | |
| 102 } | |
| 91 return l10n_util::GetStringFUTF16( | 103 return l10n_util::GetStringFUTF16( |
| 92 IDS_SYNC_ACCOUNT_SYNCING_TO_USER_WITH_MANAGE_LINK, | 104 IDS_SYNC_ACCOUNT_SYNCING_TO_USER_WITH_MANAGE_LINK, |
| 93 user_name, | 105 user_name, |
| 94 base::ASCIIToUTF16(chrome::kSyncGoogleDashboardURL)); | 106 base::ASCIIToUTF16(chrome::kSyncGoogleDashboardURL)); |
| 95 default: | 107 default: |
| 96 NOTREACHED(); | 108 NOTREACHED(); |
| 97 return NULL; | 109 return NULL; |
| 98 } | 110 } |
| 99 } | 111 } |
| 100 | 112 |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 base::string16 ConstructTime(int64 time_in_int) { | 388 base::string16 ConstructTime(int64 time_in_int) { |
| 377 base::Time time = base::Time::FromInternalValue(time_in_int); | 389 base::Time time = base::Time::FromInternalValue(time_in_int); |
| 378 | 390 |
| 379 // If time is null the format function returns a time in 1969. | 391 // If time is null the format function returns a time in 1969. |
| 380 if (time.is_null()) | 392 if (time.is_null()) |
| 381 return base::string16(); | 393 return base::string16(); |
| 382 return base::TimeFormatFriendlyDateAndTime(time); | 394 return base::TimeFormatFriendlyDateAndTime(time); |
| 383 } | 395 } |
| 384 | 396 |
| 385 } // namespace sync_ui_util | 397 } // namespace sync_ui_util |
| OLD | NEW |