OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 global_error_bubble_accept_label->assign(l10n_util::GetStringUTF16( | 124 global_error_bubble_accept_label->assign(l10n_util::GetStringUTF16( |
125 IDS_SYNC_SIGN_IN_ERROR_BUBBLE_VIEW_ACCEPT)); | 125 IDS_SYNC_SIGN_IN_ERROR_BUBBLE_VIEW_ACCEPT)); |
126 } | 126 } |
127 break; | 127 break; |
128 } | 128 } |
129 } | 129 } |
130 | 130 |
131 // Returns the message that should be displayed when the user is authenticated | 131 // Returns the message that should be displayed when the user is authenticated |
132 // and can connect to the sync server. If the user hasn't yet authenticated, an | 132 // and can connect to the sync server. If the user hasn't yet authenticated, an |
133 // empty string is returned. | 133 // empty string is returned. |
134 string16 GetSyncedStateStatusLabel(ProfileSyncService* service) { | 134 string16 GetSyncedStateStatusLabel(ProfileSyncService* service, |
135 bool html_links) { | |
135 string16 label; | 136 string16 label; |
136 string16 user_name(service->GetAuthenticatedUsername()); | 137 string16 user_name(service->GetAuthenticatedUsername()); |
137 if (user_name.empty()) | 138 if (user_name.empty()) |
138 return label; | 139 return label; |
139 | 140 |
140 return l10n_util::GetStringFUTF16( | 141 // Message may also carry additional advice with an HTML link, if acceptable. |
141 IDS_SYNC_ACCOUNT_SYNCING_TO_USER, | 142 if (html_links) |
stuartmorgan
2011/10/27 11:51:20
These are multi-line, so need to have braces.
jimblackler
2011/10/27 14:53:52
Done.
| |
142 user_name, | 143 return l10n_util::GetStringFUTF16( |
143 ASCIIToUTF16(chrome::kSyncGoogleDashboardURL)); | 144 IDS_SYNC_ACCOUNT_SYNCING_TO_USER_WITH_MANAGE_LINK, |
145 user_name, | |
146 ASCIIToUTF16(chrome::kSyncGoogleDashboardURL)); | |
147 else | |
148 return l10n_util::GetStringFUTF16( | |
149 IDS_SYNC_ACCOUNT_SYNCING_TO_USER, | |
150 user_name); | |
144 } | 151 } |
145 | 152 |
146 void GetStatusForActionableError( | 153 void GetStatusForActionableError( |
147 const browser_sync::SyncProtocolError& error, | 154 const browser_sync::SyncProtocolError& error, |
148 string16* status_label) { | 155 string16* status_label) { |
149 DCHECK(status_label); | 156 DCHECK(status_label); |
150 switch (error.action) { | 157 switch (error.action) { |
151 case browser_sync::STOP_AND_RESTART_SYNC: | 158 case browser_sync::STOP_AND_RESTART_SYNC: |
152 status_label->assign( | 159 status_label->assign( |
153 l10n_util::GetStringUTF16(IDS_SYNC_STOP_AND_RESTART_SYNC)); | 160 l10n_util::GetStringUTF16(IDS_SYNC_STOP_AND_RESTART_SYNC)); |
(...skipping 14 matching lines...) Expand all Loading... | |
168 default: | 175 default: |
169 NOTREACHED(); | 176 NOTREACHED(); |
170 } | 177 } |
171 } | 178 } |
172 | 179 |
173 // TODO(akalin): Write unit tests for these three functions below. | 180 // TODO(akalin): Write unit tests for these three functions below. |
174 | 181 |
175 // status_label and link_label must either be both NULL or both non-NULL. | 182 // status_label and link_label must either be both NULL or both non-NULL. |
176 MessageType GetStatusInfo(ProfileSyncService* service, | 183 MessageType GetStatusInfo(ProfileSyncService* service, |
177 string16* status_label, | 184 string16* status_label, |
178 string16* link_label) { | 185 string16* link_label, |
186 bool html_links) { | |
179 DCHECK_EQ(status_label == NULL, link_label == NULL); | 187 DCHECK_EQ(status_label == NULL, link_label == NULL); |
180 | 188 |
181 MessageType result_type(SYNCED); | 189 MessageType result_type(SYNCED); |
182 | 190 |
183 if (!service) { | 191 if (!service) { |
184 return PRE_SYNCED; | 192 return PRE_SYNCED; |
185 } | 193 } |
186 | 194 |
187 if (service->HasSyncSetupCompleted()) { | 195 if (service->HasSyncSetupCompleted()) { |
188 ProfileSyncService::Status status(service->QueryDetailedSyncStatus()); | 196 ProfileSyncService::Status status(service->QueryDetailedSyncStatus()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 | 237 |
230 // Now finally passphrase error. | 238 // Now finally passphrase error. |
231 if (service->IsPassphraseRequired()) { | 239 if (service->IsPassphraseRequired()) { |
232 if (service->IsPassphraseRequiredForDecryption()) { | 240 if (service->IsPassphraseRequiredForDecryption()) { |
233 // TODO(lipalani) : Ask tim if this is still needed. | 241 // TODO(lipalani) : Ask tim if this is still needed. |
234 // NOT first machine. | 242 // NOT first machine. |
235 // Show a link ("needs attention"), but still indicate the | 243 // Show a link ("needs attention"), but still indicate the |
236 // current synced status. Return SYNC_PROMO so that | 244 // current synced status. Return SYNC_PROMO so that |
237 // the configure link will still be shown. | 245 // the configure link will still be shown. |
238 if (status_label && link_label) { | 246 if (status_label && link_label) { |
239 status_label->assign(GetSyncedStateStatusLabel(service)); | 247 status_label->assign(GetSyncedStateStatusLabel(service, html_links)); |
240 link_label->assign( | 248 link_label->assign( |
241 l10n_util::GetStringUTF16(IDS_SYNC_PASSWORD_SYNC_ATTENTION)); | 249 l10n_util::GetStringUTF16(IDS_SYNC_PASSWORD_SYNC_ATTENTION)); |
242 } | 250 } |
243 return SYNC_PROMO; | 251 return SYNC_PROMO; |
244 } | 252 } |
245 } | 253 } |
246 | 254 |
247 // There is no error. Display "Last synced..." message. | 255 // There is no error. Display "Last synced..." message. |
248 if (status_label) | 256 if (status_label) |
249 status_label->assign(GetSyncedStateStatusLabel(service)); | 257 status_label->assign(GetSyncedStateStatusLabel(service, html_links)); |
250 return SYNCED; | 258 return SYNCED; |
251 } else { | 259 } else { |
252 // Either show auth error information with a link to re-login, auth in prog, | 260 // Either show auth error information with a link to re-login, auth in prog, |
253 // or provide a link to continue with setup. | 261 // or provide a link to continue with setup. |
254 result_type = PRE_SYNCED; | 262 result_type = PRE_SYNCED; |
255 if (service->SetupInProgress()) { | 263 if (service->SetupInProgress()) { |
256 ProfileSyncService::Status status(service->QueryDetailedSyncStatus()); | 264 ProfileSyncService::Status status(service->QueryDetailedSyncStatus()); |
257 const AuthError& auth_error = service->GetAuthError(); | 265 const AuthError& auth_error = service->GetAuthError(); |
258 if (status_label) { | 266 if (status_label) { |
259 status_label->assign( | 267 status_label->assign( |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 if (status_label && link_label) { | 329 if (status_label && link_label) { |
322 status_label->assign(string16()); | 330 status_label->assign(string16()); |
323 link_label->assign( | 331 link_label->assign( |
324 l10n_util::GetStringUTF16(IDS_SYNC_CONFIGURE_ENCRYPTION)); | 332 l10n_util::GetStringUTF16(IDS_SYNC_CONFIGURE_ENCRYPTION)); |
325 } | 333 } |
326 return SYNC_ERROR; | 334 return SYNC_ERROR; |
327 } | 335 } |
328 } | 336 } |
329 | 337 |
330 // Fallback to default. | 338 // Fallback to default. |
331 return GetStatusInfo(service, status_label, link_label); | 339 return GetStatusInfo(service, status_label, link_label, true); |
332 } | 340 } |
333 | 341 |
334 } // namespace | 342 } // namespace |
335 | 343 |
336 MessageType GetStatusLabels(ProfileSyncService* service, | 344 MessageType GetStatusLabels(ProfileSyncService* service, |
337 string16* status_label, | 345 string16* status_label, |
338 string16* link_label) { | 346 string16* link_label, |
347 bool html_links) { | |
339 DCHECK(status_label); | 348 DCHECK(status_label); |
340 DCHECK(link_label); | 349 DCHECK(link_label); |
341 return sync_ui_util::GetStatusInfo(service, status_label, link_label); | 350 return sync_ui_util::GetStatusInfo(service, status_label, link_label, |
351 html_links); | |
342 } | 352 } |
343 | 353 |
344 MessageType GetStatusLabelsForNewTabPage(ProfileSyncService* service, | 354 MessageType GetStatusLabelsForNewTabPage(ProfileSyncService* service, |
345 string16* status_label, | 355 string16* status_label, |
346 string16* link_label) { | 356 string16* link_label) { |
347 DCHECK(status_label); | 357 DCHECK(status_label); |
348 DCHECK(link_label); | 358 DCHECK(link_label); |
349 return sync_ui_util::GetStatusInfoForNewTabPage( | 359 return sync_ui_util::GetStatusInfoForNewTabPage( |
350 service, status_label, link_label); | 360 service, status_label, link_label); |
351 } | 361 } |
(...skipping 30 matching lines...) Expand all Loading... | |
382 return; | 392 return; |
383 | 393 |
384 const AuthError& auth_error = service->GetAuthError(); | 394 const AuthError& auth_error = service->GetAuthError(); |
385 if (auth_error.state() != AuthError::NONE) { | 395 if (auth_error.state() != AuthError::NONE) { |
386 GetStatusLabelsForAuthError(auth_error, *service, NULL, NULL, | 396 GetStatusLabelsForAuthError(auth_error, *service, NULL, NULL, |
387 menu_label, bubble_message, bubble_accept_label); | 397 menu_label, bubble_message, bubble_accept_label); |
388 } | 398 } |
389 } | 399 } |
390 | 400 |
391 MessageType GetStatus(ProfileSyncService* service) { | 401 MessageType GetStatus(ProfileSyncService* service) { |
392 return sync_ui_util::GetStatusInfo(service, NULL, NULL); | 402 return sync_ui_util::GetStatusInfo(service, NULL, NULL, true); |
393 } | 403 } |
394 | 404 |
395 bool ShouldShowSyncErrorButton(ProfileSyncService* service) { | 405 bool ShouldShowSyncErrorButton(ProfileSyncService* service) { |
396 if (!service) | 406 if (!service) |
397 return false; | 407 return false; |
398 | 408 |
399 if (service->IsManaged() || !service->HasSyncSetupCompleted()) | 409 if (service->IsManaged() || !service->HasSyncSetupCompleted()) |
400 return false; | 410 return false; |
401 | 411 |
402 // Don't display error button for unrecoverable errors; they are not | 412 // Don't display error button for unrecoverable errors; they are not |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
673 DictionaryValue* val = new DictionaryValue; | 683 DictionaryValue* val = new DictionaryValue; |
674 val->SetString("model_type", ModelTypeToString(it->first)); | 684 val->SetString("model_type", ModelTypeToString(it->first)); |
675 val->SetString("group", ModelSafeGroupToString(it->second)); | 685 val->SetString("group", ModelSafeGroupToString(it->second)); |
676 routing_info->Append(val); | 686 routing_info->Append(val); |
677 } | 687 } |
678 } | 688 } |
679 } | 689 } |
680 } | 690 } |
681 | 691 |
682 } // namespace sync_ui_util | 692 } // namespace sync_ui_util |
OLD | NEW |