Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: chrome/browser/sync/sync_status_ui_helper.cc

Issue 338008: Resubmit http://codereview.chromium.org/314016 with views fixed (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync/sync_status_ui_helper.h ('k') | chrome/browser/views/bookmark_bar_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #if defined(BROWSER_SYNC) 5 #if defined(BROWSER_SYNC)
6 6
7 #include "chrome/browser/sync/sync_status_ui_helper.h" 7 #include "chrome/browser/sync/sync_status_ui_helper.h"
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "chrome/browser/sync/auth_error_state.h" 11 #include "chrome/browser/sync/auth_error_state.h"
12 #include "chrome/browser/sync/profile_sync_service.h" 12 #include "chrome/browser/sync/profile_sync_service.h"
13 #include "grit/chromium_strings.h" 13 #include "grit/chromium_strings.h"
14 #include "grit/generated_resources.h" 14 #include "grit/generated_resources.h"
15 15
16 // Given an authentication state, this helper function returns the appropriate 16 // Given an authentication state, this helper function returns the appropriate
17 // status message and, if necessary, the text that should appear in the 17 // status message and, if necessary, the text that should appear in the
18 // re-login link. 18 // re-login link.
19 static void GetLabelsForAuthError(AuthErrorState auth_error, 19 static void GetLabelsForAuthError(AuthErrorState auth_error,
20 ProfileSyncService* service, std::wstring* status_label, 20 ProfileSyncService* service, string16* status_label,
21 std::wstring* link_label) { 21 string16* link_label) {
22 if (link_label) 22 if (link_label)
23 link_label->assign(l10n_util::GetString(IDS_SYNC_RELOGIN_LINK_LABEL)); 23 link_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_RELOGIN_LINK_LABEL));
24 if (auth_error == AUTH_ERROR_INVALID_GAIA_CREDENTIALS) { 24 if (auth_error == AUTH_ERROR_INVALID_GAIA_CREDENTIALS) {
25 // If the user name is empty then the first login failed, otherwise the 25 // If the user name is empty then the first login failed, otherwise the
26 // credentials are out-of-date. 26 // credentials are out-of-date.
27 if (service->GetAuthenticatedUsername().empty()) 27 if (service->GetAuthenticatedUsername().empty())
28 status_label->assign( 28 status_label->assign(
29 l10n_util::GetString(IDS_SYNC_INVALID_USER_CREDENTIALS)); 29 l10n_util::GetStringUTF16(IDS_SYNC_INVALID_USER_CREDENTIALS));
30 else 30 else
31 status_label->assign( 31 status_label->assign(
32 l10n_util::GetString(IDS_SYNC_LOGIN_INFO_OUT_OF_DATE)); 32 l10n_util::GetStringUTF16(IDS_SYNC_LOGIN_INFO_OUT_OF_DATE));
33 } else if (auth_error == AUTH_ERROR_CONNECTION_FAILED) { 33 } else if (auth_error == AUTH_ERROR_CONNECTION_FAILED) {
34 // Note that there is little the user can do if the server is not 34 // Note that there is little the user can do if the server is not
35 // reachable. Since attempting to re-connect is done automatically by 35 // reachable. Since attempting to re-connect is done automatically by
36 // the Syncer, we do not show the (re)login link. 36 // the Syncer, we do not show the (re)login link.
37 status_label->assign( 37 status_label->assign(
38 l10n_util::GetStringF(IDS_SYNC_SERVER_IS_UNREACHABLE, 38 l10n_util::GetStringFUTF16(IDS_SYNC_SERVER_IS_UNREACHABLE,
39 l10n_util::GetString(IDS_PRODUCT_NAME))); 39 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
40 if (link_label) 40 if (link_label)
41 link_label->clear(); 41 link_label->clear();
42 } else { 42 } else {
43 status_label->assign(l10n_util::GetString(IDS_SYNC_ERROR_SIGNING_IN)); 43 status_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_ERROR_SIGNING_IN));
44 } 44 }
45 } 45 }
46 46
47 // Returns the message that should be displayed when the user is authenticated 47 // Returns the message that should be displayed when the user is authenticated
48 // and can connect to the sync server. If the user hasn't yet authenticated, an 48 // and can connect to the sync server. If the user hasn't yet authenticated, an
49 // empty string is returned. 49 // empty string is returned.
50 static std::wstring GetSyncedStateStatusLabel(ProfileSyncService* service) { 50 static string16 GetSyncedStateStatusLabel(ProfileSyncService* service) {
51 std::wstring label; 51 string16 label;
52 std::wstring user_name(UTF16ToWide(service->GetAuthenticatedUsername())); 52 string16 user_name(service->GetAuthenticatedUsername());
53 if (user_name.empty()) 53 if (user_name.empty())
54 return label; 54 return label;
55 55
56 return l10n_util::GetStringF(IDS_SYNC_ACCOUNT_SYNCED_TO_USER_WITH_TIME, 56 return l10n_util::GetStringFUTF16(
57 user_name, service->GetLastSyncedTimeString()); 57 IDS_SYNC_ACCOUNT_SYNCED_TO_USER_WITH_TIME,
58 user_name,
59 WideToUTF16(service->GetLastSyncedTimeString()));
58 } 60 }
59 61
60 // static 62 // static
61 SyncStatusUIHelper::MessageType SyncStatusUIHelper::GetLabels( 63 SyncStatusUIHelper::MessageType SyncStatusUIHelper::GetLabels(
62 ProfileSyncService* service, std::wstring* status_label, 64 ProfileSyncService* service, string16* status_label,
63 std::wstring* link_label) { 65 string16* link_label) {
64 MessageType result_type(SYNCED); 66 MessageType result_type(SYNCED);
65 67
66 if (!service) { 68 if (!service) {
67 return PRE_SYNCED; 69 return PRE_SYNCED;
68 } 70 }
69 71
70 if (service->HasSyncSetupCompleted()) { 72 if (service->HasSyncSetupCompleted()) {
71 ProfileSyncService::Status status(service->QueryDetailedSyncStatus()); 73 ProfileSyncService::Status status(service->QueryDetailedSyncStatus());
72 AuthErrorState auth_error(service->GetAuthErrorState()); 74 AuthErrorState auth_error(service->GetAuthErrorState());
73 75
74 // Either show auth error information with a link to re-login, auth in prog, 76 // Either show auth error information with a link to re-login, auth in prog,
75 // or note that everything is OK with the last synced time. 77 // or note that everything is OK with the last synced time.
76 if (status.authenticated) { 78 if (status.authenticated) {
77 // Everything is peachy. 79 // Everything is peachy.
78 status_label->assign(GetSyncedStateStatusLabel(service)); 80 status_label->assign(GetSyncedStateStatusLabel(service));
79 DCHECK_EQ(auth_error, AUTH_ERROR_NONE); 81 DCHECK_EQ(auth_error, AUTH_ERROR_NONE);
80 } else if (service->UIShouldDepictAuthInProgress()) { 82 } else if (service->UIShouldDepictAuthInProgress()) {
81 status_label->assign(l10n_util::GetString(IDS_SYNC_AUTHENTICATING_LABEL)); 83 status_label->assign(
84 l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL));
82 result_type = PRE_SYNCED; 85 result_type = PRE_SYNCED;
83 } else if (auth_error != AUTH_ERROR_NONE) { 86 } else if (auth_error != AUTH_ERROR_NONE) {
84 GetLabelsForAuthError(auth_error, service, status_label, link_label); 87 GetLabelsForAuthError(auth_error, service, status_label, link_label);
85 result_type = SYNC_ERROR; 88 result_type = SYNC_ERROR;
86 } 89 }
87 } else { 90 } else {
88 // Either show auth error information with a link to re-login, auth in prog, 91 // Either show auth error information with a link to re-login, auth in prog,
89 // or provide a link to continue with setup. 92 // or provide a link to continue with setup.
90 result_type = PRE_SYNCED; 93 result_type = PRE_SYNCED;
91 if (service->SetupInProgress()) { 94 if (service->SetupInProgress()) {
92 ProfileSyncService::Status status(service->QueryDetailedSyncStatus()); 95 ProfileSyncService::Status status(service->QueryDetailedSyncStatus());
93 AuthErrorState auth_error(service->GetAuthErrorState()); 96 AuthErrorState auth_error(service->GetAuthErrorState());
94 status_label->assign( 97 status_label->assign(
95 l10n_util::GetString(IDS_SYNC_NTP_SETUP_IN_PROGRESS)); 98 l10n_util::GetStringUTF16(IDS_SYNC_NTP_SETUP_IN_PROGRESS));
96 if (service->UIShouldDepictAuthInProgress()) { 99 if (service->UIShouldDepictAuthInProgress()) {
97 status_label->assign( 100 status_label->assign(
98 l10n_util::GetString(IDS_SYNC_AUTHENTICATING_LABEL)); 101 l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL));
99 } else if (auth_error != AUTH_ERROR_NONE) { 102 } else if (auth_error != AUTH_ERROR_NONE) {
100 status_label->clear(); 103 status_label->clear();
101 GetLabelsForAuthError(auth_error, service, status_label, NULL); 104 GetLabelsForAuthError(auth_error, service, status_label, NULL);
102 result_type = SYNC_ERROR; 105 result_type = SYNC_ERROR;
103 } else if (!status.authenticated) { 106 } else if (!status.authenticated) {
104 status_label->assign( 107 status_label->assign(
105 l10n_util::GetString(IDS_SYNC_ACCOUNT_DETAILS_NOT_ENTERED)); 108 l10n_util::GetStringUTF16(IDS_SYNC_ACCOUNT_DETAILS_NOT_ENTERED));
106 } 109 }
107 } else if (service->unrecoverable_error_detected()) { 110 } else if (service->unrecoverable_error_detected()) {
108 result_type = SYNC_ERROR; 111 result_type = SYNC_ERROR;
109 status_label->assign(l10n_util::GetString(IDS_SYNC_SETUP_ERROR)); 112 status_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_SETUP_ERROR));
110 } else { 113 } else {
111 status_label->assign(l10n_util::GetString(IDS_SYNC_NOT_SET_UP_INFO)); 114 status_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_NOT_SET_UP_INFO));
112 } 115 }
113 } 116 }
114 return result_type; 117 return result_type;
115 } 118 }
116 119
117 #endif // defined(BROWSER_SYNC) 120 #endif // defined(BROWSER_SYNC)
OLDNEW
« no previous file with comments | « chrome/browser/sync/sync_status_ui_helper.h ('k') | chrome/browser/views/bookmark_bar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698