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/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "components/signin/core/browser/signin_error_controller.h" | 28 #include "components/signin/core/browser/signin_error_controller.h" |
29 #include "components/signin/core/browser/signin_manager_base.h" | 29 #include "components/signin/core/browser/signin_manager_base.h" |
30 #include "google_apis/gaia/google_service_auth_error.h" | 30 #include "google_apis/gaia/google_service_auth_error.h" |
31 #include "sync/internal_api/public/base/model_type.h" | 31 #include "sync/internal_api/public/base/model_type.h" |
32 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" | 32 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" |
33 #include "sync/protocol/proto_enum_conversions.h" | 33 #include "sync/protocol/proto_enum_conversions.h" |
34 #include "sync/protocol/sync_protocol_error.h" | 34 #include "sync/protocol/sync_protocol_error.h" |
35 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
36 | 36 |
37 #if defined(OS_CHROMEOS) | 37 #if defined(OS_CHROMEOS) |
| 38 #include "components/signin/core/account_id/account_id.h" |
38 #include "components/user_manager/user_manager.h" | 39 #include "components/user_manager/user_manager.h" |
39 #endif // defined(OS_CHROMEOS) | 40 #endif // defined(OS_CHROMEOS) |
40 | 41 |
41 typedef GoogleServiceAuthError AuthError; | 42 typedef GoogleServiceAuthError AuthError; |
42 | 43 |
43 namespace sync_ui_util { | 44 namespace sync_ui_util { |
44 | 45 |
45 namespace { | 46 namespace { |
46 | 47 |
47 bool IsChromeDashboardEnabled() { | 48 bool IsChromeDashboardEnabled() { |
48 const std::string group_name = | 49 const std::string group_name = |
49 base::FieldTrialList::FindFullName("ChromeDashboard"); | 50 base::FieldTrialList::FindFullName("ChromeDashboard"); |
50 return group_name == "Enabled"; | 51 return group_name == "Enabled"; |
51 } | 52 } |
52 | 53 |
53 // Returns the message that should be displayed when the user is authenticated | 54 // Returns the message that should be displayed when the user is authenticated |
54 // and can connect to the sync server. If the user hasn't yet authenticated, an | 55 // and can connect to the sync server. If the user hasn't yet authenticated, an |
55 // empty string is returned. | 56 // empty string is returned. |
56 base::string16 GetSyncedStateStatusLabel(ProfileSyncService* service, | 57 base::string16 GetSyncedStateStatusLabel(ProfileSyncService* service, |
57 const SigninManagerBase& signin, | 58 const SigninManagerBase& signin, |
58 StatusLabelStyle style) { | 59 StatusLabelStyle style) { |
59 std::string user_display_name = signin.GetAuthenticatedAccountInfo().email; | 60 std::string user_display_name = signin.GetAuthenticatedAccountInfo().email; |
60 | 61 |
61 #if defined(OS_CHROMEOS) | 62 #if defined(OS_CHROMEOS) |
62 if (user_manager::UserManager::IsInitialized()) { | 63 if (user_manager::UserManager::IsInitialized()) { |
63 // On CrOS user email is sanitized and then passed to the signin manager. | 64 // On CrOS user email is sanitized and then passed to the signin manager. |
64 // Original email (containing dots) is stored as "display email". | 65 // Original email (containing dots) is stored as "display email". |
65 user_display_name = user_manager::UserManager::Get()->GetUserDisplayEmail( | 66 user_display_name = user_manager::UserManager::Get()->GetUserDisplayEmail( |
66 user_display_name); | 67 AccountId::FromUserEmail(user_display_name)); |
67 } | 68 } |
68 #endif // defined(OS_CHROMEOS) | 69 #endif // defined(OS_CHROMEOS) |
69 | 70 |
70 base::string16 user_name = base::UTF8ToUTF16(user_display_name); | 71 base::string16 user_name = base::UTF8ToUTF16(user_display_name); |
71 | 72 |
72 if (!user_name.empty()) { | 73 if (!user_name.empty()) { |
73 if (!service || service->IsManaged()) { | 74 if (!service || service->IsManaged()) { |
74 // User is signed in, but sync is disabled. | 75 // User is signed in, but sync is disabled. |
75 return l10n_util::GetStringFUTF16(IDS_SIGNED_IN_WITH_SYNC_DISABLED, | 76 return l10n_util::GetStringFUTF16(IDS_SIGNED_IN_WITH_SYNC_DISABLED, |
76 user_name); | 77 user_name); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 base::string16 ConstructTime(int64 time_in_int) { | 390 base::string16 ConstructTime(int64 time_in_int) { |
390 base::Time time = base::Time::FromInternalValue(time_in_int); | 391 base::Time time = base::Time::FromInternalValue(time_in_int); |
391 | 392 |
392 // If time is null the format function returns a time in 1969. | 393 // If time is null the format function returns a time in 1969. |
393 if (time.is_null()) | 394 if (time.is_null()) |
394 return base::string16(); | 395 return base::string16(); |
395 return base::TimeFormatFriendlyDateAndTime(time); | 396 return base::TimeFormatFriendlyDateAndTime(time); |
396 } | 397 } |
397 | 398 |
398 } // namespace sync_ui_util | 399 } // namespace sync_ui_util |
OLD | NEW |