summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/sync
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/views/sync')
-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
5 files changed, 90 insertions, 15 deletions
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.