OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/i18n/number_formatting.h" | 9 #include "base/i18n/number_formatting.h" |
10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 DCHECK_EQ(auth_error.state(), AuthError::NONE); | 100 DCHECK_EQ(auth_error.state(), AuthError::NONE); |
101 } else if (service->UIShouldDepictAuthInProgress()) { | 101 } else if (service->UIShouldDepictAuthInProgress()) { |
102 if (status_label) { | 102 if (status_label) { |
103 status_label->assign( | 103 status_label->assign( |
104 l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL)); | 104 l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL)); |
105 } | 105 } |
106 result_type = PRE_SYNCED; | 106 result_type = PRE_SYNCED; |
107 } else if (service->observed_passphrase_required()) { | 107 } else if (service->observed_passphrase_required()) { |
108 if (service->passphrase_required_for_decryption()) { | 108 if (service->passphrase_required_for_decryption()) { |
109 // NOT first machine. | 109 // NOT first machine. |
110 // Show a link and present as an error ("needs attention"). | 110 // Show a link and present as an error ("needs attention"), |
| 111 // but still indicate the current synced status. |
111 if (status_label && link_label) { | 112 if (status_label && link_label) { |
112 status_label->assign(string16()); | 113 status_label->assign(GetSyncedStateStatusLabel(service)); |
113 link_label->assign( | 114 link_label->assign( |
114 l10n_util::GetStringUTF16(IDS_SYNC_CONFIGURE_ENCRYPTION)); | 115 l10n_util::GetStringUTF16(IDS_SYNC_PASSWORD_SYNC_ATTENTION)); |
115 } | 116 } |
116 result_type = SYNC_ERROR; | 117 result_type = SYNC_ERROR; |
117 } else { | 118 } else { |
118 // First machine. Show as a promotion. | 119 // First machine. Show as a promotion. |
119 if (status_label && link_label) { | 120 if (status_label && link_label) { |
120 status_label->assign( | 121 status_label->assign(GetSyncedStateStatusLabel(service)); |
121 l10n_util::GetStringFUTF16(IDS_SYNC_NTP_PASSWORD_PROMO, | |
122 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | |
123 link_label->assign( | 122 link_label->assign( |
124 l10n_util::GetStringUTF16(IDS_SYNC_NTP_PASSWORD_ENABLE)); | 123 l10n_util::GetStringUTF16(IDS_SYNC_NEW_PASSWORD_SYNC)); |
125 } | 124 } |
126 result_type = SYNC_PROMO; | 125 result_type = SYNC_PROMO; |
127 } | 126 } |
128 } else if (auth_error.state() != AuthError::NONE) { | 127 } else if (auth_error.state() != AuthError::NONE) { |
129 if (status_label && link_label) { | 128 if (status_label && link_label) { |
130 GetStatusLabelsForAuthError(auth_error, service, | 129 GetStatusLabelsForAuthError(auth_error, service, |
131 status_label, link_label); | 130 status_label, link_label); |
132 } | 131 } |
133 result_type = SYNC_ERROR; | 132 result_type = SYNC_ERROR; |
134 } | 133 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 if (status_label) { | 168 if (status_label) { |
170 status_label->assign( | 169 status_label->assign( |
171 l10n_util::GetStringFUTF16(IDS_SYNC_NOT_SET_UP_INFO, | 170 l10n_util::GetStringFUTF16(IDS_SYNC_NOT_SET_UP_INFO, |
172 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 171 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
173 } | 172 } |
174 } | 173 } |
175 } | 174 } |
176 return result_type; | 175 return result_type; |
177 } | 176 } |
178 | 177 |
| 178 // Returns the status info for use on the new tab page, where we want slightly |
| 179 // different information than in the settings panel. |
| 180 MessageType GetStatusInfoForNewTabPage(ProfileSyncService* service, |
| 181 string16* status_label, |
| 182 string16* link_label) { |
| 183 DCHECK(status_label); |
| 184 DCHECK(link_label); |
| 185 |
| 186 if (service->HasSyncSetupCompleted() && |
| 187 service->observed_passphrase_required()) { |
| 188 if (!service->passphrase_required_for_decryption()) { |
| 189 // First machine migrating to passwords. Show as a promotion. |
| 190 if (status_label && link_label) { |
| 191 status_label->assign( |
| 192 l10n_util::GetStringFUTF16( |
| 193 IDS_SYNC_NTP_PASSWORD_PROMO, |
| 194 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
| 195 link_label->assign( |
| 196 l10n_util::GetStringUTF16(IDS_SYNC_NTP_PASSWORD_ENABLE)); |
| 197 } |
| 198 return SYNC_PROMO; |
| 199 } else { |
| 200 // NOT first machine. |
| 201 // Show a link and present as an error ("needs attention"). |
| 202 if (status_label && link_label) { |
| 203 status_label->assign(string16()); |
| 204 link_label->assign( |
| 205 l10n_util::GetStringUTF16(IDS_SYNC_CONFIGURE_ENCRYPTION)); |
| 206 } |
| 207 return SYNC_ERROR; |
| 208 } |
| 209 } |
| 210 |
| 211 // Fallback to default. |
| 212 return GetStatusInfo(service, status_label, link_label); |
| 213 } |
| 214 |
179 } // namespace | 215 } // namespace |
180 | 216 |
181 // Returns an HTML chunk for a login prompt related to encryption. | 217 // Returns an HTML chunk for a login prompt related to encryption. |
182 string16 GetLoginMessageForEncryption() { | 218 string16 GetLoginMessageForEncryption() { |
183 std::vector<std::string> subst; | 219 std::vector<std::string> subst; |
184 const base::StringPiece html( | 220 const base::StringPiece html( |
185 ResourceBundle::GetSharedInstance().GetRawDataResource( | 221 ResourceBundle::GetSharedInstance().GetRawDataResource( |
186 IDR_SYNC_ENCRYPTION_LOGIN_HTML)); | 222 IDR_SYNC_ENCRYPTION_LOGIN_HTML)); |
187 subst.push_back(l10n_util::GetStringUTF8(IDS_SYNC_PLEASE_SIGN_IN)); | 223 subst.push_back(l10n_util::GetStringUTF8(IDS_SYNC_PLEASE_SIGN_IN)); |
188 subst.push_back( | 224 subst.push_back( |
189 l10n_util::GetStringFUTF8(IDS_SYNC_LOGIN_FOR_ENCRYPTION, | 225 l10n_util::GetStringFUTF8(IDS_SYNC_LOGIN_FOR_ENCRYPTION, |
190 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 226 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
191 | 227 |
192 return UTF8ToUTF16(ReplaceStringPlaceholders(html, subst, NULL)); | 228 return UTF8ToUTF16(ReplaceStringPlaceholders(html, subst, NULL)); |
193 } | 229 } |
194 | 230 |
195 MessageType GetStatusLabels(ProfileSyncService* service, | 231 MessageType GetStatusLabels(ProfileSyncService* service, |
196 string16* status_label, | 232 string16* status_label, |
197 string16* link_label) { | 233 string16* link_label) { |
198 DCHECK(status_label); | 234 DCHECK(status_label); |
199 DCHECK(link_label); | 235 DCHECK(link_label); |
200 return sync_ui_util::GetStatusInfo(service, status_label, link_label); | 236 return sync_ui_util::GetStatusInfo(service, status_label, link_label); |
201 } | 237 } |
202 | 238 |
| 239 MessageType GetStatusLabelsForNewTabPage(ProfileSyncService* service, |
| 240 string16* status_label, |
| 241 string16* link_label) { |
| 242 DCHECK(status_label); |
| 243 DCHECK(link_label); |
| 244 return sync_ui_util::GetStatusInfoForNewTabPage( |
| 245 service, status_label, link_label); |
| 246 } |
| 247 |
203 MessageType GetStatus(ProfileSyncService* service) { | 248 MessageType GetStatus(ProfileSyncService* service) { |
204 return sync_ui_util::GetStatusInfo(service, NULL, NULL); | 249 return sync_ui_util::GetStatusInfo(service, NULL, NULL); |
205 } | 250 } |
206 | 251 |
207 bool ShouldShowSyncErrorButton(ProfileSyncService* service) { | 252 bool ShouldShowSyncErrorButton(ProfileSyncService* service) { |
208 return service && !service->IsManaged() && service->HasSyncSetupCompleted() && | 253 return service && !service->IsManaged() && service->HasSyncSetupCompleted() && |
209 (GetStatus(service) == sync_ui_util::SYNC_ERROR); | 254 (GetStatus(service) == sync_ui_util::SYNC_ERROR); |
210 } | 255 } |
211 | 256 |
212 string16 GetSyncMenuLabel(ProfileSyncService* service) { | 257 string16 GetSyncMenuLabel(ProfileSyncService* service) { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 | 441 |
397 DictionaryValue* val = new DictionaryValue; | 442 DictionaryValue* val = new DictionaryValue; |
398 val->SetString("stat_name", "Autofill Migration Time"); | 443 val->SetString("stat_name", "Autofill Migration Time"); |
399 val->SetString("stat_value", ConstructTime(info.autofill_migration_time)); | 444 val->SetString("stat_value", ConstructTime(info.autofill_migration_time)); |
400 details->Append(val); | 445 details->Append(val); |
401 } | 446 } |
402 } | 447 } |
403 } | 448 } |
404 | 449 |
405 } // namespace sync_ui_util | 450 } // namespace sync_ui_util |
OLD | NEW |