Commit a68dfce6 authored by johnnyg@chromium.org's avatar johnnyg@chromium.org

Create a new code path to generate sync strings for the new tab page different...

Create a new code path to generate sync strings for the new tab page different from those used on the settings' page.

This will allow us to show on the settings page the current sync status as well as a message regarding passwords.

BUG=69622
TEST=see bug

Review URL: http://codereview.chromium.org/6350008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72171 0039d316-1c4b-4281-b951-d872f2087c98
parent 9e63fded
...@@ -8117,6 +8117,13 @@ Keep your key file in a safe place. You will need it to create new versions of y ...@@ -8117,6 +8117,13 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_SYNC_CONFIGURE_ENCRYPTION" desc="Link to configure sync encryption for passwords"> <message name="IDS_SYNC_CONFIGURE_ENCRYPTION" desc="Link to configure sync encryption for passwords">
Configure password sync. Configure password sync.
</message> </message>
<message name="IDS_SYNC_NEW_PASSWORD_SYNC" desc="Promotional message for password sync setup.">
New! Configure password sync.
</message>
<message name="IDS_SYNC_PASSWORD_SYNC_ATTENTION" desc="Message indicating password sync needs attention.">
Password sync needs your attention.
</message>
<message name="IDS_SYNC_PLEASE_SIGN_IN" desc="An title for a sign in dialog."> <message name="IDS_SYNC_PLEASE_SIGN_IN" desc="An title for a sign in dialog.">
Please sign in Please sign in
</message> </message>
......
...@@ -144,7 +144,9 @@ void NewTabPageSyncHandler::BuildAndSendSyncStatus() { ...@@ -144,7 +144,9 @@ void NewTabPageSyncHandler::BuildAndSendSyncStatus() {
string16 status_msg; string16 status_msg;
string16 link_text; string16 link_text;
sync_ui_util::MessageType type = sync_ui_util::MessageType type =
sync_ui_util::GetStatusLabels(sync_service_, &status_msg, &link_text); sync_ui_util::GetStatusLabelsForNewTabPage(sync_service_,
&status_msg,
&link_text);
SendSyncMessageToPage(FromSyncStatusMessageType(type), SendSyncMessageToPage(FromSyncStatusMessageType(type),
UTF16ToUTF8(status_msg), UTF16ToUTF8(link_text)); UTF16ToUTF8(status_msg), UTF16ToUTF8(link_text));
} }
......
...@@ -107,21 +107,21 @@ MessageType GetStatusInfo(ProfileSyncService* service, ...@@ -107,21 +107,21 @@ MessageType GetStatusInfo(ProfileSyncService* service,
} else if (service->observed_passphrase_required()) { } else if (service->observed_passphrase_required()) {
if (service->passphrase_required_for_decryption()) { if (service->passphrase_required_for_decryption()) {
// NOT first machine. // NOT first machine.
// Show a link and present as an error ("needs attention"). // Show a link ("needs attention"), but still indicate the
// current synced status. Return SYNC_PROMO so that
// the configure link will still be shown.
if (status_label && link_label) { if (status_label && link_label) {
status_label->assign(string16()); status_label->assign(GetSyncedStateStatusLabel(service));
link_label->assign( link_label->assign(
l10n_util::GetStringUTF16(IDS_SYNC_CONFIGURE_ENCRYPTION)); l10n_util::GetStringUTF16(IDS_SYNC_PASSWORD_SYNC_ATTENTION));
} }
result_type = SYNC_ERROR; result_type = SYNC_PROMO;
} else { } else {
// First machine. Show as a promotion. // First machine. Show as a promotion.
if (status_label && link_label) { if (status_label && link_label) {
status_label->assign( status_label->assign(GetSyncedStateStatusLabel(service));
l10n_util::GetStringFUTF16(IDS_SYNC_NTP_PASSWORD_PROMO,
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
link_label->assign( link_label->assign(
l10n_util::GetStringUTF16(IDS_SYNC_NTP_PASSWORD_ENABLE)); l10n_util::GetStringUTF16(IDS_SYNC_NEW_PASSWORD_SYNC));
} }
result_type = SYNC_PROMO; result_type = SYNC_PROMO;
} }
...@@ -176,6 +176,43 @@ MessageType GetStatusInfo(ProfileSyncService* service, ...@@ -176,6 +176,43 @@ MessageType GetStatusInfo(ProfileSyncService* service,
return result_type; return result_type;
} }
// Returns the status info for use on the new tab page, where we want slightly
// different information than in the settings panel.
MessageType GetStatusInfoForNewTabPage(ProfileSyncService* service,
string16* status_label,
string16* link_label) {
DCHECK(status_label);
DCHECK(link_label);
if (service->HasSyncSetupCompleted() &&
service->observed_passphrase_required()) {
if (!service->passphrase_required_for_decryption()) {
// First machine migrating to passwords. Show as a promotion.
if (status_label && link_label) {
status_label->assign(
l10n_util::GetStringFUTF16(
IDS_SYNC_NTP_PASSWORD_PROMO,
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
link_label->assign(
l10n_util::GetStringUTF16(IDS_SYNC_NTP_PASSWORD_ENABLE));
}
return SYNC_PROMO;
} else {
// NOT first machine.
// Show a link and present as an error ("needs attention").
if (status_label && link_label) {
status_label->assign(string16());
link_label->assign(
l10n_util::GetStringUTF16(IDS_SYNC_CONFIGURE_ENCRYPTION));
}
return SYNC_ERROR;
}
}
// Fallback to default.
return GetStatusInfo(service, status_label, link_label);
}
} // namespace } // namespace
// Returns an HTML chunk for a login prompt related to encryption. // Returns an HTML chunk for a login prompt related to encryption.
...@@ -200,6 +237,15 @@ MessageType GetStatusLabels(ProfileSyncService* service, ...@@ -200,6 +237,15 @@ MessageType GetStatusLabels(ProfileSyncService* service,
return sync_ui_util::GetStatusInfo(service, status_label, link_label); return sync_ui_util::GetStatusInfo(service, status_label, link_label);
} }
MessageType GetStatusLabelsForNewTabPage(ProfileSyncService* service,
string16* status_label,
string16* link_label) {
DCHECK(status_label);
DCHECK(link_label);
return sync_ui_util::GetStatusInfoForNewTabPage(
service, status_label, link_label);
}
MessageType GetStatus(ProfileSyncService* service) { MessageType GetStatus(ProfileSyncService* service) {
return sync_ui_util::GetStatusInfo(service, NULL, NULL); return sync_ui_util::GetStatusInfo(service, NULL, NULL);
} }
......
...@@ -39,6 +39,11 @@ MessageType GetStatusLabels(ProfileSyncService* service, ...@@ -39,6 +39,11 @@ MessageType GetStatusLabels(ProfileSyncService* service,
string16* status_label, string16* status_label,
string16* link_label); string16* link_label);
// Same as above but for use specifically on the New Tab Page.
MessageType GetStatusLabelsForNewTabPage(ProfileSyncService* service,
string16* status_label,
string16* link_label);
MessageType GetStatus(ProfileSyncService* service); MessageType GetStatus(ProfileSyncService* service);
// Determines whether or not the sync error button should be visible. // Determines whether or not the sync error button should be visible.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment