diff options
author | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-15 21:52:28 +0000 |
---|---|---|
committer | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-15 21:52:28 +0000 |
commit | d742d2f41fd7035ef040a1b76bd5bcd93ae9b0ac (patch) | |
tree | 1593105e3c5b59d87bcedbb465eb9d67500f3fdd /chrome/browser/dom_ui | |
parent | 53556e1b386f14de94d97351e47774b97c0ed753 (diff) | |
download | chromium_src-d742d2f41fd7035ef040a1b76bd5bcd93ae9b0ac.zip chromium_src-d742d2f41fd7035ef040a1b76bd5bcd93ae9b0ac.tar.gz chromium_src-d742d2f41fd7035ef040a1b76bd5bcd93ae9b0ac.tar.bz2 |
Facelifts to sync UI
BUG=23136,24858,21596
TEST=SyncSetupWizardTest
Review URL: http://codereview.chromium.org/270081
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29197 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r-- | chrome/browser/dom_ui/new_tab_page_sync_handler.cc | 56 | ||||
-rw-r--r-- | chrome/browser/dom_ui/new_tab_page_sync_handler.h | 11 |
2 files changed, 40 insertions, 27 deletions
diff --git a/chrome/browser/dom_ui/new_tab_page_sync_handler.cc b/chrome/browser/dom_ui/new_tab_page_sync_handler.cc index 0b26492..e5239a5 100644 --- a/chrome/browser/dom_ui/new_tab_page_sync_handler.cc +++ b/chrome/browser/dom_ui/new_tab_page_sync_handler.cc @@ -80,6 +80,20 @@ NewTabPageSyncHandler::~NewTabPageSyncHandler() { sync_service_->RemoveObserver(this); } +// static +NewTabPageSyncHandler::MessageType + NewTabPageSyncHandler::FromSyncStatusMessageType( + SyncStatusUIHelper::MessageType type) { + switch (type) { + case SyncStatusUIHelper::SYNC_ERROR: + return SYNC_ERROR; + case SyncStatusUIHelper::PRE_SYNCED: + case SyncStatusUIHelper::SYNCED: + default: + return HIDE; + } +} + DOMMessageHandler* NewTabPageSyncHandler::Attach(DOMUI* dom_ui) { sync_service_ = dom_ui->GetProfile()->GetProfileSyncService(); DCHECK(sync_service_); // This shouldn't get called by an incognito NTP. @@ -100,8 +114,7 @@ void NewTabPageSyncHandler::HandleGetSyncMessage(const Value* value) { } void NewTabPageSyncHandler::HideSyncStatusSection() { - SendSyncMessageToPage(SyncStatusUIHelper::PRE_SYNCED, std::string(), - std::string()); + SendSyncMessageToPage(HIDE, std::string(), std::string()); } void NewTabPageSyncHandler::BuildAndSendSyncStatus() { @@ -116,14 +129,11 @@ void NewTabPageSyncHandler::BuildAndSendSyncStatus() { // We show the sync promotion if sync has not been enabled and the user is // logged in to Google Accounts. If the user is not signed in to GA, we // should hide the sync status section entirely. - if (!sync_service_->HasSyncSetupCompleted() && - !sync_service_->SetupInProgress()) { - if (IsGoogleGAIACookieInstalled()) { - SendSyncMessageToPage(SyncStatusUIHelper::PRE_SYNCED, + if (!sync_service_->HasSyncSetupCompleted()) { + if(!sync_service_->SetupInProgress() && IsGoogleGAIACookieInstalled()) { + SendSyncMessageToPage(PROMOTION, WideToUTF8(l10n_util::GetString(IDS_SYNC_NTP_PROMOTION_MESSAGE)), WideToUTF8(l10n_util::GetString(IDS_SYNC_NTP_START_NOW_LINK_LABEL))); - } else { - HideSyncStatusSection(); } return; } @@ -131,17 +141,15 @@ void NewTabPageSyncHandler::BuildAndSendSyncStatus() { // Once sync has been enabled, the supported "sync statuses" for the NNTP // from the user's perspective are: // - // "Synced to foo@gmail.com", when we are successfully authenticated and - // connected to a sync server. // "Sync error", when we can't authenticate or establish a connection with // the sync server (appropriate information appended to // message). - // "Authenticating", when credentials are in flight. - SyncStatusUIHelper::MessageType type(SyncStatusUIHelper::PRE_SYNCED); std::wstring status_msg; std::wstring link_text; - type = SyncStatusUIHelper::GetLabels(sync_service_, &status_msg, &link_text); - SendSyncMessageToPage(type, WideToUTF8(status_msg), WideToUTF8(link_text)); + SyncStatusUIHelper::MessageType type = + SyncStatusUIHelper::GetLabels(sync_service_, &status_msg, &link_text); + SendSyncMessageToPage(FromSyncStatusMessageType(type), + WideToUTF8(status_msg), WideToUTF8(link_text)); } void NewTabPageSyncHandler::HandleSyncLinkClicked(const Value* value) { @@ -165,7 +173,7 @@ void NewTabPageSyncHandler::OnStateChanged() { } void NewTabPageSyncHandler::SendSyncMessageToPage( - SyncStatusUIHelper::MessageType type, std::string msg, + MessageType type, std::string msg, std::string linktext) { DictionaryValue value; std::string msgtype; @@ -174,28 +182,24 @@ void NewTabPageSyncHandler::SendSyncMessageToPage( WideToUTF8(l10n_util::GetString(IDS_SYNC_NTP_SYNC_SECTION_TITLE)); std::string linkurl; switch (type) { - case SyncStatusUIHelper::PRE_SYNCED: + case HIDE: + case PROMOTION: msgtype = "presynced"; break; - case SyncStatusUIHelper::SYNCED: - msgtype = "synced"; - linktext = - WideToUTF8(l10n_util::GetString(IDS_SYNC_NTP_VIEW_ONLINE_LINK)); - linkurl = kSyncDefaultViewOnlineUrl; - user = UTF16ToWide(sync_service_->GetAuthenticatedUsername()); - msg = WideToUTF8(l10n_util::GetStringF(IDS_SYNC_NTP_SYNCED_TO, user)); - break; - case SyncStatusUIHelper::SYNC_ERROR: + case SYNC_ERROR: title = WideToUTF8( l10n_util::GetString(IDS_SYNC_NTP_SYNC_SECTION_ERROR_TITLE)); msgtype = "error"; break; + default: + NOTREACHED(); + break; } // If there is no message to show, we should hide the sync section // altogether. - if (msg.empty()) { + if (type == HIDE || msg.empty()) { value.SetBoolean(L"syncsectionisvisible", false); } else { value.SetBoolean(L"syncsectionisvisible", true); diff --git a/chrome/browser/dom_ui/new_tab_page_sync_handler.h b/chrome/browser/dom_ui/new_tab_page_sync_handler.h index 5931684..9774640 100644 --- a/chrome/browser/dom_ui/new_tab_page_sync_handler.h +++ b/chrome/browser/dom_ui/new_tab_page_sync_handler.h @@ -36,8 +36,13 @@ class NewTabPageSyncHandler : public DOMMessageHandler, virtual void OnStateChanged(); private: + enum MessageType { + HIDE, + PROMOTION, + SYNC_ERROR, + }; // Helper to invoke the |syncMessageChanged| JS function on the new tab page. - void SendSyncMessageToPage(SyncStatusUIHelper::MessageType type, + void SendSyncMessageToPage(MessageType type, std::string msg, std::string linktext); // Helper to query the sync service and figure out what to send to @@ -48,6 +53,10 @@ class NewTabPageSyncHandler : public DOMMessageHandler, // Helper to send a message to the NNTP which hides the sync section. void HideSyncStatusSection(); + // Helper to convert from a sync status message type to an NTP specific one. + static MessageType FromSyncStatusMessageType( + SyncStatusUIHelper::MessageType type); + // Cached pointer to ProfileSyncService. ProfileSyncService* sync_service_; |