summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authortim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-15 21:52:28 +0000
committertim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-15 21:52:28 +0000
commitd742d2f41fd7035ef040a1b76bd5bcd93ae9b0ac (patch)
tree1593105e3c5b59d87bcedbb465eb9d67500f3fdd /chrome/browser/views
parent53556e1b386f14de94d97351e47774b97c0ed753 (diff)
downloadchromium_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/views')
-rw-r--r--chrome/browser/views/confirm_message_box_dialog.cc37
-rw-r--r--chrome/browser/views/confirm_message_box_dialog.h35
-rw-r--r--chrome/browser/views/options/content_page_view.cc19
-rw-r--r--chrome/browser/views/options/content_page_view.h7
-rw-r--r--chrome/browser/views/sync/sync_setup_flow.cc33
-rw-r--r--chrome/browser/views/sync/sync_setup_flow.h3
-rw-r--r--chrome/browser/views/sync/sync_setup_wizard.cc31
-rw-r--r--chrome/browser/views/sync/sync_setup_wizard.h16
-rw-r--r--chrome/browser/views/sync/sync_setup_wizard_unittest.cc22
-rw-r--r--chrome/browser/views/toolbar_view.cc17
10 files changed, 186 insertions, 34 deletions
diff --git a/chrome/browser/views/confirm_message_box_dialog.cc b/chrome/browser/views/confirm_message_box_dialog.cc
index fe66582..6182bd8 100644
--- a/chrome/browser/views/confirm_message_box_dialog.cc
+++ b/chrome/browser/views/confirm_message_box_dialog.cc
@@ -25,11 +25,38 @@ void ConfirmMessageBoxDialog::Run(gfx::NativeWindow parent,
window->Show();
}
+// static
+void ConfirmMessageBoxDialog::RunWithCustomConfiguration(
+ gfx::NativeWindow parent,
+ ConfirmMessageBoxObserver* observer,
+ const std::wstring& message_text,
+ const std::wstring& window_title,
+ const std::wstring& confirm_label,
+ const std::wstring& reject_label,
+ const gfx::Size& preferred_size) {
+ DCHECK(observer);
+ ConfirmMessageBoxDialog* dialog = new ConfirmMessageBoxDialog(observer,
+ message_text, window_title);
+ dialog->preferred_size_ = preferred_size;
+ dialog->confirm_label_ = confirm_label;
+ dialog->reject_label_ = reject_label;
+ views::Window* window = views::Window::CreateChromeWindow(
+ parent, gfx::Rect(), dialog);
+ window->Show();
+}
+
ConfirmMessageBoxDialog::ConfirmMessageBoxDialog(
ConfirmMessageBoxObserver* observer, const std::wstring& message_text,
const std::wstring& window_title)
: observer_(observer),
- window_title_(window_title) {
+ window_title_(window_title),
+ preferred_size_(gfx::Size(views::Window::GetLocalizedContentsSize(
+ IDS_CONFIRM_MESSAGE_BOX_DEFAULT_WIDTH_CHARS,
+ IDS_CONFIRM_MESSAGE_BOX_DEFAULT_HEIGHT_LINES))),
+ confirm_label_(l10n_util::GetString(
+ IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL)),
+ reject_label_(l10n_util::GetString(
+ IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL)) {
message_label_ = new views::Label(message_text);
message_label_->SetMultiLine(true);
l10n_util::TextDirection direction =
@@ -59,10 +86,10 @@ std::wstring ConfirmMessageBoxDialog::GetWindowTitle() const {
std::wstring ConfirmMessageBoxDialog::GetDialogButtonLabel(
MessageBoxFlags::DialogButton button) const {
if (button == MessageBoxFlags::DIALOGBUTTON_OK) {
- return l10n_util::GetString(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL);
+ return confirm_label_;
}
if (button == MessageBoxFlags::DIALOGBUTTON_CANCEL)
- return l10n_util::GetString(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL);
+ return reject_label_;
return DialogDelegate::GetDialogButtonLabel(button);
}
@@ -84,7 +111,5 @@ void ConfirmMessageBoxDialog::Layout() {
}
gfx::Size ConfirmMessageBoxDialog::GetPreferredSize() {
- return gfx::Size(views::Window::GetLocalizedContentsSize(
- IDS_CONFIRM_MESSAGE_BOX_DEFAULT_WIDTH_CHARS,
- IDS_CONFIRM_MESSAGE_BOX_DEFAULT_HEIGHT_LINES));
+ return preferred_size_;
} \ No newline at end of file
diff --git a/chrome/browser/views/confirm_message_box_dialog.h b/chrome/browser/views/confirm_message_box_dialog.h
index b2ca806..81c0213 100644
--- a/chrome/browser/views/confirm_message_box_dialog.h
+++ b/chrome/browser/views/confirm_message_box_dialog.h
@@ -28,18 +28,28 @@ class ConfirmMessageBoxDialog : public views::DialogDelegate,
public views::View {
public:
// The method presents a modal confirmation dialog to the user with the title
- // |window_title| and message |message_text|. |observer| will be notified
- // when the user makes a decision or closes the dialog. Note that this class
- // guarantees it will call one of the observer's methods, so it is the
- // caller's responsibility to ensure |observer| lives until one of the
- // methods is invoked; it can be deleted thereafter from this class' point
- // of view. |parent| specifies where to insert the view into the hierarchy
- // and effectively assumes ownership of the dialog.
+ // |window_title| and message |message_text|, and 'Yes' 'No' buttons.
+ // |observer| will be notified when the user makes a decision or closes the
+ // dialog. Note that this class guarantees it will call one of the observer's
+ // methods, so it is the caller's responsibility to ensure |observer| lives
+ // until one of the methods is invoked; it can be deleted thereafter from this
+ // class' point of view. |parent| specifies where to insert the view into the
+ // hierarchy and effectively assumes ownership of the dialog.
static void Run(gfx::NativeWindow parent,
ConfirmMessageBoxObserver* observer,
const std::wstring& message_text,
const std::wstring& window_title);
+ // A variant of the above for when the message text is longer/shorter than
+ // what the default size of this dialog can accommodate.
+ static void RunWithCustomConfiguration(gfx::NativeWindow parent,
+ ConfirmMessageBoxObserver* observer,
+ const std::wstring& message_text,
+ const std::wstring& window_title,
+ const std::wstring& confirm_label,
+ const std::wstring& reject_label,
+ const gfx::Size& preferred_size);
+
virtual ~ConfirmMessageBoxDialog() {}
// views::DialogDelegate implementation.
@@ -47,6 +57,10 @@ class ConfirmMessageBoxDialog : public views::DialogDelegate,
virtual std::wstring GetWindowTitle() const;
virtual std::wstring GetDialogButtonLabel(
MessageBoxFlags::DialogButton button) const;
+ virtual int GetDefaultDialogButton() const {
+ return MessageBoxFlags::DIALOGBUTTON_CANCEL;
+ }
+
virtual bool Accept();
virtual bool Cancel();
@@ -69,6 +83,13 @@ class ConfirmMessageBoxDialog : public views::DialogDelegate,
// This is the Title bar text.
std::wstring window_title_;
+ // The text for the 'OK' and 'CANCEL' buttons.
+ std::wstring confirm_label_;
+ std::wstring reject_label_;
+
+ // The preferred size of the dialog.
+ gfx::Size preferred_size_;
+
// The observer to notify of acceptance or cancellation.
ConfirmMessageBoxObserver* observer_;
diff --git a/chrome/browser/views/options/content_page_view.cc b/chrome/browser/views/options/content_page_view.cc
index 2f8efb0..a3df28c 100644
--- a/chrome/browser/views/options/content_page_view.cc
+++ b/chrome/browser/views/options/content_page_view.cc
@@ -128,9 +128,19 @@ void ContentPageView::ButtonPressed(
#ifdef CHROME_PERSONALIZATION
} else if (sender == sync_start_stop_button_) {
DCHECK(sync_service_);
+
if (sync_service_->HasSyncSetupCompleted()) {
- sync_service_->DisableForUser();
- ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS);
+ ConfirmMessageBoxDialog::RunWithCustomConfiguration(
+ GetWindow()->GetNativeWindow(),
+ this,
+ l10n_util::GetString(IDS_SYNC_STOP_SYNCING_EXPLANATION_LABEL),
+ l10n_util::GetString(IDS_SYNC_STOP_SYNCING_BUTTON_LABEL),
+ l10n_util::GetString(IDS_SYNC_STOP_SYNCING_CONFIRM_BUTTON_LABEL),
+ l10n_util::GetString(IDS_CANCEL),
+ gfx::Size(views::Window::GetLocalizedContentsSize(
+ IDS_CONFIRM_STOP_SYNCING_DIALOG_WIDTH_CHARS,
+ IDS_CONFIRM_STOP_SYNCING_DIALOG_HEIGHT_LINES)));
+ return;
} else {
sync_service_->EnableForUser();
ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_OPTIONS);
@@ -422,6 +432,11 @@ void ContentPageView::InitBrowsingDataGroup() {
L"", true);
}
+void ContentPageView::OnConfirmMessageAccept() {
+ sync_service_->DisableForUser();
+ ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS);
+}
+
#ifdef CHROME_PERSONALIZATION
void ContentPageView::InitSyncGroup() {
sync_status_label_ = new views::Label;
diff --git a/chrome/browser/views/options/content_page_view.h b/chrome/browser/views/options/content_page_view.h
index 62133c0..e3902c4 100644
--- a/chrome/browser/views/options/content_page_view.h
+++ b/chrome/browser/views/options/content_page_view.h
@@ -7,6 +7,7 @@
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/views/options/options_page_view.h"
+#include "chrome/browser/views/confirm_message_box_dialog.h"
#include "chrome/common/pref_member.h"
#include "views/controls/button/button.h"
#include "views/controls/link.h"
@@ -30,7 +31,8 @@ class ContentPageView : public OptionsPageView,
public views::LinkController,
public ProfileSyncServiceObserver,
#endif
- public views::ButtonListener {
+ public views::ButtonListener,
+ public ConfirmMessageBoxObserver {
public:
explicit ContentPageView(Profile* profile);
virtual ~ContentPageView();
@@ -41,6 +43,9 @@ class ContentPageView : public OptionsPageView,
// views::LinkController method.
virtual void LinkActivated(views::Link* source, int event_flags);
+ // ConfirmMessageBoxObserver implementation.
+ virtual void OnConfirmMessageAccept();
+
#ifdef CHROME_PERSONALIZATION
// ProfileSyncServiceObserver method.
virtual void OnStateChanged();
diff --git a/chrome/browser/views/sync/sync_setup_flow.cc b/chrome/browser/views/sync/sync_setup_flow.cc
index 7019c39..01a5728 100644
--- a/chrome/browser/views/sync/sync_setup_flow.cc
+++ b/chrome/browser/views/sync/sync_setup_flow.cc
@@ -25,6 +25,7 @@
// XPath expression for finding specific iframes.
static const wchar_t* kLoginIFrameXPath = L"//iframe[@id='login']";
static const wchar_t* kMergeIFrameXPath = L"//iframe[@id='merge']";
+static const wchar_t* kDoneIframeXPath = L"//iframe[@id='done']";
// Helper function to read the JSON string from the Value parameter.
static std::string GetJsonResponse(const Value* content) {
@@ -114,8 +115,23 @@ void FlowHandler::ShowMergeAndSync() {
dom_ui_->CallJavascriptFunction(L"showMergeAndSync");
}
-void FlowHandler::ShowMergeAndSyncDone() {
- ExecuteJavascriptInIFrame(kMergeIFrameXPath, L"showMergeAndSyncDone();");
+void FlowHandler::ShowSetupDone(const std::wstring& user) {
+ StringValue synced_to_string(WideToUTF8(l10n_util::GetStringF(
+ IDS_SYNC_NTP_SYNCED_TO, user)));
+ std::string json;
+ JSONWriter::Write(&synced_to_string, false, &json);
+ std::wstring javascript = std::wstring(L"setSyncedToUser") +
+ L"(" + UTF8ToWide(json) + L");";
+ ExecuteJavascriptInIFrame(kDoneIframeXPath, javascript);
+
+ if (dom_ui_)
+ dom_ui_->CallJavascriptFunction(L"showSetupDone", synced_to_string);
+}
+
+void FlowHandler::ShowFirstTimeDone(const std::wstring& user) {
+ ExecuteJavascriptInIFrame(kDoneIframeXPath,
+ L"setShowFirstTimeSetupSummary();");
+ ShowSetupDone(user);
}
void FlowHandler::ShowMergeAndSyncError() {
@@ -153,7 +169,8 @@ void SyncSetupFlow::GetDialogSize(gfx::Size* size) const {
void SyncSetupFlow::OnDialogClosed(const std::string& json_retval) {
DCHECK(json_retval.empty());
container_->set_flow(NULL); // Sever ties from the wizard.
- if (current_state_ == SyncSetupWizard::DONE) {
+ if (current_state_ == SyncSetupWizard::DONE ||
+ current_state_ == SyncSetupWizard::DONE_FIRST_TIME) {
service_->SetSyncSetupCompleted();
}
@@ -171,6 +188,7 @@ void SyncSetupFlow::OnDialogClosed(const std::string& json_retval) {
ProfileSyncService::SyncEvent(
ProfileSyncService::CANCEL_DURING_SIGNON_AFTER_MERGE);
break;
+ case SyncSetupWizard::DONE_FIRST_TIME:
case SyncSetupWizard::DONE:
UMA_HISTOGRAM_MEDIUM_TIMES("Sync.UserPerceivedAuthorizationTime",
base::TimeTicks::Now() - login_start_time_);
@@ -212,6 +230,7 @@ bool SyncSetupFlow::ShouldAdvance(SyncSetupWizard::State state) {
return current_state_ == SyncSetupWizard::GAIA_SUCCESS;
case SyncSetupWizard::FATAL_ERROR:
return true; // You can always hit the panic button.
+ case SyncSetupWizard::DONE_FIRST_TIME:
case SyncSetupWizard::DONE:
return current_state_ == SyncSetupWizard::MERGE_AND_SYNC ||
current_state_ == SyncSetupWizard::GAIA_SUCCESS;
@@ -244,11 +263,11 @@ void SyncSetupFlow::Advance(SyncSetupWizard::State advance_state) {
if (current_state_ == SyncSetupWizard::MERGE_AND_SYNC)
flow_handler_->ShowMergeAndSyncError();
break;
+ case SyncSetupWizard::DONE_FIRST_TIME:
+ flow_handler_->ShowFirstTimeDone(service_->GetAuthenticatedUsername());
+ break;
case SyncSetupWizard::DONE:
- if (current_state_ == SyncSetupWizard::MERGE_AND_SYNC)
- flow_handler_->ShowMergeAndSyncDone();
- else if (current_state_ == SyncSetupWizard::GAIA_SUCCESS)
- flow_handler_->ShowGaiaSuccessAndClose();
+ flow_handler_->ShowSetupDone(service_->GetAuthenticatedUsername());
break;
default:
NOTREACHED() << "Invalid advance state: " << advance_state;
diff --git a/chrome/browser/views/sync/sync_setup_flow.h b/chrome/browser/views/sync/sync_setup_flow.h
index f02b292..4bc7d60 100644
--- a/chrome/browser/views/sync/sync_setup_flow.h
+++ b/chrome/browser/views/sync/sync_setup_flow.h
@@ -170,8 +170,9 @@ class FlowHandler : public DOMMessageHandler {
void ShowGaiaSuccessAndClose();
void ShowGaiaSuccessAndSettingUp();
void ShowMergeAndSync();
- void ShowMergeAndSyncDone();
void ShowMergeAndSyncError();
+ void ShowSetupDone(const std::wstring& user);
+ void ShowFirstTimeDone(const std::wstring& user);
void set_flow(SyncSetupFlow* flow) {
flow_ = flow;
diff --git a/chrome/browser/views/sync/sync_setup_wizard.cc b/chrome/browser/views/sync/sync_setup_wizard.cc
index 5e46382..31afcea 100644
--- a/chrome/browser/views/sync/sync_setup_wizard.cc
+++ b/chrome/browser/views/sync/sync_setup_wizard.cc
@@ -80,7 +80,7 @@ void SyncResourcesSource::StartDataRequest(const std::string& path_raw,
localized_strings.SetString(L"settingup",
l10n_util::GetString(IDS_SYNC_LOGIN_SETTING_UP));
localized_strings.SetString(L"success",
- l10n_util::GetString(IDS_SYNC_LOGIN_SUCCESS));
+ l10n_util::GetString(IDS_SYNC_SUCCESS));
localized_strings.SetString(L"errorsigningin",
l10n_util::GetString(IDS_SYNC_ERROR_SIGNING_IN));
static const base::StringPiece html(ResourceBundle::GetSharedInstance()
@@ -98,8 +98,6 @@ void SyncResourcesSource::StartDataRequest(const std::string& path_raw,
l10n_util::GetString(IDS_ABORT));
localized_strings.SetString(L"closelabel",
l10n_util::GetString(IDS_CLOSE));
- localized_strings.SetString(L"alldone",
- l10n_util::GetString(IDS_SYNC_MERGE_ALL_DONE));
localized_strings.SetString(L"mergeandsyncwarning",
l10n_util::GetString(IDS_SYNC_MERGE_WARNING));
localized_strings.SetString(L"setuperror",
@@ -110,6 +108,21 @@ void SyncResourcesSource::StartDataRequest(const std::string& path_raw,
SetFontAndTextDirection(&localized_strings);
response = jstemplate_builder::GetI18nTemplateHtml(
html, &localized_strings);
+ } else if (path_raw == chrome::kSyncSetupDonePath) {
+ DictionaryValue localized_strings;
+ localized_strings.SetString(L"success",
+ l10n_util::GetString(IDS_SYNC_SUCCESS));
+ localized_strings.SetString(L"setupsummary",
+ l10n_util::GetString(IDS_SYNC_SETUP_ALL_DONE));
+ localized_strings.SetString(L"firsttimesetupsummary",
+ l10n_util::GetString(IDS_SYNC_SETUP_FIRST_TIME_ALL_DONE));
+ localized_strings.SetString(L"okay",
+ l10n_util::GetString(IDS_SYNC_SETUP_OK_BUTTON_LABEL));
+ static const base::StringPiece html(ResourceBundle::GetSharedInstance()
+ .GetRawDataResource(IDR_SYNC_SETUP_DONE_HTML));
+ SetFontAndTextDirection(&localized_strings);
+ response = jstemplate_builder::GetI18nTemplateHtml(
+ html, &localized_strings);
} else if (path_raw == chrome::kSyncSetupFlowPath) {
static const base::StringPiece html(ResourceBundle::GetSharedInstance()
.GetRawDataResource(IDR_SYNC_SETUP_FLOW_HTML));
@@ -146,7 +159,7 @@ void SyncSetupWizard::Step(State advance_state) {
flow->Advance(advance_state);
} else if (!service_->profile()->GetPrefs()->GetBoolean(
prefs::kSyncHasSetupCompleted)) {
- if (advance_state == DONE || advance_state == GAIA_SUCCESS)
+ if (IsTerminalState(advance_state))
return;
// No flow is in progress, and we have never escorted the user all the
// way through the wizard flow.
@@ -155,13 +168,21 @@ void SyncSetupWizard::Step(State advance_state) {
} else {
// No flow in in progress, but we've finished the wizard flow once before.
// This is just a discrete run.
- if (advance_state == DONE || advance_state == GAIA_SUCCESS)
+ if (IsTerminalState(advance_state))
return; // Nothing to do.
flow_container_->set_flow(SyncSetupFlow::Run(service_, flow_container_,
advance_state, GetEndStateForDiscreteRun(advance_state)));
}
}
+// static
+bool SyncSetupWizard::IsTerminalState(State advance_state) {
+ return advance_state == GAIA_SUCCESS ||
+ advance_state == DONE ||
+ advance_state == DONE_FIRST_TIME ||
+ advance_state == FATAL_ERROR;
+}
+
bool SyncSetupWizard::IsVisible() const {
return flow_container_->get_flow() != NULL;
}
diff --git a/chrome/browser/views/sync/sync_setup_wizard.h b/chrome/browser/views/sync/sync_setup_wizard.h
index f51ba64..1d36f61 100644
--- a/chrome/browser/views/sync/sync_setup_wizard.h
+++ b/chrome/browser/views/sync/sync_setup_wizard.h
@@ -19,10 +19,23 @@ class ProfileSyncService;
class SyncSetupWizard {
public:
enum State {
+ // Show the Google Account login UI.
GAIA_LOGIN = 0,
+ // A login attempt succeeded. Depending on initial conditions, this may
+ // cause a transition to DONE, or to wait for an explicit transition (via
+ // Step) to the next state.
GAIA_SUCCESS,
+ // The user needs to accept a merge and sync warning to proceed.
MERGE_AND_SYNC,
+ // The panic switch. Something went terribly wrong during setup and we
+ // can't recover.
FATAL_ERROR,
+ // A final state for when setup completes and it is possible it is the
+ // user's first time (globally speaking) as the cloud doesn't have any
+ // bookmarks. We show additional info in this case to explain setting up
+ // more computers.
+ DONE_FIRST_TIME,
+ // A catch-all done case for any setup process.
DONE
};
@@ -51,6 +64,9 @@ class SyncSetupWizard {
// the end state to pass to Run for a given |start_state|.
static State GetEndStateForDiscreteRun(State start_state);
+ // Helper to return whether |state| warrants starting a new flow.
+ static bool IsTerminalState(State state);
+
ProfileSyncService* service_;
#if defined(OS_WIN)
diff --git a/chrome/browser/views/sync/sync_setup_wizard_unittest.cc b/chrome/browser/views/sync/sync_setup_wizard_unittest.cc
index 4861649..fec7ef3 100644
--- a/chrome/browser/views/sync/sync_setup_wizard_unittest.cc
+++ b/chrome/browser/views/sync/sync_setup_wizard_unittest.cc
@@ -254,10 +254,11 @@ TEST_F(SyncSetupWizardTest, InitialStepMergeAndSync) {
EXPECT_TRUE(service_->user_accepted_merge_and_sync_);
EXPECT_FALSE(service_->user_cancelled_dialog_);
service_->ResetTestStats();
- wizard_->Step(SyncSetupWizard::DONE); // No merge and sync.
+ wizard_->Step(SyncSetupWizard::DONE_FIRST_TIME); // No merge and sync.
EXPECT_TRUE(wizard_->IsVisible());
EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled());
- EXPECT_EQ(SyncSetupWizard::DONE, test_window_->flow()->current_state_);
+ EXPECT_EQ(SyncSetupWizard::DONE_FIRST_TIME,
+ test_window_->flow()->current_state_);
}
TEST_F(SyncSetupWizardTest, DialogCancelled) {
@@ -294,12 +295,18 @@ TEST_F(SyncSetupWizardTest, InvalidTransitions) {
EXPECT_FALSE(wizard_->IsVisible());
EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled());
+ wizard_->Step(SyncSetupWizard::DONE_FIRST_TIME);
+ EXPECT_FALSE(wizard_->IsVisible());
+ EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled());
+
wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC);
EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_);
wizard_->Step(SyncSetupWizard::DONE);
EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_);
+ wizard_->Step(SyncSetupWizard::DONE_FIRST_TIME);
+ EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_);
wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC);
@@ -325,6 +332,17 @@ TEST_F(SyncSetupWizardTest, FullSuccessfulRunSetsPref) {
prefs::kSyncHasSetupCompleted));
}
+TEST_F(SyncSetupWizardTest, FirstFullSuccessfulRunSetsPref) {
+ wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
+ wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
+ wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC);
+ wizard_->Step(SyncSetupWizard::DONE_FIRST_TIME);
+ test_window_->CloseDialog();
+ EXPECT_FALSE(wizard_->IsVisible());
+ EXPECT_TRUE(service_->profile()->GetPrefs()->GetBoolean(
+ prefs::kSyncHasSetupCompleted));
+}
+
TEST_F(SyncSetupWizardTest, DiscreteRun) {
DictionaryValue dialog_args;
// For a discrete run, we need to have ran through setup once.
diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc
index 4c29e28..97b0381 100644
--- a/chrome/browser/views/toolbar_view.cc
+++ b/chrome/browser/views/toolbar_view.cc
@@ -20,14 +20,15 @@
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/browser_theme_provider.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/character_encoding.h"
#include "chrome/browser/encoding_menu_controller.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/profile.h"
+#include "chrome/browser/sync/sync_status_ui_helper.h"
#include "chrome/browser/tab_contents/navigation_controller.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
-#include "chrome/browser/browser_theme_provider.h"
#include "chrome/browser/user_data_manager.h"
#include "chrome/browser/views/bookmark_menu_button.h"
#include "chrome/browser/views/browser_actions_container.h"
@@ -1133,8 +1134,18 @@ void ToolbarView::CreateAppMenu() {
app_menu_contents_->AddSeparator();
#ifdef CHROME_PERSONALIZATION
if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableSync)) {
- app_menu_contents_->AddItem(IDC_SYNC_BOOKMARKS,
- l10n_util::GetString(IDS_SYNC_MY_BOOKMARKS_LABEL) + L"...");
+ std::wstring label;
+ std::wstring link;
+ // TODO(timsteele): Need a ui helper method to just get the type without
+ // needing labels.
+ SyncStatusUIHelper::MessageType type = SyncStatusUIHelper::GetLabels(
+ browser_->profile()->GetProfileSyncService(), &label, &link);
+ label = type == SyncStatusUIHelper::SYNCED ?
+ l10n_util::GetString(IDS_SYNC_MENU_BOOKMARKS_SYNCED_LABEL) :
+ type == SyncStatusUIHelper::SYNC_ERROR ?
+ l10n_util::GetString(IDS_SYNC_MENU_BOOKMARK_SYNC_ERROR_LABEL) :
+ l10n_util::GetString(IDS_SYNC_START_SYNC_BUTTON_LABEL);
+ app_menu_contents_->AddItem(IDC_SYNC_BOOKMARKS, label);
app_menu_contents_->AddSeparator();
}
#endif