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