summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/generated_resources.grd110
-rw-r--r--chrome/app/resources/locale_settings.grd9
-rw-r--r--chrome/browser/browser_resources.grd1
-rw-r--r--chrome/browser/sync/glue/autofill_data_type_controller.cc27
-rw-r--r--chrome/browser/sync/glue/autofill_data_type_controller.h6
-rw-r--r--chrome/browser/sync/glue/bookmark_data_type_controller.cc16
-rw-r--r--chrome/browser/sync/glue/bookmark_data_type_controller.h3
-rw-r--r--chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc45
-rw-r--r--chrome/browser/sync/glue/data_type_controller.h12
-rw-r--r--chrome/browser/sync/glue/data_type_controller_mock.h2
-rw-r--r--chrome/browser/sync/glue/data_type_manager_impl.cc3
-rw-r--r--chrome/browser/sync/glue/data_type_manager_impl_unittest.cc20
-rw-r--r--chrome/browser/sync/glue/preference_data_type_controller.cc13
-rw-r--r--chrome/browser/sync/glue/preference_data_type_controller.h2
-rw-r--r--chrome/browser/sync/glue/preference_data_type_controller_unittest.cc32
-rw-r--r--chrome/browser/sync/glue/theme_data_type_controller.cc8
-rw-r--r--chrome/browser/sync/glue/theme_data_type_controller.h4
-rw-r--r--chrome/browser/sync/glue/theme_data_type_controller_unittest.cc32
-rw-r--r--chrome/browser/sync/glue/typed_url_data_type_controller.cc19
-rw-r--r--chrome/browser/sync/glue/typed_url_data_type_controller.h4
-rw-r--r--chrome/browser/sync/profile_sync_factory_impl_unittest.cc46
-rw-r--r--chrome/browser/sync/profile_sync_service.cc41
-rw-r--r--chrome/browser/sync/profile_sync_service.h24
-rwxr-xr-xchrome/browser/sync/resources/gaia_login.html21
-rw-r--r--chrome/browser/sync/resources/merge_and_sync.html95
-rw-r--r--chrome/browser/sync/resources/setup_flow.html25
-rw-r--r--chrome/browser/sync/sync_setup_flow.cc72
-rw-r--r--chrome/browser/sync/sync_setup_flow.h29
-rw-r--r--chrome/browser/sync/sync_setup_wizard.cc29
-rw-r--r--chrome/browser/sync/sync_setup_wizard.h2
-rw-r--r--chrome/browser/sync/sync_setup_wizard_unittest.cc48
-rw-r--r--chrome/browser/sync/sync_ui_util.cc4
-rw-r--r--chrome/browser/sync/sync_ui_util_mac.mm4
-rw-r--r--chrome/browser/sync/sync_ui_util_mac_unittest.mm4
-rw-r--r--chrome/browser/views/options/content_page_view.cc50
-rw-r--r--chrome/browser/views/options/content_page_view.h1
-rwxr-xr-xchrome/browser/views/options/customize_sync_window_view.cc231
-rwxr-xr-xchrome/browser/views/options/customize_sync_window_view.h85
-rwxr-xr-xchrome/chrome_browser.gypi2
-rw-r--r--chrome/common/pref_names.cc6
-rw-r--r--chrome/common/pref_names.h3
41 files changed, 690 insertions, 500 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 4d13069..ac326c6 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -5896,6 +5896,10 @@ Keep your key file in a safe place. You will need it to create new versions of y
desc="Title for the hard coded thumbnail that represents the Google Chrome Themes Gallery page. This is used on the NTP when there aren't enough thumbnails to show.">
Google Chrome Themes Gallery
</message>
+ <message name="IDS_NEW_TAB_SHOW_HIDE_BOOKMARK_SYNC"
+ desc="Menu item text used to show or hide the sync status.">
+ Sync
+ </message>
<message name="IDS_NEW_TAB_HOME_PAGE_SET_NOTIFICATION"
desc="Notification text to show after the user has made the NTP his/her home page.">
Welcome to your home page!
@@ -6440,12 +6444,12 @@ Keep your key file in a safe place. You will need it to create new versions of y
<!-- Sync options dialog strings -->
<if expr="not pp_ifdef('use_titlecase') or os != 'linux2'">
<message name="IDS_SYNC_OPTIONS_GROUP_NAME" desc="The name of the sync group in the options dialog.">
- Bookmark sync:
+ Sync:
</message>
</if>
<if expr="pp_ifdef('use_titlecase') and os == 'linux2'">
<message name="IDS_SYNC_OPTIONS_GROUP_NAME" desc="In Title Case and without trailing colon: The name of the sync group in the options dialog.">
- Bookmark Sync
+ Sync
</message>
</if>
<message name="IDS_SYNC_NOT_SET_UP_INFO" desc="The message that appears in the options dialog when sync has not been set up by the user.">
@@ -6453,19 +6457,19 @@ Keep your key file in a safe place. You will need it to create new versions of y
</message>
<if expr="not pp_ifdef('use_titlecase')">
<message name="IDS_SYNC_START_SYNC_BUTTON_LABEL" desc="The label that appears on the sync button in the options dialog when sync has not been set up by the user.">
- Synchronize my bookmarks...
+ Set up sync...
</message>
</if>
<if expr="pp_ifdef('use_titlecase')">
<message name="IDS_SYNC_START_SYNC_BUTTON_LABEL" desc="In Title Case. The label that appears on the sync button in the options dialog when sync has not been set up by the user.">
- Synchronize My Bookmarks...
+ Set Up Sync...
</message>
</if>
<message name="IDS_SYNC_SETUP_ERROR" desc="The message displayed when an unspecified but unrecoverable error occurs during sync setup.">
An error occurred while trying to set up sync.
</message>
<message name="IDS_SYNC_ACCOUNT_SYNCED_TO_USER_WITH_TIME" desc="The message that appears in the options dialog indicating that account is synced to a user with the given email address. The last sync also appears in the message.">
- Synced to <ph name="USER_EMAIL_ADDRESS">$1<ex>foo@gmail.com</ex></ph>\nLast synced: <ph name="LAST_SYNC_TIME">$2<ex>12 seconds ago</ex></ph>
+ Synced to <ph name="USER_EMAIL_ADDRESS">$1<ex>foo@gmail.com</ex></ph>. Last synced: <ph name="LAST_SYNC_TIME">$2<ex>12 seconds ago</ex></ph>
</message>
<message name="IDS_SYNC_ACCOUNT_DETAILS_NOT_ENTERED" desc="The sync setup is underway and the user has not yet entered credentials.">
Account login details are not yet entered.
@@ -6492,11 +6496,14 @@ Keep your key file in a safe place. You will need it to create new versions of y
Login details are out of date.
</message>
<message name="IDS_SYNC_SERVER_IS_UNREACHABLE" desc="The message to display in the New Tab Page sync section when the server is unreachable.">
- <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex> could not sync your bookmarks because it could not connect to the sync server. Retrying...</ph>
+ <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex> could not sync your data because it could not connect to the sync server. Retrying...</ph>
</message>
<message name="IDS_SYNC_RELOGIN_LINK_LABEL" desc="The text to display on in the hyperlink when the user needs to relogin to use sync.">
Login again
</message>
+ <message name="IDS_SYNC_CUSTOMIZE_BUTTON_LABEL" desc="The text to display on the button to customize which data types the user is syncing.">
+ Customize...
+ </message>
<message name="IDS_SYNC_STOP_SYNCING_BUTTON_LABEL" desc="The text to display on the button to indicate stop syncing functionality.">
Stop syncing this account
</message>
@@ -6504,7 +6511,7 @@ Keep your key file in a safe place. You will need it to create new versions of y
Stop syncing
</message>
<message name="IDS_SYNC_STOP_SYNCING_EXPLANATION_LABEL" desc="The text to display below the 'Stop syncing this account' button on the options pane, explaining what the button does.">
- If you disable sync, your bookmarks will no longer be kept in sync with those stored in your Google Account or on your other machines. No bookmarks will be deleted. All existing bookmarks will remain on this computer and in your Google Account.
+ If you disable sync, your <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> data will no longer be kept in sync with data stored in your Google Account or on your other machines. No data will be deleted. All existing data will remain on this computer and in your Google Account.
</message>
<!-- Sync time strings -->
<message name="IDS_SYNC_TIME_NEVER" desc="Indicates that the first sync has never completed.">
@@ -6516,27 +6523,27 @@ Keep your key file in a safe place. You will need it to create new versions of y
<!-- Sync / Extension interaction messages -->
<message name="IDS_SYNC_EXTENSIONS_MALFUNCTION_ROADBLOCK" desc="A message shown on a dialog presented to the user when an extension is causing many changes to bookmarks and sync is malfunctioning">
- Bookmark Sync is malfunctioning because too many requests are being sent to the server. <ph name="NAME_OF_EXTENSION">$1<ex>foo extension</ex></ph> seems to be making too many changes to your bookmarks.
+ Sync is malfunctioning because too many requests are being sent to the server. <ph name="NAME_OF_EXTENSION">$1<ex>foo extension</ex></ph> seems to be making too many changes to your bookmarks.
</message>
<message name="IDS_SYNC_EXTENSIONS_MALFUNCTION_DISABLE_EXTENSION_OPTION" desc="The label of a button allowing the user to choose to disable an extension believed to be causing sync problems preventing bookmark sync operation.">
Disable <ph name="NAME_OF_EXTENSION">$1<ex>foo extension</ex></ph>
</message>
- <message name="IDS_SYNC_EXTENSIONS_MALFUNCTION_DISABLE_SYNC_OPTION" desc="The label of a button allowing the user to choose to disable bookmark sync when an extension is believed to be causing sync problems preventing bookmark sync operation.">
- Disable Bookmark Sync
+ <message name="IDS_SYNC_EXTENSIONS_MALFUNCTION_DISABLE_SYNC_OPTION" desc="The label of a button allowing the user to choose to disable sync when an extension is believed to be causing sync problems preventing sync operation.">
+ Disable Sync
</message>
<message name="IDS_SYNC_EXTENSIONS_MALFUNCTION_EXTENSION_DISABLED" desc="A message shown on a dialog when an extension has been disabled due to problems arising from interactions with sync.">
- <ph name="NAME_OF_EXTENSION">$1<ex>foo extension</ex></ph> has been disabled. If you turn off Bookmark Sync, you can re-enable this extension on the extensions page, accessible through the Tools menu.
+ <ph name="NAME_OF_EXTENSION">$1<ex>foo extension</ex></ph> has been disabled. If you stop syncing your bookmarks, you can re-enable this extension on the extensions page, accessible through the Tools menu.
</message>
<message name="IDS_SYNC_EXTENSIONS_MALFUNCTION_SYNC_DISABLED" desc="A message shown on a dialog when bookmark sync has been disabled due to problems arising from interactions with sync.">
- Bookmark Sync has been disabled on this computer. If you uninstall <ph name="NAME_OF_EXTENSION">$1<ex>foo extension</ex></ph> you can re-enable Bookmark Sync by choosing "Synchronize my bookmarks..." in the Tools menu.
+ Bookmark sync has been disabled on this computer. If you uninstall <ph name="NAME_OF_EXTENSION">$1<ex>foo extension</ex></ph> you can re-enable Bookmark Sync by choosing "Set up sync..." in the Tools menu.
</message>
<!-- Sync New Tab Page strings -->
<message name="IDS_SYNC_NTP_SYNC_SECTION_TITLE" desc="The title of the sync status section in the New Tab Page.">
- Bookmark Sync
+ Sync
</message>
<message name="IDS_SYNC_NTP_SYNC_SECTION_ERROR_TITLE" desc="The title to display in the New Tab Page sync status section in case of an error.">
- Bookmark Sync Error!
+ Sync Error!
</message>
<message name="IDS_SYNC_NTP_SETUP_IN_PROGRESS" desc="The message to display in the New Tab Page sync section when the sync setup is underway.">
Setup in progress...
@@ -6545,15 +6552,41 @@ Keep your key file in a safe place. You will need it to create new versions of y
Synced to <ph name="USER_EMAIL_ADDRESS">$1<ex>foo@gmail.com</ex></ph>
</message>
+ <!-- Customize Sync (data type choice) dialog strings -->
+ <message name="IDS_CUSTOMIZE_SYNC_WINDOW_TITLE" desc="The title of the Customize Sync dialog box.">
+ Customize Sync
+ </message>
+ <message name="IDS_CUSTOMIZE_SYNC_DESCRIPTION" desc="The first line of the Customize Sync dialog, explaining what this box does.">
+ Sync the following items automatically:
+ </message>
+ <message name="IDS_SYNC_DATATYPE_BOOKMARKS" desc="Bookmarks, one of the data types that we allow syncing.">
+ Bookmarks
+ </message>
+ <message name="IDS_SYNC_DATATYPE_PREFERENCES" desc="Preferences, one of the data types that we allow syncing.">
+ Preferences
+ </message>
+ <message name="IDS_SYNC_DATATYPE_AUTOFILL" desc="Form autofill items, one of the data types that we allow syncing.">
+ AutoFill
+ </message>
+ <message name="IDS_SYNC_DATATYPE_THEMES" desc="Themes, one of the data types that we allow syncing.">
+ Themes
+ </message>
+ <message name="IDS_SYNC_DATATYPE_PASSWORDS" desc="Saved passwords, one of the data types that we allow syncing.">
+ Passwords
+ </message>
+ <message name="IDS_SYNC_DATATYPE_TYPED_URLS" desc="Typed URLs, one of the data types that we allow syncing.">
+ Typed URLs
+ </message>
+
<!-- Login dialog strings -->
<message name="IDS_SYNC_MY_BOOKMARKS_LABEL" desc="Text to show for the sync login dialog.">
- Sync my bookmarks
+ Set up sync
</message>
<message name="IDS_SYNC_LOGIN_INTRODUCTION" desc="The message to display at the top of the Login dialog">
- Bookmark Sync makes it easy to keep the same set of bookmarks on multiple computers.
- When you enable sync, your bookmarks will get stored online in your Google Account.
- Each additional computer on which you enable sync will receive the same bookmarks.
- </message>
+ <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> Sync makes it easy to keep the same set of data (such as bookmarks and preferences) on multiple computers.
+ When you enable syncing, your <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> data will get stored online in your Google Account.
+ Each additional computer on which you enable syncing will receive the same <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> data.
+ </message>
<message name="IDS_SYNC_LOGIN_SIGNIN_PREFIX" desc="The first part of the sentence that is displayed after the login info">
Sign in with your
</message>
@@ -6575,6 +6608,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_SYNC_CREATE_ACCOUNT" desc="The text of a hyperlink to create a Google account">
Create a Google account
</message>
+ <message name="IDS_SYNC_LOGIN_CUSTOMIZE" desc="The text of a button in the login dialog which lets you choose which datatypes to sync">
+ Customize sync...
+ </message>
<message name="IDS_SYNC_CANNOT_BE_BLANK" desc="The input error message when the user hasn't entered a username or password">
Required field cannot be left blank
</message>
@@ -6582,7 +6618,7 @@ Keep your key file in a safe place. You will need it to create new versions of y
Could not connect to the server
</message>
<message name="IDS_SYNC_LOGIN_SETTING_UP_SYNC" desc="For the connect error message">
- Setting up Bookmarks Sync
+ Setting up Sync
</message>
<message name="IDS_SYNC_LOGIN_SETTING_UP" desc="A progress message">
Setting up...
@@ -6593,39 +6629,29 @@ Keep your key file in a safe place. You will need it to create new versions of y
<!-- Sync app menu item strings -->
<if expr="not pp_ifdef('use_titlecase')">
- <message name="IDS_SYNC_MENU_BOOKMARKS_SYNCED_LABEL" desc="The text for the sync app menu item when bookmark sync has been enabled">
- Bookmarks synced...
+ <message name="IDS_SYNC_MENU_SYNCED_LABEL" desc="The text for the sync app menu item when bookmark sync has been enabled">
+ Synced...
</message>
- <message name="IDS_SYNC_MENU_BOOKMARK_SYNC_ERROR_LABEL" desc="The text for the sync app menu item when a bookmark sync error has occured">
- Bookmark sync error...
+ <message name="IDS_SYNC_MENU_SYNC_ERROR_LABEL" desc="The text for the sync app menu item when a bookmark sync error has occured">
+ Sync error...
</message>
</if>
<if expr="pp_ifdef('use_titlecase')">
- <message name="IDS_SYNC_MENU_BOOKMARKS_SYNCED_LABEL" desc="In Title Case: The text for the sync app menu item when bookmark sync has been enabled">
- Bookmarks Synced...
+ <message name="IDS_SYNC_MENU_SYNCED_LABEL" desc="In Title Case: The text for the sync app menu item when bookmark sync has been enabled">
+ Synced...
</message>
- <message name="IDS_SYNC_MENU_BOOKMARK_SYNC_ERROR_LABEL" desc="In Title Case: The text for the sync app menu item when a bookmark sync error has occured">
- Bookmark Sync Error...
+ <message name="IDS_SYNC_MENU_SYNC_ERROR_LABEL" desc="In Title Case: The text for the sync app menu item when a bookmark sync error has occured">
+ Sync Error...
</message>
</if>
- <!-- Merge and Sync dialog strings -->
- <message name="IDS_SYNC_MERGE_INTRODUCTION" desc="The header at the top of the merge and sync dialog.">
- Your bookmarks will be merged.
- </message>
- <message name="IDS_SYNC_MERGE_AND_SYNC_LABEL" desc="The label of the button to actually merge your profile">
- Merge and sync
- </message>
- <message name="IDS_SYNC_MERGE_WARNING" desc="The footer at the bottom of the merge and sync dialog.">
- Your existing online bookmarks will be merged with the
- bookmarks on this machine. You can use the Bookmark Manager to organize
- your bookmarks after the merge.
- </message>
+ <!-- Success dialog strings-->
<message name="IDS_SYNC_SETUP_ALL_DONE" desc="The text shown on the confirmation dialog after setting up sync when there were already bookmarks in the cloud.">
- Your bookmarks will now be synced between all computers where you have enabled sync.
+ Your <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> data will now be synced among all computers where you have enabled sync.
</message>
<message name="IDS_SYNC_SETUP_FIRST_TIME_ALL_DONE" desc="The text shown on the confirmation dialog after setting up sync when no bookmarks exist in the cloud.">
- Your bookmarks are now synced to Google Docs! To merge and sync your bookmarks to Chrome on another computer, just repeat the same setup process on that computer.
+ Your bookmarks are now synced to Google Docs! To merge and sync your bookmarks to <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>
+ on another computer, just repeat the same setup process on that computer.
</message>
<message name="IDS_SYNC_SETUP_OK_BUTTON_LABEL" desc="The button label on the 'OK' button displayed at the end of sync setup.">
OK
diff --git a/chrome/app/resources/locale_settings.grd b/chrome/app/resources/locale_settings.grd
index d3b974e..498b73b2 100644
--- a/chrome/app/resources/locale_settings.grd
+++ b/chrome/app/resources/locale_settings.grd
@@ -302,6 +302,15 @@
27
</message>
+ <!-- The width and height of the Sync Options (customize sync) dialog box in -->
+ <!-- characters and lines (See above for defns of char width and height). -->
+ <message name="IDS_CUSTOMIZE_SYNC_DIALOG_WIDTH_CHARS" use_name_for_id="true">
+ 60
+ </message>
+ <message name="IDS_CUSTOMIZE_SYNC_DIALOG_HEIGHT_LINES" use_name_for_id="true">
+ 10
+ </message>
+
<!-- The width and height of the Bug Reporting dialog box in characters and lines -->
<!-- (See above). -->
<message name="IDS_BUGREPORT_DIALOG_WIDTH_CHARS" use_name_for_id="true">
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd
index 8184f06..1aeceab 100644
--- a/chrome/browser/browser_resources.grd
+++ b/chrome/browser/browser_resources.grd
@@ -60,7 +60,6 @@ without changes to the corresponding grd file. fbt1 -->
<include name="IDR_ABOUT_SYNC_HTML" file="sync\resources\about_sync.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_GAIA_LOGIN_HTML" file="sync\resources\gaia_login.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_SYNC_SETUP_FLOW_HTML" file="sync\resources\setup_flow.html" flattenhtml="true" type="BINDATA" />
- <include name="IDR_MERGE_AND_SYNC_HTML" file="sync\resources\merge_and_sync.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_SYNC_SETUP_DONE_HTML" file="sync\resources\setup_done.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_BLACKLIST_HTML" file="resources\privacy_blacklist_block.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_BLACKLIST_IMAGE" file="resources\privacy_blacklist_block.png" type="BINDATA" />
diff --git a/chrome/browser/sync/glue/autofill_data_type_controller.cc b/chrome/browser/sync/glue/autofill_data_type_controller.cc
index 10fb9ec..5e7bca68 100644
--- a/chrome/browser/sync/glue/autofill_data_type_controller.cc
+++ b/chrome/browser/sync/glue/autofill_data_type_controller.cc
@@ -25,8 +25,7 @@ AutofillDataTypeController::AutofillDataTypeController(
: profile_sync_factory_(profile_sync_factory),
profile_(profile),
sync_service_(sync_service),
- state_(NOT_RUNNING),
- merge_allowed_(false) {
+ state_(NOT_RUNNING) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
DCHECK(profile_sync_factory);
DCHECK(profile);
@@ -37,8 +36,7 @@ AutofillDataTypeController::~AutofillDataTypeController() {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
}
-void AutofillDataTypeController::Start(bool merge_allowed,
- StartCallback* start_callback) {
+void AutofillDataTypeController::Start(StartCallback* start_callback) {
LOG(INFO) << "Starting autofill data controller.";
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
DCHECK(start_callback);
@@ -49,7 +47,6 @@ void AutofillDataTypeController::Start(bool merge_allowed,
}
start_callback_.reset(start_callback);
- merge_allowed_ = merge_allowed;
web_data_service_ = profile_->GetWebDataService(Profile::IMPLICIT_ACCESS);
if (web_data_service_.get() && web_data_service_->IsDatabaseLoaded()) {
@@ -57,8 +54,7 @@ void AutofillDataTypeController::Start(bool merge_allowed,
ChromeThread::PostTask(ChromeThread::DB, FROM_HERE,
NewRunnableMethod(
this,
- &AutofillDataTypeController::StartImpl,
- merge_allowed_));
+ &AutofillDataTypeController::StartImpl));
} else {
set_state(MODEL_STARTING);
notification_registrar_.Add(this, NotificationType::WEB_DATABASE_LOADED,
@@ -77,8 +73,7 @@ void AutofillDataTypeController::Observe(NotificationType type,
ChromeThread::PostTask(ChromeThread::DB, FROM_HERE,
NewRunnableMethod(
this,
- &AutofillDataTypeController::StartImpl,
- merge_allowed_));
+ &AutofillDataTypeController::StartImpl));
}
void AutofillDataTypeController::Stop() {
@@ -98,7 +93,7 @@ void AutofillDataTypeController::Stop() {
&AutofillDataTypeController::StopImpl));
}
-void AutofillDataTypeController::StartImpl(bool merge_allowed) {
+void AutofillDataTypeController::StartImpl() {
LOG(INFO) << "Autofill data type controller StartImpl called.";
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::DB));
// No additional services need to be started before we can proceed
@@ -111,28 +106,18 @@ void AutofillDataTypeController::StartImpl(bool merge_allowed) {
model_associator_.reset(sync_components.model_associator);
change_processor_.reset(sync_components.change_processor);
- bool chrome_has_nodes = false;
- if (!model_associator_->ChromeModelHasUserCreatedNodes(&chrome_has_nodes)) {
- StartFailed(UNRECOVERABLE_ERROR);
- return;
- }
bool sync_has_nodes = false;
if (!model_associator_->SyncModelHasUserCreatedNodes(&sync_has_nodes)) {
StartFailed(UNRECOVERABLE_ERROR);
return;
}
- if (chrome_has_nodes && sync_has_nodes && !merge_allowed) {
- StartFailed(NEEDS_MERGE);
- return;
- }
-
base::TimeTicks start_time = base::TimeTicks::Now();
bool merge_success = model_associator_->AssociateModels();
UMA_HISTOGRAM_TIMES("Sync.AutofillAssociationTime",
base::TimeTicks::Now() - start_time);
if (!merge_success) {
- StartFailed(NEEDS_MERGE);
+ StartFailed(ASSOCIATION_FAILED);
return;
}
diff --git a/chrome/browser/sync/glue/autofill_data_type_controller.h b/chrome/browser/sync/glue/autofill_data_type_controller.h
index 4e088d9..5ae23ec 100644
--- a/chrome/browser/sync/glue/autofill_data_type_controller.h
+++ b/chrome/browser/sync/glue/autofill_data_type_controller.h
@@ -30,7 +30,7 @@ class AutofillDataTypeController : public DataTypeController,
virtual ~AutofillDataTypeController();
// DataTypeController implementation
- virtual void Start(bool merge_allowed, StartCallback* start_callback);
+ virtual void Start(StartCallback* start_callback);
virtual void Stop();
@@ -65,7 +65,7 @@ class AutofillDataTypeController : public DataTypeController,
const NotificationDetails& details);
private:
- void StartImpl(bool merge_allowed);
+ void StartImpl();
void StartDone(StartResult result, State state);
void StartDoneImpl(StartResult result, State state);
void StopImpl();
@@ -89,8 +89,6 @@ class AutofillDataTypeController : public DataTypeController,
NotificationRegistrar notification_registrar_;
- bool merge_allowed_;
-
DISALLOW_COPY_AND_ASSIGN(AutofillDataTypeController);
};
diff --git a/chrome/browser/sync/glue/bookmark_data_type_controller.cc b/chrome/browser/sync/glue/bookmark_data_type_controller.cc
index 3705b31..97c8ff2 100644
--- a/chrome/browser/sync/glue/bookmark_data_type_controller.cc
+++ b/chrome/browser/sync/glue/bookmark_data_type_controller.cc
@@ -27,7 +27,6 @@ BookmarkDataTypeController::BookmarkDataTypeController(
profile_(profile),
sync_service_(sync_service),
state_(NOT_RUNNING),
- merge_allowed_(false),
unrecoverable_error_detected_(false) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
DCHECK(profile_sync_factory);
@@ -39,8 +38,7 @@ BookmarkDataTypeController::~BookmarkDataTypeController() {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
}
-void BookmarkDataTypeController::Start(bool merge_allowed,
- StartCallback* start_callback) {
+void BookmarkDataTypeController::Start(StartCallback* start_callback) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
DCHECK(start_callback);
unrecoverable_error_detected_ = false;
@@ -51,7 +49,6 @@ void BookmarkDataTypeController::Start(bool merge_allowed,
}
start_callback_.reset(start_callback);
- merge_allowed_ = merge_allowed;
if (!enabled()) {
FinishStart(NOT_ENABLED);
@@ -93,7 +90,6 @@ void BookmarkDataTypeController::Stop() {
model_associator_.reset();
state_ = NOT_RUNNING;
- merge_allowed_ = false;
}
void BookmarkDataTypeController::OnUnrecoverableError() {
@@ -121,22 +117,12 @@ void BookmarkDataTypeController::Associate() {
model_associator_.reset(sync_components.model_associator);
change_processor_.reset(sync_components.change_processor);
- bool chrome_has_nodes = false;
- if (!model_associator_->ChromeModelHasUserCreatedNodes(&chrome_has_nodes)) {
- StartFailed(UNRECOVERABLE_ERROR);
- return;
- }
bool sync_has_nodes = false;
if (!model_associator_->SyncModelHasUserCreatedNodes(&sync_has_nodes)) {
StartFailed(UNRECOVERABLE_ERROR);
return;
}
- if (chrome_has_nodes && sync_has_nodes && !merge_allowed_) {
- StartFailed(NEEDS_MERGE);
- return;
- }
-
base::TimeTicks start_time = base::TimeTicks::Now();
bool merge_success = model_associator_->AssociateModels();
UMA_HISTOGRAM_TIMES("Sync.BookmarkAssociationTime",
diff --git a/chrome/browser/sync/glue/bookmark_data_type_controller.h b/chrome/browser/sync/glue/bookmark_data_type_controller.h
index 948bbe7..33a0089 100644
--- a/chrome/browser/sync/glue/bookmark_data_type_controller.h
+++ b/chrome/browser/sync/glue/bookmark_data_type_controller.h
@@ -34,7 +34,7 @@ class BookmarkDataTypeController : public DataTypeController,
virtual ~BookmarkDataTypeController();
// DataTypeController interface.
- virtual void Start(bool merge_allowed, StartCallback* start_callback);
+ virtual void Start(StartCallback* start_callback);
virtual void Stop();
@@ -82,7 +82,6 @@ class BookmarkDataTypeController : public DataTypeController,
ProfileSyncService* sync_service_;
State state_;
- bool merge_allowed_;
bool unrecoverable_error_detected_;
scoped_ptr<StartCallback> start_callback_;
diff --git a/chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc b/chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc
index 593b912..f3b4993 100644
--- a/chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc
+++ b/chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc
@@ -102,8 +102,7 @@ TEST_F(BookmarkDataTypeControllerTest, StartBookmarkModelReady) {
EXPECT_EQ(DataTypeController::NOT_RUNNING, bookmark_dtc_->state());
EXPECT_CALL(start_callback_, Run(DataTypeController::OK));
- bookmark_dtc_->Start(false,
- NewCallback(&start_callback_, &StartCallback::Run));
+ bookmark_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
EXPECT_EQ(DataTypeController::RUNNING, bookmark_dtc_->state());
}
@@ -113,8 +112,7 @@ TEST_F(BookmarkDataTypeControllerTest, StartBookmarkModelNotReady) {
SetAssociateExpectations();
EXPECT_CALL(start_callback_, Run(DataTypeController::OK));
- bookmark_dtc_->Start(false,
- NewCallback(&start_callback_, &StartCallback::Run));
+ bookmark_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
EXPECT_EQ(DataTypeController::MODEL_STARTING, bookmark_dtc_->state());
// Send the notification that the bookmark model has started.
@@ -131,8 +129,7 @@ TEST_F(BookmarkDataTypeControllerTest, StartFirstRun) {
EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)).
WillRepeatedly(DoAll(SetArgumentPointee<0>(false), Return(true)));
EXPECT_CALL(start_callback_, Run(DataTypeController::OK_FIRST_RUN));
- bookmark_dtc_->Start(false,
- NewCallback(&start_callback_, &StartCallback::Run));
+ bookmark_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
}
TEST_F(BookmarkDataTypeControllerTest, StartBusy) {
@@ -140,26 +137,11 @@ TEST_F(BookmarkDataTypeControllerTest, StartBusy) {
EXPECT_CALL(bookmark_model_, IsLoaded()).WillRepeatedly(Return(false));
EXPECT_CALL(start_callback_, Run(DataTypeController::BUSY));
- bookmark_dtc_->Start(false,
- NewCallback(&start_callback_, &StartCallback::Run));
- bookmark_dtc_->Start(false,
- NewCallback(&start_callback_, &StartCallback::Run));
+ bookmark_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
+ bookmark_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
}
-TEST_F(BookmarkDataTypeControllerTest, StartNeedsMerge) {
- SetStartExpectations();
- EXPECT_CALL(*profile_sync_factory_, CreateBookmarkSyncComponents(_, _));
- EXPECT_CALL(*model_associator_, ChromeModelHasUserCreatedNodes(_)).
- WillRepeatedly(DoAll(SetArgumentPointee<0>(true), Return(true)));
- EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)).
- WillRepeatedly(DoAll(SetArgumentPointee<0>(true), Return(true)));
-
- EXPECT_CALL(start_callback_, Run(DataTypeController::NEEDS_MERGE));
- bookmark_dtc_->Start(false,
- NewCallback(&start_callback_, &StartCallback::Run));
-}
-
-TEST_F(BookmarkDataTypeControllerTest, StartMergeAllowed) {
+TEST_F(BookmarkDataTypeControllerTest, StartOk) {
SetStartExpectations();
SetAssociateExpectations();
EXPECT_CALL(*model_associator_, ChromeModelHasUserCreatedNodes(_)).
@@ -168,8 +150,7 @@ TEST_F(BookmarkDataTypeControllerTest, StartMergeAllowed) {
WillRepeatedly(DoAll(SetArgumentPointee<0>(true), Return(true)));
EXPECT_CALL(start_callback_, Run(DataTypeController::OK));
- bookmark_dtc_->Start(true,
- NewCallback(&start_callback_, &StartCallback::Run));
+ bookmark_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
}
TEST_F(BookmarkDataTypeControllerTest, StartAssociationFailed) {
@@ -184,8 +165,7 @@ TEST_F(BookmarkDataTypeControllerTest, StartAssociationFailed) {
WillRepeatedly(Return(false));
EXPECT_CALL(start_callback_, Run(DataTypeController::ASSOCIATION_FAILED));
- bookmark_dtc_->Start(true,
- NewCallback(&start_callback_, &StartCallback::Run));
+ bookmark_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
EXPECT_EQ(DataTypeController::NOT_RUNNING, bookmark_dtc_->state());
}
@@ -199,8 +179,7 @@ TEST_F(BookmarkDataTypeControllerTest,
EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)).
WillRepeatedly(DoAll(SetArgumentPointee<0>(false), Return(false)));
EXPECT_CALL(start_callback_, Run(DataTypeController::UNRECOVERABLE_ERROR));
- bookmark_dtc_->Start(true,
- NewCallback(&start_callback_, &StartCallback::Run));
+ bookmark_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
EXPECT_EQ(DataTypeController::NOT_RUNNING, bookmark_dtc_->state());
}
@@ -209,8 +188,7 @@ TEST_F(BookmarkDataTypeControllerTest, StartAborted) {
EXPECT_CALL(bookmark_model_, IsLoaded()).WillRepeatedly(Return(false));
EXPECT_CALL(start_callback_, Run(DataTypeController::ABORTED));
- bookmark_dtc_->Start(false,
- NewCallback(&start_callback_, &StartCallback::Run));
+ bookmark_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
bookmark_dtc_->Stop();
EXPECT_EQ(DataTypeController::NOT_RUNNING, bookmark_dtc_->state());
}
@@ -223,8 +201,7 @@ TEST_F(BookmarkDataTypeControllerTest, Stop) {
EXPECT_EQ(DataTypeController::NOT_RUNNING, bookmark_dtc_->state());
EXPECT_CALL(start_callback_, Run(DataTypeController::OK));
- bookmark_dtc_->Start(false,
- NewCallback(&start_callback_, &StartCallback::Run));
+ bookmark_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
EXPECT_EQ(DataTypeController::RUNNING, bookmark_dtc_->state());
bookmark_dtc_->Stop();
EXPECT_EQ(DataTypeController::NOT_RUNNING, bookmark_dtc_->state());
diff --git a/chrome/browser/sync/glue/data_type_controller.h b/chrome/browser/sync/glue/data_type_controller.h
index 669e2ff..95bc0b3 100644
--- a/chrome/browser/sync/glue/data_type_controller.h
+++ b/chrome/browser/sync/glue/data_type_controller.h
@@ -42,10 +42,6 @@ class DataTypeController
// determined by cloud state.
BUSY, // Start() was called while already in progress.
NOT_ENABLED, // This data type is not enabled for the current user.
- NEEDS_MERGE, // Can't start without explicit permission to
- // perform a data merge. Re-starting with
- // merge_allowed = true will allow this data
- // type to start.
ASSOCIATION_FAILED, // An error occurred during model association.
ABORTED, // Start was aborted by calling Stop().
UNRECOVERABLE_ERROR // An unrecoverable error occured.
@@ -55,15 +51,15 @@ class DataTypeController
typedef std::map<syncable::ModelType,
scoped_refptr<DataTypeController> > TypeMap;
+ typedef std::map<syncable::ModelType, DataTypeController::State> StateMap;
// Begins asynchronous start up of this data type. Start up will
// wait for all other dependent services to be available, then
// proceed with model association and then change processor
// activation. Upon completion, the start_callback will be invoked
- // on the UI thread. The merge_allowed parameter gives the data
- // type permission to perform a data merge at start time. See the
- // StartResult enum above for details on the possible start results.
- virtual void Start(bool merge_allowed, StartCallback* start_callback) = 0;
+ // on the UI thread. See the StartResult enum above for details on the
+ // possible start results.
+ virtual void Start(StartCallback* start_callback) = 0;
// Synchronously stops the data type. If called after Start() is
// called but before the start callback is called, the start is
diff --git a/chrome/browser/sync/glue/data_type_controller_mock.h b/chrome/browser/sync/glue/data_type_controller_mock.h
index 5c58887..914e98f 100644
--- a/chrome/browser/sync/glue/data_type_controller_mock.h
+++ b/chrome/browser/sync/glue/data_type_controller_mock.h
@@ -12,7 +12,7 @@ namespace browser_sync {
class DataTypeControllerMock : public DataTypeController {
public:
- MOCK_METHOD2(Start, void(bool merge_allowed, StartCallback* start_callback));
+ MOCK_METHOD1(Start, void(StartCallback* start_callback));
MOCK_METHOD0(Stop, void());
MOCK_METHOD0(enabled, bool());
MOCK_METHOD0(type, syncable::ModelType());
diff --git a/chrome/browser/sync/glue/data_type_manager_impl.cc b/chrome/browser/sync/glue/data_type_manager_impl.cc
index 6292290..23e5ab1 100644
--- a/chrome/browser/sync/glue/data_type_manager_impl.cc
+++ b/chrome/browser/sync/glue/data_type_manager_impl.cc
@@ -35,7 +35,7 @@ class SortComparator : public std::binary_function<DataTypeController*,
explicit SortComparator(std::map<syncable::ModelType, int>* order)
: order_(order) { }
- // Returns true if lhs preceeds rhs.
+ // Returns true if lhs precedes rhs.
bool operator() (DataTypeController* lhs, DataTypeController* rhs) {
return (*order_)[lhs->type()] < (*order_)[rhs->type()];
}
@@ -183,7 +183,6 @@ void DataTypeManagerImpl::StartNextType() {
current_dtc_ = needs_start_[0];
LOG(INFO) << "Starting " << current_dtc_->name();
current_dtc_->Start(
- true,
NewCallback(this, &DataTypeManagerImpl::TypeStartCallback));
return;
}
diff --git a/chrome/browser/sync/glue/data_type_manager_impl_unittest.cc b/chrome/browser/sync/glue/data_type_manager_impl_unittest.cc
index 43718b8..20a823c 100644
--- a/chrome/browser/sync/glue/data_type_manager_impl_unittest.cc
+++ b/chrome/browser/sync/glue/data_type_manager_impl_unittest.cc
@@ -38,8 +38,8 @@ using testing::Return;
using testing::SaveArg;
ACTION_P(InvokeCallback, callback_result) {
- arg1->Run(callback_result);
- delete arg1;
+ arg0->Run(callback_result);
+ delete arg0;
}
class DataTypeManagerImplTest : public testing::Test {
@@ -80,7 +80,7 @@ class DataTypeManagerImplTest : public testing::Test {
InSequence seq;
EXPECT_CALL(*mock_dtc, state()).
WillRepeatedly(Return(DataTypeController::NOT_RUNNING));
- EXPECT_CALL(*mock_dtc, Start(true, _)).
+ EXPECT_CALL(*mock_dtc, Start(_)).
WillOnce(InvokeCallback((DataTypeController::OK)));
EXPECT_CALL(*mock_dtc, state()).
WillRepeatedly(Return(DataTypeController::RUNNING));
@@ -214,8 +214,8 @@ TEST_F(DataTypeManagerImplTest, ConfigureWhileOneInFlight) {
InSequence seq;
EXPECT_CALL(*bookmark_dtc, state()).
WillRepeatedly(Return(DataTypeController::NOT_RUNNING));
- EXPECT_CALL(*bookmark_dtc, Start(true, _)).
- WillOnce(SaveArg<1>(&callback));
+ EXPECT_CALL(*bookmark_dtc, Start(_)).
+ WillOnce(SaveArg<0>(&callback));
EXPECT_CALL(*bookmark_dtc, state()).
WillRepeatedly(Return(DataTypeController::RUNNING));
EXPECT_CALL(*bookmark_dtc, Stop()).Times(1);
@@ -383,7 +383,7 @@ TEST_F(DataTypeManagerImplTest, StopWhileResumePending) {
TEST_F(DataTypeManagerImplTest, OneFailingController) {
DataTypeControllerMock* bookmark_dtc = MakeBookmarkDTC();
- EXPECT_CALL(*bookmark_dtc, Start(true, _)).
+ EXPECT_CALL(*bookmark_dtc, Start(_)).
WillOnce(InvokeCallback((DataTypeController::ASSOCIATION_FAILED)));
EXPECT_CALL(*bookmark_dtc, Stop()).Times(0);
EXPECT_CALL(*bookmark_dtc, state()).
@@ -410,8 +410,8 @@ TEST_F(DataTypeManagerImplTest, StopWhileInFlight) {
DataTypeControllerMock* preference_dtc = MakePreferenceDTC();
// Save the callback here so we can interrupt startup.
DataTypeController::StartCallback* callback;
- EXPECT_CALL(*preference_dtc, Start(true, _)).
- WillOnce(SaveArg<1>(&callback));
+ EXPECT_CALL(*preference_dtc, Start(_)).
+ WillOnce(SaveArg<0>(&callback));
EXPECT_CALL(*preference_dtc, Stop()).Times(1);
EXPECT_CALL(*preference_dtc, state()).
WillRepeatedly(Return(DataTypeController::NOT_RUNNING));
@@ -444,7 +444,7 @@ TEST_F(DataTypeManagerImplTest, SecondControllerFails) {
controllers_[syncable::BOOKMARKS] = bookmark_dtc;
DataTypeControllerMock* preference_dtc = MakePreferenceDTC();
- EXPECT_CALL(*preference_dtc, Start(true, _)).
+ EXPECT_CALL(*preference_dtc, Start(_)).
WillOnce(InvokeCallback((DataTypeController::ASSOCIATION_FAILED)));
EXPECT_CALL(*preference_dtc, Stop()).Times(0);
EXPECT_CALL(*preference_dtc, state()).
@@ -466,7 +466,7 @@ TEST_F(DataTypeManagerImplTest, SecondControllerFails) {
TEST_F(DataTypeManagerImplTest, PauseFailed) {
DataTypeControllerMock* bookmark_dtc = MakeBookmarkDTC();
- EXPECT_CALL(*bookmark_dtc, Start(_, _)).Times(0);
+ EXPECT_CALL(*bookmark_dtc, Start(_)).Times(0);
EXPECT_CALL(*bookmark_dtc, state()).
WillRepeatedly(Return(DataTypeController::NOT_RUNNING));
controllers_[syncable::BOOKMARKS] = bookmark_dtc;
diff --git a/chrome/browser/sync/glue/preference_data_type_controller.cc b/chrome/browser/sync/glue/preference_data_type_controller.cc
index a3c52c6..940f093 100644
--- a/chrome/browser/sync/glue/preference_data_type_controller.cc
+++ b/chrome/browser/sync/glue/preference_data_type_controller.cc
@@ -31,8 +31,7 @@ PreferenceDataTypeController::~PreferenceDataTypeController() {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
}
-void PreferenceDataTypeController::Start(bool merge_allowed,
- StartCallback* start_callback) {
+void PreferenceDataTypeController::Start(StartCallback* start_callback) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
DCHECK(start_callback);
unrecoverable_error_detected_ = false;
@@ -52,22 +51,12 @@ void PreferenceDataTypeController::Start(bool merge_allowed,
model_associator_.reset(sync_components.model_associator);
change_processor_.reset(sync_components.change_processor);
- bool chrome_has_nodes = false;
- if (!model_associator_->ChromeModelHasUserCreatedNodes(&chrome_has_nodes)) {
- StartFailed(UNRECOVERABLE_ERROR);
- return;
- }
bool sync_has_nodes = false;
if (!model_associator_->SyncModelHasUserCreatedNodes(&sync_has_nodes)) {
StartFailed(UNRECOVERABLE_ERROR);
return;
}
- if (chrome_has_nodes && sync_has_nodes && !merge_allowed) {
- StartFailed(NEEDS_MERGE);
- return;
- }
-
base::TimeTicks start_time = base::TimeTicks::Now();
bool merge_success = model_associator_->AssociateModels();
UMA_HISTOGRAM_TIMES("Sync.PreferenceAssociationTime",
diff --git a/chrome/browser/sync/glue/preference_data_type_controller.h b/chrome/browser/sync/glue/preference_data_type_controller.h
index 5347225..b2926d0 100644
--- a/chrome/browser/sync/glue/preference_data_type_controller.h
+++ b/chrome/browser/sync/glue/preference_data_type_controller.h
@@ -24,7 +24,7 @@ class PreferenceDataTypeController : public DataTypeController {
ProfileSyncService* sync_service);
virtual ~PreferenceDataTypeController();
- virtual void Start(bool merge_allowed, StartCallback* start_callback);
+ virtual void Start(StartCallback* start_callback);
virtual void Stop();
diff --git a/chrome/browser/sync/glue/preference_data_type_controller_unittest.cc b/chrome/browser/sync/glue/preference_data_type_controller_unittest.cc
index 8449222..5c0f5d0 100644
--- a/chrome/browser/sync/glue/preference_data_type_controller_unittest.cc
+++ b/chrome/browser/sync/glue/preference_data_type_controller_unittest.cc
@@ -85,8 +85,7 @@ TEST_F(PreferenceDataTypeControllerTest, Start) {
SetActivateExpectations();
EXPECT_EQ(DataTypeController::NOT_RUNNING, preference_dtc_->state());
EXPECT_CALL(start_callback_, Run(DataTypeController::OK));
- preference_dtc_->Start(false,
- NewCallback(&start_callback_, &StartCallback::Run));
+ preference_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
EXPECT_EQ(DataTypeController::RUNNING, preference_dtc_->state());
}
@@ -97,23 +96,10 @@ TEST_F(PreferenceDataTypeControllerTest, StartFirstRun) {
EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)).
WillRepeatedly(DoAll(SetArgumentPointee<0>(false), Return(true)));
EXPECT_CALL(start_callback_, Run(DataTypeController::OK_FIRST_RUN));
- preference_dtc_->Start(false,
- NewCallback(&start_callback_, &StartCallback::Run));
+ preference_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
}
-TEST_F(PreferenceDataTypeControllerTest, StartNeedsMerge) {
- SetStartExpectations();
- SetAssociateExpectations();
- EXPECT_CALL(*model_associator_, ChromeModelHasUserCreatedNodes(_)).
- WillRepeatedly(DoAll(SetArgumentPointee<0>(true), Return(true)));
- EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)).
- WillRepeatedly(DoAll(SetArgumentPointee<0>(true), Return(true)));
- EXPECT_CALL(start_callback_, Run(DataTypeController::NEEDS_MERGE));
- preference_dtc_->Start(false,
- NewCallback(&start_callback_, &StartCallback::Run));
-}
-
-TEST_F(PreferenceDataTypeControllerTest, StartMergeAllowed) {
+TEST_F(PreferenceDataTypeControllerTest, StartOk) {
SetStartExpectations();
SetAssociateExpectations();
SetActivateExpectations();
@@ -123,8 +109,7 @@ TEST_F(PreferenceDataTypeControllerTest, StartMergeAllowed) {
WillRepeatedly(DoAll(SetArgumentPointee<0>(true), Return(true)));
EXPECT_CALL(start_callback_, Run(DataTypeController::OK));
- preference_dtc_->Start(true,
- NewCallback(&start_callback_, &StartCallback::Run));
+ preference_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
}
TEST_F(PreferenceDataTypeControllerTest, StartAssociationFailed) {
@@ -134,8 +119,7 @@ TEST_F(PreferenceDataTypeControllerTest, StartAssociationFailed) {
WillRepeatedly(Return(false));
EXPECT_CALL(start_callback_, Run(DataTypeController::ASSOCIATION_FAILED));
- preference_dtc_->Start(true,
- NewCallback(&start_callback_, &StartCallback::Run));
+ preference_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
EXPECT_EQ(DataTypeController::NOT_RUNNING, preference_dtc_->state());
}
@@ -148,8 +132,7 @@ TEST_F(PreferenceDataTypeControllerTest,
EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)).
WillRepeatedly(DoAll(SetArgumentPointee<0>(false), Return(false)));
EXPECT_CALL(start_callback_, Run(DataTypeController::UNRECOVERABLE_ERROR));
- preference_dtc_->Start(true,
- NewCallback(&start_callback_, &StartCallback::Run));
+ preference_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
EXPECT_EQ(DataTypeController::NOT_RUNNING, preference_dtc_->state());
}
@@ -162,8 +145,7 @@ TEST_F(PreferenceDataTypeControllerTest, Stop) {
EXPECT_EQ(DataTypeController::NOT_RUNNING, preference_dtc_->state());
EXPECT_CALL(start_callback_, Run(DataTypeController::OK));
- preference_dtc_->Start(false,
- NewCallback(&start_callback_, &StartCallback::Run));
+ preference_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
EXPECT_EQ(DataTypeController::RUNNING, preference_dtc_->state());
preference_dtc_->Stop();
EXPECT_EQ(DataTypeController::NOT_RUNNING, preference_dtc_->state());
diff --git a/chrome/browser/sync/glue/theme_data_type_controller.cc b/chrome/browser/sync/glue/theme_data_type_controller.cc
index 19f2153..0d0b2fb 100644
--- a/chrome/browser/sync/glue/theme_data_type_controller.cc
+++ b/chrome/browser/sync/glue/theme_data_type_controller.cc
@@ -31,8 +31,7 @@ ThemeDataTypeController::ThemeDataTypeController(
ThemeDataTypeController::~ThemeDataTypeController() {
}
-void ThemeDataTypeController::Start(bool merge_allowed,
- StartCallback* start_callback) {
+void ThemeDataTypeController::Start(StartCallback* start_callback) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
DCHECK(start_callback);
unrecoverable_error_detected_ = false;
@@ -62,11 +61,6 @@ void ThemeDataTypeController::Start(bool merge_allowed,
return;
}
- if (chrome_has_nodes && sync_has_nodes && !merge_allowed) {
- StartFailed(NEEDS_MERGE);
- return;
- }
-
base::TimeTicks start_time = base::TimeTicks::Now();
bool merge_success = model_associator_->AssociateModels();
UMA_HISTOGRAM_TIMES("Sync.ThemeAssociationTime",
diff --git a/chrome/browser/sync/glue/theme_data_type_controller.h b/chrome/browser/sync/glue/theme_data_type_controller.h
index 5d020d2..b26c992 100644
--- a/chrome/browser/sync/glue/theme_data_type_controller.h
+++ b/chrome/browser/sync/glue/theme_data_type_controller.h
@@ -26,8 +26,8 @@ class ThemeDataTypeController : public DataTypeController {
ProfileSyncService* sync_service);
virtual ~ThemeDataTypeController();
- // DataTypeController impementation.
- virtual void Start(bool merge_allowed, StartCallback* start_callback);
+ // DataTypeController implementation.
+ virtual void Start(StartCallback* start_callback);
virtual void Stop();
diff --git a/chrome/browser/sync/glue/theme_data_type_controller_unittest.cc b/chrome/browser/sync/glue/theme_data_type_controller_unittest.cc
index 4c04c20..c67e1e5 100644
--- a/chrome/browser/sync/glue/theme_data_type_controller_unittest.cc
+++ b/chrome/browser/sync/glue/theme_data_type_controller_unittest.cc
@@ -87,8 +87,7 @@ TEST_F(ThemeDataTypeControllerTest, Start) {
SetActivateExpectations();
EXPECT_EQ(DataTypeController::NOT_RUNNING, theme_dtc_->state());
EXPECT_CALL(start_callback_, Run(DataTypeController::OK));
- theme_dtc_->Start(false,
- NewCallback(&start_callback_, &StartCallback::Run));
+ theme_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
EXPECT_EQ(DataTypeController::RUNNING, theme_dtc_->state());
}
@@ -99,23 +98,10 @@ TEST_F(ThemeDataTypeControllerTest, StartFirstRun) {
EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)).
WillRepeatedly(DoAll(SetArgumentPointee<0>(false), Return(true)));
EXPECT_CALL(start_callback_, Run(DataTypeController::OK_FIRST_RUN));
- theme_dtc_->Start(false,
- NewCallback(&start_callback_, &StartCallback::Run));
+ theme_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
}
-TEST_F(ThemeDataTypeControllerTest, StartNeedsMerge) {
- SetStartExpectations();
- SetAssociateExpectations();
- EXPECT_CALL(*model_associator_, ChromeModelHasUserCreatedNodes(_)).
- WillRepeatedly(DoAll(SetArgumentPointee<0>(true), Return(true)));
- EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)).
- WillRepeatedly(DoAll(SetArgumentPointee<0>(true), Return(true)));
- EXPECT_CALL(start_callback_, Run(DataTypeController::NEEDS_MERGE));
- theme_dtc_->Start(false,
- NewCallback(&start_callback_, &StartCallback::Run));
-}
-
-TEST_F(ThemeDataTypeControllerTest, StartMergeAllowed) {
+TEST_F(ThemeDataTypeControllerTest, StartOk) {
SetStartExpectations();
SetAssociateExpectations();
SetActivateExpectations();
@@ -125,8 +111,7 @@ TEST_F(ThemeDataTypeControllerTest, StartMergeAllowed) {
WillRepeatedly(DoAll(SetArgumentPointee<0>(true), Return(true)));
EXPECT_CALL(start_callback_, Run(DataTypeController::OK));
- theme_dtc_->Start(true,
- NewCallback(&start_callback_, &StartCallback::Run));
+ theme_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
}
TEST_F(ThemeDataTypeControllerTest, StartAssociationFailed) {
@@ -136,8 +121,7 @@ TEST_F(ThemeDataTypeControllerTest, StartAssociationFailed) {
WillRepeatedly(Return(false));
EXPECT_CALL(start_callback_, Run(DataTypeController::ASSOCIATION_FAILED));
- theme_dtc_->Start(true,
- NewCallback(&start_callback_, &StartCallback::Run));
+ theme_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
EXPECT_EQ(DataTypeController::NOT_RUNNING, theme_dtc_->state());
}
@@ -150,8 +134,7 @@ TEST_F(ThemeDataTypeControllerTest,
EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)).
WillRepeatedly(DoAll(SetArgumentPointee<0>(false), Return(false)));
EXPECT_CALL(start_callback_, Run(DataTypeController::UNRECOVERABLE_ERROR));
- theme_dtc_->Start(true,
- NewCallback(&start_callback_, &StartCallback::Run));
+ theme_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
EXPECT_EQ(DataTypeController::NOT_RUNNING, theme_dtc_->state());
}
@@ -164,8 +147,7 @@ TEST_F(ThemeDataTypeControllerTest, Stop) {
EXPECT_EQ(DataTypeController::NOT_RUNNING, theme_dtc_->state());
EXPECT_CALL(start_callback_, Run(DataTypeController::OK));
- theme_dtc_->Start(false,
- NewCallback(&start_callback_, &StartCallback::Run));
+ theme_dtc_->Start(NewCallback(&start_callback_, &StartCallback::Run));
EXPECT_EQ(DataTypeController::RUNNING, theme_dtc_->state());
theme_dtc_->Stop();
EXPECT_EQ(DataTypeController::NOT_RUNNING, theme_dtc_->state());
diff --git a/chrome/browser/sync/glue/typed_url_data_type_controller.cc b/chrome/browser/sync/glue/typed_url_data_type_controller.cc
index ec5c4e1..841392e 100644
--- a/chrome/browser/sync/glue/typed_url_data_type_controller.cc
+++ b/chrome/browser/sync/glue/typed_url_data_type_controller.cc
@@ -52,8 +52,7 @@ TypedUrlDataTypeController::TypedUrlDataTypeController(
: profile_sync_factory_(profile_sync_factory),
profile_(profile),
sync_service_(sync_service),
- state_(NOT_RUNNING),
- merge_allowed_(false) {
+ state_(NOT_RUNNING) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
DCHECK(profile_sync_factory);
DCHECK(profile);
@@ -64,8 +63,7 @@ TypedUrlDataTypeController::~TypedUrlDataTypeController() {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
}
-void TypedUrlDataTypeController::Start(bool merge_allowed,
- StartCallback* start_callback) {
+void TypedUrlDataTypeController::Start(StartCallback* start_callback) {
LOG(INFO) << "Starting typed_url data controller.";
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
DCHECK(start_callback);
@@ -76,7 +74,6 @@ void TypedUrlDataTypeController::Start(bool merge_allowed,
}
start_callback_.reset(start_callback);
- merge_allowed_ = merge_allowed;
HistoryService* history = profile_->GetHistoryServiceWithoutCreating();
if (history) {
@@ -130,28 +127,18 @@ void TypedUrlDataTypeController::StartImpl(history::HistoryBackend* backend) {
model_associator_.reset(sync_components.model_associator);
change_processor_.reset(sync_components.change_processor);
- bool chrome_has_nodes = false;
- if (!model_associator_->ChromeModelHasUserCreatedNodes(&chrome_has_nodes)) {
- StartFailed(UNRECOVERABLE_ERROR);
- return;
- }
bool sync_has_nodes = false;
if (!model_associator_->SyncModelHasUserCreatedNodes(&sync_has_nodes)) {
StartFailed(UNRECOVERABLE_ERROR);
return;
}
- if (chrome_has_nodes && sync_has_nodes && !merge_allowed_) {
- StartFailed(NEEDS_MERGE);
- return;
- }
-
base::TimeTicks start_time = base::TimeTicks::Now();
bool merge_success = model_associator_->AssociateModels();
UMA_HISTOGRAM_TIMES("Sync.TypedUrlAssociationTime",
base::TimeTicks::Now() - start_time);
if (!merge_success) {
- StartFailed(NEEDS_MERGE);
+ StartFailed(ASSOCIATION_FAILED);
return;
}
diff --git a/chrome/browser/sync/glue/typed_url_data_type_controller.h b/chrome/browser/sync/glue/typed_url_data_type_controller.h
index 9897f71..edfba68 100644
--- a/chrome/browser/sync/glue/typed_url_data_type_controller.h
+++ b/chrome/browser/sync/glue/typed_url_data_type_controller.h
@@ -38,7 +38,7 @@ class TypedUrlDataTypeController : public DataTypeController,
virtual ~TypedUrlDataTypeController();
// DataTypeController implementation
- virtual void Start(bool merge_allowed, StartCallback* start_callback);
+ virtual void Start(StartCallback* start_callback);
virtual void Stop();
@@ -103,8 +103,6 @@ class TypedUrlDataTypeController : public DataTypeController,
NotificationRegistrar notification_registrar_;
- bool merge_allowed_;
-
DISALLOW_COPY_AND_ASSIGN(TypedUrlDataTypeController);
};
diff --git a/chrome/browser/sync/profile_sync_factory_impl_unittest.cc b/chrome/browser/sync/profile_sync_factory_impl_unittest.cc
index fb400ce..d13f8a4 100644
--- a/chrome/browser/sync/profile_sync_factory_impl_unittest.cc
+++ b/chrome/browser/sync/profile_sync_factory_impl_unittest.cc
@@ -40,46 +40,56 @@ class ProfileSyncFactoryImplTest : public testing::Test {
TEST_F(ProfileSyncFactoryImplTest, CreatePSSDefault) {
scoped_ptr<ProfileSyncService> pss;
pss.reset(profile_sync_service_factory_->CreateProfileSyncService());
- DataTypeController::TypeMap controllers(pss->data_type_controllers());
- EXPECT_EQ(1U, controllers.size());
- EXPECT_EQ(1U, controllers.count(syncable::BOOKMARKS));
+ DataTypeController::StateMap controller_states;
+ DataTypeController::StateMap* controller_states_ptr = &controller_states;
+ pss->GetDataTypeControllerStates(controller_states_ptr);
+ EXPECT_EQ(1U, controller_states_ptr->size());
+ EXPECT_EQ(1U, controller_states_ptr->count(syncable::BOOKMARKS));
}
TEST_F(ProfileSyncFactoryImplTest, CreatePSSEnableAutofill) {
command_line_->AppendSwitch(switches::kEnableSyncAutofill);
scoped_ptr<ProfileSyncService> pss;
pss.reset(profile_sync_service_factory_->CreateProfileSyncService());
- DataTypeController::TypeMap controllers(pss->data_type_controllers());
- EXPECT_EQ(2U, controllers.size());
- EXPECT_EQ(1U, controllers.count(syncable::BOOKMARKS));
- EXPECT_EQ(1U, controllers.count(syncable::AUTOFILL));
+ DataTypeController::StateMap controller_states;
+ DataTypeController::StateMap* controller_states_ptr = &controller_states;
+ pss->GetDataTypeControllerStates(controller_states_ptr);
+ EXPECT_EQ(2U, controller_states_ptr->size());
+ EXPECT_EQ(1U, controller_states_ptr->count(syncable::BOOKMARKS));
+ EXPECT_EQ(1U, controller_states_ptr->count(syncable::AUTOFILL));
}
TEST_F(ProfileSyncFactoryImplTest, CreatePSSDisableBookmarks) {
command_line_->AppendSwitch(switches::kDisableSyncBookmarks);
scoped_ptr<ProfileSyncService> pss;
pss.reset(profile_sync_service_factory_->CreateProfileSyncService());
- DataTypeController::TypeMap controllers(pss->data_type_controllers());
- EXPECT_EQ(0U, controllers.size());
- EXPECT_EQ(0U, controllers.count(syncable::BOOKMARKS));
+ DataTypeController::StateMap controller_states;
+ DataTypeController::StateMap* controller_states_ptr = &controller_states;
+ pss->GetDataTypeControllerStates(controller_states_ptr);
+ EXPECT_EQ(0U, controller_states_ptr->size());
+ EXPECT_EQ(0U, controller_states_ptr->count(syncable::BOOKMARKS));
}
TEST_F(ProfileSyncFactoryImplTest, CreatePSSEnablePreferences) {
command_line_->AppendSwitch(switches::kEnableSyncPreferences);
scoped_ptr<ProfileSyncService> pss;
pss.reset(profile_sync_service_factory_->CreateProfileSyncService());
- DataTypeController::TypeMap controllers(pss->data_type_controllers());
- EXPECT_EQ(2U, controllers.size());
- EXPECT_EQ(1U, controllers.count(syncable::BOOKMARKS));
- EXPECT_EQ(1U, controllers.count(syncable::PREFERENCES));
+ DataTypeController::StateMap controller_states;
+ DataTypeController::StateMap* controller_states_ptr = &controller_states;
+ pss->GetDataTypeControllerStates(controller_states_ptr);
+ EXPECT_EQ(2U, controller_states_ptr->size());
+ EXPECT_EQ(1U, controller_states_ptr->count(syncable::BOOKMARKS));
+ EXPECT_EQ(1U, controller_states_ptr->count(syncable::PREFERENCES));
}
TEST_F(ProfileSyncFactoryImplTest, CreatePSSEnableThemes) {
command_line_->AppendSwitch(switches::kEnableSyncThemes);
scoped_ptr<ProfileSyncService> pss;
pss.reset(profile_sync_service_factory_->CreateProfileSyncService());
- DataTypeController::TypeMap controllers(pss->data_type_controllers());
- EXPECT_EQ(2U, controllers.size());
- EXPECT_EQ(1U, controllers.count(syncable::BOOKMARKS));
- EXPECT_EQ(1U, controllers.count(syncable::THEMES));
+ DataTypeController::StateMap controller_states;
+ DataTypeController::StateMap* controller_states_ptr = &controller_states;
+ pss->GetDataTypeControllerStates(controller_states_ptr);
+ EXPECT_EQ(2U, controller_states_ptr->size());
+ EXPECT_EQ(1U, controller_states_ptr->count(syncable::BOOKMARKS));
+ EXPECT_EQ(1U, controller_states_ptr->count(syncable::THEMES));
}
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index a6d388c..ad670be 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/sync/profile_sync_service.h"
+#include <map>
#include <set>
#include "app/l10n_util.h"
@@ -22,6 +23,9 @@
#include "chrome/browser/sync/glue/data_type_controller.h"
#include "chrome/browser/sync/glue/data_type_manager.h"
#include "chrome/browser/sync/profile_sync_factory.h"
+#if defined(OS_WIN)
+#include "chrome/browser/views/options/customize_sync_window_view.h"
+#endif
#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_details.h"
#include "chrome/common/notification_service.h"
@@ -31,7 +35,6 @@
#include "chrome/common/time_format.h"
#include "grit/generated_resources.h"
#include "net/base/cookie_monster.h"
-#include "views/window/window.h"
using browser_sync::ChangeProcessor;
using browser_sync::DataTypeController;
@@ -98,6 +101,15 @@ void ProfileSyncService::RegisterDataTypeController(
data_type_controller;
}
+void ProfileSyncService::GetDataTypeControllerStates(
+ browser_sync::DataTypeController::StateMap* state_map) const {
+ browser_sync::DataTypeController::TypeMap::const_iterator iter
+ = data_type_controllers_.begin();
+ for ( ; iter != data_type_controllers_.end(); ++iter ) {
+ (*state_map)[iter->first] = iter->second.get()->state();
+ }
+}
+
void ProfileSyncService::InitSettings() {
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
@@ -132,6 +144,11 @@ void ProfileSyncService::RegisterPreferences() {
pref_service->RegisterInt64Pref(prefs::kSyncLastSyncedTime, 0);
pref_service->RegisterBooleanPref(prefs::kSyncHasSetupCompleted, false);
+ // If you've never synced before, all datatypes are on by default.
+ pref_service->RegisterBooleanPref(prefs::kSyncBookmarks, true);
+ pref_service->RegisterBooleanPref(prefs::kSyncPreferences, true);
+ pref_service->RegisterBooleanPref(prefs::kSyncAutofill, true);
+
// TODO(albertb): Consider getting rid of this preference once we have a UI
// for per-data type disabling.
if (bootstrap_sync_authentication_ &&
@@ -386,6 +403,14 @@ string16 ProfileSyncService::GetAuthenticatedUsername() const {
return backend_->GetAuthenticatedUsername();
}
+void ProfileSyncService::OnUserClickedCustomize() {
+ // This is coming from the gaia_login, so set configure_on_accept=false
+ // (because when the user accepts, he/she will not have signed in yet).
+#if defined(OS_WIN)
+ CustomizeSyncWindowView::Show(NULL, profile_, false);
+#endif
+}
+
void ProfileSyncService::OnUserSubmittedAuth(
const std::string& username, const std::string& password,
const std::string& captcha) {
@@ -397,14 +422,9 @@ void ProfileSyncService::OnUserSubmittedAuth(
backend_->Authenticate(username, password, captcha);
}
-void ProfileSyncService::OnUserAcceptedMergeAndSync() {
- // TODO(skrul): Remove this.
- NOTREACHED();
-}
-
void ProfileSyncService::OnUserCancelledDialog() {
if (!profile_->GetPrefs()->GetBoolean(prefs::kSyncHasSetupCompleted)) {
- // A sync dialog was aborted before authentication or merge acceptance.
+ // A sync dialog was aborted before authentication.
// Rollback.
DisableForUser();
}
@@ -412,11 +432,14 @@ void ProfileSyncService::OnUserCancelledDialog() {
FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged());
}
+void ProfileSyncService::ChangeDataTypes(
+ const browser_sync::DataTypeManager::TypeSet& desired_types) {
+ data_type_manager_->Configure(desired_types);
+}
+
void ProfileSyncService::StartProcessingChangesIfReady() {
DCHECK(backend_initialized_);
- // If we're running inside Chromium OS, always allow merges and
- // consider the sync setup complete.
if (bootstrap_sync_authentication_) {
SetSyncSetupCompleted();
}
diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h
index 283c4bd..a79440c 100644
--- a/chrome/browser/sync/profile_sync_service.h
+++ b/chrome/browser/sync/profile_sync_service.h
@@ -63,17 +63,15 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
START_FROM_OPTIONS = 3, // Sync was started from Wrench->Options.
START_FROM_BOOKMARK_MANAGER = 4, // Sync was started from Bookmark manager.
- // Events regarding cancelation of the signon process of sync.
+ // Events regarding cancellation of the signon process of sync.
CANCEL_FROM_SIGNON_WITHOUT_AUTH = 10, // Cancelled before submitting
// username and password.
CANCEL_DURING_SIGNON = 11, // Cancelled after auth.
- CANCEL_DURING_SIGNON_AFTER_MERGE = 12, // Cancelled during merge.
// Events resulting in the stoppage of sync service.
STOP_FROM_OPTIONS = 20, // Sync was stopped from Wrench->Options.
// Miscellaneous events caused by sync service.
- MERGE_AND_SYNC_NEEDED = 30,
MAX_SYNC_EVENT_CODE
};
@@ -94,10 +92,10 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
void RegisterDataTypeController(
browser_sync::DataTypeController* data_type_controller);
- const browser_sync::DataTypeController::TypeMap& data_type_controllers()
- const {
- return data_type_controllers_;
- }
+ // Fills state_map with a map of current data types that are possible to
+ // sync, as well as their states.
+ void GetDataTypeControllerStates(
+ browser_sync::DataTypeController::StateMap* state_map) const;
// Enables/disables sync for user.
virtual void EnableForUser();
@@ -112,15 +110,15 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
virtual void OnSyncCycleCompleted();
virtual void OnAuthError();
+ // Called when a user clicks the "customize" button while setting up sync.
+ virtual void OnUserClickedCustomize();
+
// Called when a user enters credentials through UI.
virtual void OnUserSubmittedAuth(const std::string& username,
const std::string& password,
const std::string& captcha);
- // Called when a user decides whether to merge and sync or abort.
- virtual void OnUserAcceptedMergeAndSync();
-
- // Called when a user cancels any setup dialog (login, merge and sync, etc).
+ // Called when a user cancels any setup dialog (login, etc).
virtual void OnUserCancelledDialog();
// Get various information for displaying in the user interface.
@@ -214,6 +212,10 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
const NotificationSource& source,
const NotificationDetails& details);
+ // Changes which data types we're going to be syncing to |desired_types|.
+ virtual void ChangeDataTypes(
+ const browser_sync::DataTypeManager::TypeSet& desired_types);
+
protected:
// Call this after any of the subsystems being synced (the bookmark
// model and the sync backend) finishes its initialization. When everything
diff --git a/chrome/browser/sync/resources/gaia_login.html b/chrome/browser/sync/resources/gaia_login.html
index b7bf63a..c9f410f 100755
--- a/chrome/browser/sync/resources/gaia_login.html
+++ b/chrome/browser/sync/resources/gaia_login.html
@@ -1,7 +1,7 @@
<html i18n-values="dir:textdirection;">
<style type="text/css"><!--
body,td,div,p,a,font,span {font-family: arial,sans-serif;}
- body { bgcolor:"#ffffff" }
+ body { background-color:#ffffff }
A:link {color:#0000cc; }
A:visited { color:#551a8b; }
A:active { color:#ff0000; }
@@ -145,6 +145,10 @@
showCaptcha(args);
}
document.getElementById("signIn").disabled = false;
+ if (args.showCustomize) {
+ document.getElementById("customize").disabled = false;
+ document.getElementById("customize").style.visibility = "visible";
+ }
gaia_setFocus();
}
@@ -173,9 +177,14 @@
}
function CloseDialog() {
+ chrome.send("ClickCustomizeCancel", [""]);
chrome.send("DialogClose", [""]);
}
+ function showCustomize() {
+ chrome.send("ShowCustomize", [""]);
+ }
+
function showGaiaSuccessAndClose() {
document.getElementById("signIn").value = templateData['success'];
setTimeout(CloseDialog, 1600);
@@ -206,12 +215,17 @@
}
function sendCredentialsAndClose() {
+
+ chrome.send("ClickCustomizeOk", [""]);
if (!setErrorVisibility())
return false;
document.getElementById('Email').disabled = true;
document.getElementById('Passwd').disabled = true;
document.getElementById('CaptchaValue').disabled = true;
+ if (document.getElementById('customize')) {
+ document.getElementById('customize').disabled = true;
+ }
var throbber = document.getElementById('throbber_container');
throbber.style.display = "inline";
var f = document.getElementById("gaia_loginform");
@@ -475,8 +489,11 @@
</tr>
</table>
<div class="endaligned">
+ <input id="customize" type="button" name="customize"
+ i18n-values="value:customize" onclick="showCustomize();"
+ style="width:150;visibility:hidden" disabled="disabled">
<input type="button" name="cancel" i18n-values="value:cancel"
- onclick="CloseDialog();" style="width:85" />
+ onclick="CloseDialog();" style="width:85">
</div>
</body>
</html>
diff --git a/chrome/browser/sync/resources/merge_and_sync.html b/chrome/browser/sync/resources/merge_and_sync.html
deleted file mode 100644
index 38dd2cd..0000000
--- a/chrome/browser/sync/resources/merge_and_sync.html
+++ /dev/null
@@ -1,95 +0,0 @@
-<html i18n-values="dir:textdirection;">
-<head>
-<title></title>
-<style type="text/css">
- body,td,div,p,a,font,span {font-family: arial,sans-serif;}
- body { bgcolor:"#ffffff" }
-.gaia.le.button { font-family: Arial, Helvetica, sans-serif; font-size: smaller; }
-.endaligned {
- text-align: right;
-}
-html[dir='rtl'] .endaligned {
- text-align: left;
-}
-.textaligned {
- text-align: left;
-}
-html[dir='rtl'] .textaligned {
- text-align: right;
-}
-</style>
-<script>
- function advanceThrobber() {
- var throbber = document.getElementById('throb');
- throbber.style.backgroundPositionX =
- ((parseInt(throbber.style.backgroundPositionX) - 16) % 576) + 'px';
- }
-
- function acceptMergeAndSync() {
- var throbber = document.getElementById('throbber_container');
- throbber.style.display = "inline";
- document.getElementById("acceptMerge").disabled = true;
- chrome.send("SubmitMergeAndSync", [""]);
- }
-
- function Close() {
- chrome.send("DialogClose", [""]);
- }
-
- function showMergeAndSyncDone() {
- var throbber = document.getElementById('throbber_container');
- throbber.style.display = "none";
- document.getElementById("header").innerHTML =
- "<p><font size='-1'><b>" + templateData['alldone']
- + "</b></font></p>";
- document.getElementById("close").value = templateData['closelabel'];
- setTimeout(Close, 1600);
- }
-
- function showMergeAndSyncError() {
- var throbber = document.getElementById('throbber_container');
- throbber.style.display = "none";
- document.getElementById("header").innerHTML =
- "<p><font size='-1'><b>" + templateData['setuperror']
- + "</b></font></p>";
- }
-
- function onPageShown() {
- document.getElementById("acceptMerge").focus();
- }
-
-</script>
-</head>
-<body onload="setInterval(advanceThrobber, 30);">
-<table height="100%">
- <tr valign="top">
- <td align="center">
- <div id="header" align="left">
- <p class="textaligned"><font size="-1"><b>
- <span i18n-content="introduction"></span>
- </b></font></p>
- </div>
- <br />
- <img src="merge_and_sync.png" i18n-values="alt:mergeandsynclabel" />
- <br />
- <p class="textaligned"><font size="-1"><span i18n-content="mergeandsyncwarning"></span></font></p>
- <br />
- <div id="throbber_container" style="display:none">
- <div id="throb" style="background-image:url(throbber.png);
- width:16px; height:16px; background-position:0px;">
- </div>
- </div>
- </td>
- </tr>
- <tr class="endaligned" valign="bottom">
- <td class="endaligned">
- <input id="acceptMerge" type="button" class="gaia le button" name="accept"
- i18n-values="value:mergeandsynclabel"
- onclick="acceptMergeAndSync();" />
- <input id="close" type="button" i18n-values="value:abortlabel"
- onclick="Close();"/>
- </td>
- </tr>
-</table>
-</body>
-</html>
diff --git a/chrome/browser/sync/resources/setup_flow.html b/chrome/browser/sync/resources/setup_flow.html
index 3601f76..258e2cf 100644
--- a/chrome/browser/sync/resources/setup_flow.html
+++ b/chrome/browser/sync/resources/setup_flow.html
@@ -1,24 +1,17 @@
-<HTML id='t'>
-<HEAD>
-<TITLE></TITLE>
+<html id='t'>
+<head>
+<title></title>
<script>
- function showMergeAndSync() {
- document.getElementById("login").style.display = "none";
- document.getElementById("merge").style.display = "block";
- }
function showSetupDone() {
- document.getElementById("login").style.display = "none";
- document.getElementById("merge").style.display = "none";
- document.getElementById("done").style.display = "block";
+ document.getElementById('login').style.display = 'none';
+ document.getElementById('done').style.display = 'block';
}
</script>
-</HEAD>
-<BODY style="margin:0; border:0;">
+</head>
+<body style="margin:0; border:0;">
<iframe id="login" frameborder="0" width="100%" scrolling="no" height="100%"
src="chrome://syncresources/gaialogin"></iframe>
- <iframe id="merge" frameborder="0" width="100%" scrolling="no" height="100%"
- src="chrome://syncresources/mergeandsync" style="display:none"></iframe>
<iframe id="done" frameborder="0" width="100%" scrolling="no" height="100%"
src="chrome://syncresources/setupdone" style="display:none"></iframe>
-</BODY>
-</HTML>
+</body>
+</html>
diff --git a/chrome/browser/sync/sync_setup_flow.cc b/chrome/browser/sync/sync_setup_flow.cc
index 5da098f..12112a0 100644
--- a/chrome/browser/sync/sync_setup_flow.cc
+++ b/chrome/browser/sync/sync_setup_flow.cc
@@ -22,6 +22,7 @@
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/syncable/model_type.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/pref_names.h"
#include "gfx/font.h"
@@ -29,7 +30,6 @@
// 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.
@@ -55,10 +55,16 @@ static std::string GetJsonResponse(const Value* content) {
}
void FlowHandler::RegisterMessages() {
+#if defined(OS_WIN)
+ dom_ui_->RegisterMessageCallback("ShowCustomize",
+ NewCallback(this, &FlowHandler::HandleUserClickedCustomize));
+ dom_ui_->RegisterMessageCallback("ClickCustomizeOk",
+ NewCallback(this, &FlowHandler::ClickCustomizeOk));
+ dom_ui_->RegisterMessageCallback("ClickCustomizeCancel",
+ NewCallback(this, &FlowHandler::ClickCustomizeCancel));
+#endif
dom_ui_->RegisterMessageCallback("SubmitAuth",
NewCallback(this, &FlowHandler::HandleSubmitAuth));
- dom_ui_->RegisterMessageCallback("SubmitMergeAndSync",
- NewCallback(this, &FlowHandler::HandleSubmitMergeAndSync));
}
static bool GetAuthData(const std::string& json,
@@ -76,6 +82,23 @@ static bool GetAuthData(const std::string& json,
return true;
}
+void FlowHandler::HandleUserClickedCustomize(const Value* value) {
+ if (flow_)
+ flow_->OnUserClickedCustomize();
+}
+
+// To simulate the user clicking "OK" or "Cancel" on the Customize Sync dialog
+void FlowHandler::ClickCustomizeOk(const Value* value) {
+ if (flow_)
+ flow_->ClickCustomizeOk();
+}
+
+void FlowHandler::ClickCustomizeCancel(const Value* value) {
+ if (flow_)
+ flow_->ClickCustomizeCancel();
+}
+
+
void FlowHandler::HandleSubmitAuth(const Value* value) {
std::string json(GetJsonResponse(value));
std::string username, password, captcha;
@@ -93,11 +116,6 @@ void FlowHandler::HandleSubmitAuth(const Value* value) {
flow_->OnUserSubmittedAuth(username, password, captcha);
}
-void FlowHandler::HandleSubmitMergeAndSync(const Value* value) {
- if (flow_)
- flow_->OnUserAcceptedMergeAndSync();
-}
-
// Called by SyncSetupFlow::Advance.
void FlowHandler::ShowGaiaLogin(const DictionaryValue& args) {
std::string json;
@@ -116,14 +134,6 @@ void FlowHandler::ShowGaiaSuccessAndSettingUp() {
L"showGaiaSuccessAndSettingUp();");
}
-void FlowHandler::ShowMergeAndSync() {
- if (dom_ui_) { // NULL during testing.
- dom_ui_->CallJavascriptFunction(L"showMergeAndSync");
- }
- ExecuteJavascriptInIFrame(kMergeIFrameXPath,
- L"onPageShown();");
-}
-
void FlowHandler::ShowSetupDone(const std::wstring& user) {
StringValue synced_to_string(WideToUTF8(l10n_util::GetStringF(
IDS_SYNC_NTP_SYNCED_TO, user)));
@@ -146,10 +156,6 @@ void FlowHandler::ShowFirstTimeDone(const std::wstring& user) {
ShowSetupDone(user);
}
-void FlowHandler::ShowMergeAndSyncError() {
- ExecuteJavascriptInIFrame(kMergeIFrameXPath, L"showMergeAndSyncError();");
-}
-
void FlowHandler::ExecuteJavascriptInIFrame(const std::wstring& iframe_xpath,
const std::wstring& js) {
if (dom_ui_) {
@@ -227,10 +233,6 @@ void SyncSetupFlow::OnDialogClosed(const std::string& json_retval) {
ProfileSyncService::SyncEvent(
ProfileSyncService::CANCEL_DURING_SIGNON);
break;
- case SyncSetupWizard::MERGE_AND_SYNC:
- ProfileSyncService::SyncEvent(
- ProfileSyncService::CANCEL_DURING_SIGNON_AFTER_MERGE);
- break;
case SyncSetupWizard::DONE_FIRST_TIME:
case SyncSetupWizard::DONE:
UMA_HISTOGRAM_MEDIUM_TIMES("Sync.UserPerceivedAuthorizationTime",
@@ -258,6 +260,18 @@ void SyncSetupFlow::GetArgsForGaiaLogin(const ProfileSyncService* service,
}
args->SetString(L"captchaUrl", error.captcha().image_url.spec());
+
+ // TODO(dantasse) Remove this when multi-datatype sync is live.
+#if defined(OS_WIN)
+ browser_sync::DataTypeController::StateMap states;
+ browser_sync::DataTypeController::StateMap* controller_states = &states;
+ service->GetDataTypeControllerStates(controller_states);
+ args->SetBoolean(L"showCustomize",
+ controller_states->count(syncable::PREFERENCES) ||
+ controller_states->count(syncable::AUTOFILL));
+#else
+ args->SetBoolean(L"showCustomize", false);
+#endif
}
void SyncSetupFlow::GetDOMMessageHandlers(
@@ -274,14 +288,11 @@ bool SyncSetupFlow::ShouldAdvance(SyncSetupWizard::State state) {
return current_state_ == SyncSetupWizard::GAIA_LOGIN;
case SyncSetupWizard::GAIA_SUCCESS:
return current_state_ == SyncSetupWizard::GAIA_LOGIN;
- case SyncSetupWizard::MERGE_AND_SYNC:
- 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;
+ return current_state_ == SyncSetupWizard::GAIA_SUCCESS;
default:
NOTREACHED() << "Unhandled State: " << state;
return false;
@@ -304,12 +315,7 @@ void SyncSetupFlow::Advance(SyncSetupWizard::State advance_state) {
else
flow_handler_->ShowGaiaSuccessAndSettingUp();
break;
- case SyncSetupWizard::MERGE_AND_SYNC:
- flow_handler_->ShowMergeAndSync();
- break;
case SyncSetupWizard::FATAL_ERROR:
- if (current_state_ == SyncSetupWizard::MERGE_AND_SYNC)
- flow_handler_->ShowMergeAndSyncError();
break;
case SyncSetupWizard::DONE_FIRST_TIME:
flow_handler_->ShowFirstTimeDone(
diff --git a/chrome/browser/sync/sync_setup_flow.h b/chrome/browser/sync/sync_setup_flow.h
index 6dbc04f..12489fc 100644
--- a/chrome/browser/sync/sync_setup_flow.h
+++ b/chrome/browser/sync/sync_setup_flow.h
@@ -13,6 +13,9 @@
#include "chrome/browser/dom_ui/html_dialog_ui.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/sync_setup_wizard.h"
+#if defined(OS_WIN)
+#include "chrome/browser/views/options/customize_sync_window_view.h"
+#endif
#include "grit/generated_resources.h"
#include "testing/gtest/include/gtest/gtest_prod.h"
@@ -76,16 +79,29 @@ class SyncSetupFlow : public HtmlDialogUIDelegate {
return false;
}
+ void OnUserClickedCustomize() {
+ service_->OnUserClickedCustomize();
+ }
+
+ void ClickCustomizeOk() {
+#if defined(OS_WIN)
+ CustomizeSyncWindowView::ClickOk();
+#endif
+ }
+
+ void ClickCustomizeCancel() {
+#if defined(OS_WIN)
+ CustomizeSyncWindowView::ClickCancel();
+#endif
+ }
+
+
void OnUserSubmittedAuth(const std::string& username,
const std::string& password,
const std::string& captcha) {
service_->OnUserSubmittedAuth(username, password, captcha);
}
- void OnUserAcceptedMergeAndSync() {
- service_->OnUserAcceptedMergeAndSync();
- }
-
private:
FRIEND_TEST(SyncSetupWizardTest, InitialStepLogin);
FRIEND_TEST(SyncSetupWizardTest, InitialStepMergeAndSync);
@@ -154,6 +170,9 @@ class FlowHandler : public DOMMessageHandler {
virtual void RegisterMessages();
// Callbacks from the page.
+ void HandleUserClickedCustomize(const Value* value);
+ void ClickCustomizeOk(const Value* value);
+ void ClickCustomizeCancel(const Value* value);
void HandleSubmitAuth(const Value* value);
void HandleSubmitMergeAndSync(const Value* value);
@@ -161,8 +180,6 @@ class FlowHandler : public DOMMessageHandler {
void ShowGaiaLogin(const DictionaryValue& args);
void ShowGaiaSuccessAndClose();
void ShowGaiaSuccessAndSettingUp();
- void ShowMergeAndSync();
- void ShowMergeAndSyncError();
void ShowSetupDone(const std::wstring& user);
void ShowFirstTimeDone(const std::wstring& user);
diff --git a/chrome/browser/sync/sync_setup_wizard.cc b/chrome/browser/sync/sync_setup_wizard.cc
index 3afbff9b..660ac9f 100644
--- a/chrome/browser/sync/sync_setup_wizard.cc
+++ b/chrome/browser/sync/sync_setup_wizard.cc
@@ -20,6 +20,7 @@
#include "googleurl/src/gurl.h"
#include "grit/app_resources.h"
#include "grit/browser_resources.h"
+#include "grit/chromium_strings.h"
class SyncResourcesSource : public ChromeURLDataManager::DataSource {
public:
@@ -86,7 +87,8 @@ void SyncResourcesSource::StartDataRequest(const std::string& path_raw,
localized_strings.SetString(L"settingupsync",
l10n_util::GetString(IDS_SYNC_LOGIN_SETTING_UP_SYNC));
localized_strings.SetString(L"introduction",
- l10n_util::GetString(IDS_SYNC_LOGIN_INTRODUCTION));
+ l10n_util::GetStringF(IDS_SYNC_LOGIN_INTRODUCTION,
+ l10n_util::GetString(IDS_PRODUCT_NAME)));
localized_strings.SetString(L"signinprefix",
l10n_util::GetString(IDS_SYNC_LOGIN_SIGNIN_PREFIX));
localized_strings.SetString(L"signinsuffix",
@@ -109,6 +111,8 @@ void SyncResourcesSource::StartDataRequest(const std::string& path_raw,
l10n_util::GetString(IDS_SYNC_CREATE_ACCOUNT));
localized_strings.SetString(L"cancel",
l10n_util::GetString(IDS_CANCEL));
+ localized_strings.SetString(L"customize",
+ l10n_util::GetString(IDS_SYNC_LOGIN_CUSTOMIZE));
localized_strings.SetString(L"settingup",
l10n_util::GetString(IDS_SYNC_LOGIN_SETTING_UP));
localized_strings.SetString(L"success",
@@ -122,32 +126,13 @@ void SyncResourcesSource::StartDataRequest(const std::string& path_raw,
SetFontAndTextDirection(&localized_strings);
response = jstemplate_builder::GetI18nTemplateHtml(
html, &localized_strings);
- } else if (path_raw == chrome::kSyncMergeAndSyncPath) {
- DictionaryValue localized_strings;
- localized_strings.SetString(L"introduction",
- l10n_util::GetString(IDS_SYNC_MERGE_INTRODUCTION));
- localized_strings.SetString(L"mergeandsynclabel",
- l10n_util::GetString(IDS_SYNC_MERGE_AND_SYNC_LABEL));
- localized_strings.SetString(L"abortlabel",
- l10n_util::GetString(IDS_ABORT));
- localized_strings.SetString(L"closelabel",
- l10n_util::GetString(IDS_CLOSE));
- localized_strings.SetString(L"mergeandsyncwarning",
- l10n_util::GetString(IDS_SYNC_MERGE_WARNING));
- localized_strings.SetString(L"setuperror",
- l10n_util::GetString(IDS_SYNC_SETUP_ERROR));
-
- static const base::StringPiece html(ResourceBundle::GetSharedInstance()
- .GetRawDataResource(IDR_MERGE_AND_SYNC_HTML));
- 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));
+ l10n_util::GetStringF(IDS_SYNC_SETUP_ALL_DONE,
+ l10n_util::GetString(IDS_PRODUCT_NAME)));
localized_strings.SetString(L"firsttimesetupsummary",
l10n_util::GetString(IDS_SYNC_SETUP_FIRST_TIME_ALL_DONE));
localized_strings.SetString(L"okay",
diff --git a/chrome/browser/sync/sync_setup_wizard.h b/chrome/browser/sync/sync_setup_wizard.h
index 685b5f0..ad3c8e1 100644
--- a/chrome/browser/sync/sync_setup_wizard.h
+++ b/chrome/browser/sync/sync_setup_wizard.h
@@ -20,8 +20,6 @@ class SyncSetupWizard {
// 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,
diff --git a/chrome/browser/sync/sync_setup_wizard_unittest.cc b/chrome/browser/sync/sync_setup_wizard_unittest.cc
index 38cb614..645f365 100644
--- a/chrome/browser/sync/sync_setup_wizard_unittest.cc
+++ b/chrome/browser/sync/sync_setup_wizard_unittest.cc
@@ -231,7 +231,7 @@ TEST_F(SyncSetupWizardTest, InitialStepLogin) {
EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_);
dialog_args.Clear();
SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args);
- EXPECT_EQ(3U, dialog_args.size());
+ EXPECT_EQ(4U, dialog_args.size());
std::string actual_user;
dialog_args.GetString(L"user", &actual_user);
EXPECT_EQ(kTestUser, actual_user);
@@ -246,7 +246,7 @@ TEST_F(SyncSetupWizardTest, InitialStepLogin) {
service_->set_auth_state(kTestUser, captcha_error);
wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args);
- EXPECT_EQ(3U, dialog_args.size());
+ EXPECT_EQ(4U, dialog_args.size());
std::string captcha_url;
dialog_args.GetString(L"captchaUrl", &captcha_url);
EXPECT_EQ(kTestCaptchaUrl, GURL(captcha_url).spec());
@@ -268,35 +268,6 @@ TEST_F(SyncSetupWizardTest, InitialStepLogin) {
EXPECT_EQ(SyncSetupWizard::DONE, test_window_->flow()->current_state_);
}
-TEST_F(SyncSetupWizardTest, InitialStepMergeAndSync) {
- wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
- EXPECT_TRUE(wizard_->IsVisible());
- EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled());
- EXPECT_EQ(SyncSetupWizard::DONE, test_window_->flow()->end_state_);
-
- wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
- wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC);
- EXPECT_TRUE(wizard_->IsVisible());
- EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled());
- EXPECT_EQ(SyncSetupWizard::MERGE_AND_SYNC,
- test_window_->flow()->current_state_);
-
- test_window_->flow()->flow_handler_->HandleSubmitMergeAndSync(NULL);
- EXPECT_TRUE(wizard_->IsVisible());
- EXPECT_EQ(SyncSetupWizard::MERGE_AND_SYNC,
- test_window_->flow()->current_state_);
- EXPECT_EQ(std::string(), service_->username_);
- EXPECT_EQ(std::string(), service_->password_);
- EXPECT_TRUE(service_->user_accepted_merge_and_sync_);
- EXPECT_FALSE(service_->user_cancelled_dialog_);
- service_->ResetTestStats();
- wizard_->Step(SyncSetupWizard::DONE_FIRST_TIME); // No merge and sync.
- EXPECT_TRUE(wizard_->IsVisible());
- EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled());
- EXPECT_EQ(SyncSetupWizard::DONE_FIRST_TIME,
- test_window_->flow()->current_state_);
-}
-
TEST_F(SyncSetupWizardTest, DialogCancelled) {
wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
// Simulate the user closing the dialog.
@@ -313,7 +284,6 @@ TEST_F(SyncSetupWizardTest, DialogCancelled) {
wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled());
- wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC);
test_window_->CloseDialog();
EXPECT_FALSE(wizard_->IsVisible());
EXPECT_TRUE(service_->user_cancelled_dialog_);
@@ -336,8 +306,6 @@ TEST_F(SyncSetupWizardTest, InvalidTransitions) {
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_);
@@ -345,13 +313,6 @@ TEST_F(SyncSetupWizardTest, InvalidTransitions) {
EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_);
wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
- wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC);
- EXPECT_EQ(SyncSetupWizard::MERGE_AND_SYNC,
- test_window_->flow()->current_state_);
-
- wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
- EXPECT_EQ(SyncSetupWizard::MERGE_AND_SYNC,
- test_window_->flow()->current_state_);
wizard_->Step(SyncSetupWizard::FATAL_ERROR);
EXPECT_EQ(SyncSetupWizard::FATAL_ERROR, test_window_->flow()->current_state_);
@@ -360,7 +321,6 @@ TEST_F(SyncSetupWizardTest, InvalidTransitions) {
TEST_F(SyncSetupWizardTest, FullSuccessfulRunSetsPref) {
wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
- wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC);
wizard_->Step(SyncSetupWizard::DONE);
test_window_->CloseDialog();
EXPECT_FALSE(wizard_->IsVisible());
@@ -371,7 +331,6 @@ TEST_F(SyncSetupWizardTest, FullSuccessfulRunSetsPref) {
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());
@@ -384,7 +343,6 @@ TEST_F(SyncSetupWizardTest, DiscreteRun) {
// For a discrete run, we need to have ran through setup once.
wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
- wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC);
wizard_->Step(SyncSetupWizard::DONE);
test_window_->CloseDialog();
EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled());
@@ -397,7 +355,7 @@ TEST_F(SyncSetupWizardTest, DiscreteRun) {
wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
EXPECT_TRUE(wizard_->IsVisible());
SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args);
- EXPECT_EQ(3U, dialog_args.size());
+ EXPECT_EQ(4U, dialog_args.size());
std::string actual_user;
dialog_args.GetString(L"user", &actual_user);
EXPECT_EQ(kTestUser, actual_user);
diff --git a/chrome/browser/sync/sync_ui_util.cc b/chrome/browser/sync/sync_ui_util.cc
index a04bfe3..a72cc30 100644
--- a/chrome/browser/sync/sync_ui_util.cc
+++ b/chrome/browser/sync/sync_ui_util.cc
@@ -170,9 +170,9 @@ string16 GetSyncMenuLabel(ProfileSyncService* service) {
MessageType type = GetStatus(service);
if (type == sync_ui_util::SYNCED)
- return l10n_util::GetStringUTF16(IDS_SYNC_MENU_BOOKMARKS_SYNCED_LABEL);
+ return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNCED_LABEL);
else if (type == sync_ui_util::SYNC_ERROR)
- return l10n_util::GetStringUTF16(IDS_SYNC_MENU_BOOKMARK_SYNC_ERROR_LABEL);
+ return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNC_ERROR_LABEL);
else
return l10n_util::GetStringUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL);
}
diff --git a/chrome/browser/sync/sync_ui_util_mac.mm b/chrome/browser/sync/sync_ui_util_mac.mm
index 1612468..8aace0f 100644
--- a/chrome/browser/sync/sync_ui_util_mac.mm
+++ b/chrome/browser/sync/sync_ui_util_mac.mm
@@ -44,10 +44,10 @@ void UpdateSyncItemForStatus(id syncItem, BOOL syncEnabled,
int titleId;
switch (status) {
case sync_ui_util::SYNCED:
- titleId = IDS_SYNC_MENU_BOOKMARKS_SYNCED_LABEL;
+ titleId = IDS_SYNC_MENU_SYNCED_LABEL;
break;
case sync_ui_util::SYNC_ERROR:
- titleId = IDS_SYNC_MENU_BOOKMARK_SYNC_ERROR_LABEL;
+ titleId = IDS_SYNC_MENU_SYNC_ERROR_LABEL;
break;
case sync_ui_util::PRE_SYNCED:
titleId = IDS_SYNC_START_SYNC_BUTTON_LABEL;
diff --git a/chrome/browser/sync/sync_ui_util_mac_unittest.mm b/chrome/browser/sync/sync_ui_util_mac_unittest.mm
index ebe3bcc..14208c7 100644
--- a/chrome/browser/sync/sync_ui_util_mac_unittest.mm
+++ b/chrome/browser/sync/sync_ui_util_mac_unittest.mm
@@ -26,9 +26,9 @@ TEST_F(SyncStatusUIHelperMacTest, UpdateSyncItem) {
[syncMenuItem setTag:IDC_SYNC_BOOKMARKS];
NSString* bookmarksSynced =
- l10n_util::GetNSStringWithFixup(IDS_SYNC_MENU_BOOKMARKS_SYNCED_LABEL);
+ l10n_util::GetNSStringWithFixup(IDS_SYNC_MENU_SYNCED_LABEL);
NSString* bookmarkSyncError =
- l10n_util::GetNSStringWithFixup(IDS_SYNC_MENU_BOOKMARK_SYNC_ERROR_LABEL);
+ l10n_util::GetNSStringWithFixup(IDS_SYNC_MENU_SYNC_ERROR_LABEL);
NSString* startSync =
l10n_util::GetNSStringWithFixup(IDS_SYNC_START_SYNC_BUTTON_LABEL);
diff --git a/chrome/browser/views/options/content_page_view.cc b/chrome/browser/views/options/content_page_view.cc
index 3db7163..0f4467d 100644
--- a/chrome/browser/views/options/content_page_view.cc
+++ b/chrome/browser/views/options/content_page_view.cc
@@ -11,6 +11,8 @@
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
+#include "base/command_line.h"
+#include "base/string_util.h"
#include "chrome/browser/autofill/autofill_dialog.h"
#include "chrome/browser/autofill/personal_data_manager.h"
#include "chrome/browser/browser.h"
@@ -21,11 +23,14 @@
#include "chrome/browser/profile.h"
#include "chrome/browser/sync/sync_ui_util.h"
#include "chrome/browser/views/importer_view.h"
+#include "chrome/browser/views/options/customize_sync_window_view.h"
#include "chrome/browser/views/options/options_group_view.h"
#include "chrome/browser/views/options/passwords_exceptions_window_view.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "gfx/canvas.h"
#include "gfx/native_theme_win.h"
+#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
#include "views/controls/button/radio_button.h"
@@ -62,9 +67,10 @@ ContentPageView::ContentPageView(Profile* profile)
browsing_data_group_(NULL),
import_button_(NULL),
sync_group_(NULL),
- sync_status_label_(NULL),
sync_action_link_(NULL),
+ sync_status_label_(NULL),
sync_start_stop_button_(NULL),
+ sync_customize_button_(NULL),
sync_service_(NULL),
OptionsPageView(profile) {
if (profile->GetProfileSyncService()) {
@@ -133,7 +139,8 @@ void ContentPageView::ButtonPressed(
ConfirmMessageBoxDialog::RunWithCustomConfiguration(
GetWindow()->GetNativeWindow(),
this,
- l10n_util::GetString(IDS_SYNC_STOP_SYNCING_EXPLANATION_LABEL),
+ l10n_util::GetStringF(IDS_SYNC_STOP_SYNCING_EXPLANATION_LABEL,
+ l10n_util::GetString(IDS_PRODUCT_NAME)),
l10n_util::GetString(IDS_SYNC_STOP_SYNCING_BUTTON_LABEL),
l10n_util::GetString(IDS_SYNC_STOP_SYNCING_CONFIRM_BUTTON_LABEL),
l10n_util::GetString(IDS_CANCEL),
@@ -146,6 +153,16 @@ void ContentPageView::ButtonPressed(
ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_OPTIONS);
}
}
+#if defined(OS_WIN)
+ else if (sender == sync_customize_button_) {
+ // sync_customize_button_ should be invisible if sync is not yet set up.
+ DCHECK(sync_service_->HasSyncSetupCompleted());
+ // configure_on_accept = true because the user must have already logged in
+ // to be clicking this button here.
+ CustomizeSyncWindowView::Show(GetWindow()->GetNativeWindow(), profile(),
+ true);
+ }
+#endif
}
void ContentPageView::LinkActivated(views::Link* source, int event_flags) {
@@ -426,6 +443,9 @@ void ContentPageView::InitSyncGroup() {
sync_action_link_->SetController(this);
sync_start_stop_button_ = new views::NativeButton(this, std::wstring());
+#if defined(OS_WIN)
+ sync_customize_button_ = new views::NativeButton(this, std::wstring());
+#endif
using views::GridLayout;
using views::ColumnSet;
@@ -436,16 +456,30 @@ void ContentPageView::InitSyncGroup() {
const int single_column_view_set_id = 0;
ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id);
+ column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
+ GridLayout::USE_PREF, 0, 0);
+ column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
GridLayout::USE_PREF, 0, 0);
+
layout->StartRow(0, single_column_view_set_id);
- layout->AddView(sync_status_label_);
+ layout->AddView(sync_status_label_, 3, 1);
layout->StartRow(0, single_column_view_set_id);
- layout->AddView(sync_action_link_);
+ layout->AddView(sync_action_link_, 3, 1);
layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
layout->StartRow(0, single_column_view_set_id);
layout->AddView(sync_start_stop_button_);
+ // TODO (dantasse) Remove this big "if" when multi-datatype sync is live.
+#if defined(OS_WIN)
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableSyncPreferences) ||
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableSyncAutofill)) {
+ layout->AddView(sync_customize_button_);
+ }
+#endif
+
sync_group_ = new OptionsGroupView(contents,
l10n_util::GetString(IDS_SYNC_OPTIONS_GROUP_NAME), std::wstring(), true);
}
@@ -454,10 +488,13 @@ void ContentPageView::UpdateSyncControls() {
DCHECK(sync_service_);
std::wstring status_label;
std::wstring link_label;
+ std::wstring customize_button_label;
std::wstring button_label;
bool sync_setup_completed = sync_service_->HasSyncSetupCompleted();
bool status_has_error = sync_ui_util::GetStatusLabels(sync_service_,
&status_label, &link_label) == sync_ui_util::SYNC_ERROR;
+ customize_button_label =
+ l10n_util::GetString(IDS_SYNC_CUSTOMIZE_BUTTON_LABEL);
if (sync_setup_completed) {
button_label = l10n_util::GetString(IDS_SYNC_STOP_SYNCING_BUTTON_LABEL);
} else if (sync_service_->SetupInProgress()) {
@@ -469,8 +506,13 @@ void ContentPageView::UpdateSyncControls() {
sync_status_label_->SetText(status_label);
sync_start_stop_button_->SetEnabled(!sync_service_->WizardIsVisible());
sync_start_stop_button_->SetLabel(button_label);
+#if defined(OS_WIN)
+ sync_customize_button_->SetLabel(customize_button_label);
+ sync_customize_button_->SetVisible(sync_setup_completed);
+#endif
sync_action_link_->SetText(link_label);
sync_action_link_->SetVisible(!link_label.empty());
+
if (status_has_error) {
sync_status_label_->set_background(CreateErrorBackground());
sync_action_link_->set_background(CreateErrorBackground());
diff --git a/chrome/browser/views/options/content_page_view.h b/chrome/browser/views/options/content_page_view.h
index 9f5871b..c3f9817 100644
--- a/chrome/browser/views/options/content_page_view.h
+++ b/chrome/browser/views/options/content_page_view.h
@@ -101,6 +101,7 @@ class ContentPageView : public OptionsPageView,
views::Label* sync_status_label_;
views::Link* sync_action_link_;
views::NativeButton* sync_start_stop_button_;
+ views::NativeButton* sync_customize_button_;
BooleanPrefMember ask_to_save_passwords_;
BooleanPrefMember ask_to_save_form_autofill_;
diff --git a/chrome/browser/views/options/customize_sync_window_view.cc b/chrome/browser/views/options/customize_sync_window_view.cc
new file mode 100755
index 0000000..15638e9
--- /dev/null
+++ b/chrome/browser/views/options/customize_sync_window_view.cc
@@ -0,0 +1,231 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/pref_service.h"
+#include "chrome/browser/profile.h"
+#include "chrome/browser/sync/glue/data_type_controller.h"
+#include "chrome/browser/sync/glue/data_type_manager.h"
+#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/syncable/model_type.h"
+#include "chrome/browser/views/options/customize_sync_window_view.h"
+#include "chrome/common/pref_names.h"
+#include "app/l10n_util.h"
+#include "app/resource_bundle.h"
+#include "gfx/font.h"
+#include "grit/generated_resources.h"
+#include "grit/locale_settings.h"
+#include "views/controls/label.h"
+#include "views/controls/button/checkbox.h"
+#include "views/standard_layout.h"
+#include "views/window/window.h"
+
+// static
+CustomizeSyncWindowView* CustomizeSyncWindowView::instance_ = NULL;
+
+CustomizeSyncWindowView::CustomizeSyncWindowView(Profile* profile,
+ bool configure_on_accept)
+ : profile_(profile),
+ configure_on_accept_(configure_on_accept),
+ description_label_(NULL),
+ bookmarks_check_box_(NULL),
+ preferences_check_box_(NULL),
+ autofill_check_box_(NULL) {
+ DCHECK(profile);
+ Init();
+}
+
+// static
+void CustomizeSyncWindowView::Show(gfx::NativeWindow parent_window,
+ Profile* profile,
+ bool configure_on_accept) {
+ DCHECK(profile);
+ if (!instance_) {
+ instance_ = new CustomizeSyncWindowView(profile, configure_on_accept);
+
+ // |instance_| will get deleted once Close() is called.
+ views::Window::CreateChromeWindow(parent_window, gfx::Rect(), instance_);
+ }
+ if (!instance_->window()->IsVisible()) {
+ instance_->window()->Show();
+ } else {
+ instance_->window()->Activate();
+ }
+
+ instance_->configure_on_accept_ = configure_on_accept;
+}
+
+// static
+void CustomizeSyncWindowView::ClickOk() {
+ if (instance_) {
+ instance_->Accept();
+ instance_->window()->Close();
+ }
+}
+
+// Ideally this would do the same as when you click "cancel".
+// static
+void CustomizeSyncWindowView::ClickCancel() {
+ if (instance_) {
+ instance_->Cancel();
+ instance_->window()->Close();
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// CustomizeSyncWindowView, views::View implementations
+
+void CustomizeSyncWindowView::Layout() {
+ gfx::Size sz = description_label_->GetPreferredSize();
+ description_label_->SetBounds(kPanelHorizMargin, kPanelVertMargin,
+ sz.width(), sz.height());
+
+ sz = bookmarks_check_box_->GetPreferredSize();
+ bookmarks_check_box_->SetBounds(2 * kPanelHorizMargin,
+ description_label_->y() +
+ description_label_->height() +
+ kRelatedControlVerticalSpacing,
+ sz.width(), sz.height());
+
+ View* last_view = bookmarks_check_box_;
+ if (preferences_check_box_) {
+ sz = preferences_check_box_->GetPreferredSize();
+ preferences_check_box_->SetBounds(2 * kPanelHorizMargin,
+ last_view->y() +
+ last_view->height() +
+ kRelatedControlVerticalSpacing,
+ sz.width(), sz.height());
+ last_view = preferences_check_box_;
+ }
+
+ if (autofill_check_box_) {
+ sz = autofill_check_box_->GetPreferredSize();
+ autofill_check_box_->SetBounds(2 * kPanelHorizMargin,
+ last_view->y() +
+ last_view->height() +
+ kRelatedControlVerticalSpacing,
+ sz.width(), sz.height());
+ }
+}
+
+gfx::Size CustomizeSyncWindowView::GetPreferredSize() {
+ return gfx::Size(views::Window::GetLocalizedContentsSize(
+ IDS_CUSTOMIZE_SYNC_DIALOG_WIDTH_CHARS,
+ IDS_CUSTOMIZE_SYNC_DIALOG_HEIGHT_LINES));
+}
+
+void CustomizeSyncWindowView::ViewHierarchyChanged(
+ bool is_add, views::View* parent, views::View* child) {
+ if (is_add && child == this)
+ Init();
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// CustomizeSyncWindowView, views::DialogDelegate implementations
+
+bool CustomizeSyncWindowView::Accept() {
+ browser_sync::DataTypeManager::TypeSet desired_types;
+
+ profile_->GetPrefs()->SetBoolean(prefs::kSyncBookmarks,
+ bookmarks_check_box_->checked());
+ if (bookmarks_check_box_->checked()) {
+ desired_types.insert(syncable::BOOKMARKS);
+ }
+
+ if (preferences_check_box_) {
+ profile_->GetPrefs()->SetBoolean(prefs::kSyncPreferences,
+ preferences_check_box_->checked());
+ if (preferences_check_box_->checked()) {
+ desired_types.insert(syncable::PREFERENCES);
+ }
+ }
+ if (autofill_check_box_) {
+ profile_->GetPrefs()->SetBoolean(prefs::kSyncAutofill,
+ autofill_check_box_->checked());
+ if (autofill_check_box_->checked()) {
+ desired_types.insert(syncable::AUTOFILL);
+ }
+ }
+ profile_->GetPrefs()->ScheduleSavePersistentPrefs();
+
+ if (configure_on_accept_) {
+ profile_->GetProfileSyncService()->ChangeDataTypes(desired_types);
+ }
+ return true;
+}
+
+int CustomizeSyncWindowView::GetDialogButtons() const {
+ return MessageBoxFlags::DIALOGBUTTON_OK |
+ MessageBoxFlags::DIALOGBUTTON_CANCEL;
+}
+
+std::wstring CustomizeSyncWindowView::GetWindowTitle() const {
+ return l10n_util::GetString(IDS_CUSTOMIZE_SYNC_WINDOW_TITLE);
+}
+
+views::View* CustomizeSyncWindowView::GetContentsView() {
+ return this;
+}
+
+void CustomizeSyncWindowView::WindowClosing() {
+ // |instance_| is deleted once the window is closed, so we just have to set
+ // it to NULL.
+ instance_ = NULL;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// CustomizeSyncWindowView, private
+
+views::Checkbox* CustomizeSyncWindowView::AddCheckbox(const std::wstring& text,
+ bool checked) {
+ views::Checkbox* checkbox = new views::Checkbox(text);
+ checkbox->SetChecked(checked);
+ AddChildView(checkbox);
+ return checkbox;
+}
+
+void CustomizeSyncWindowView::Init() {
+ browser_sync::DataTypeController::StateMap states_obj;
+ browser_sync::DataTypeController::StateMap* controller_states = &states_obj;
+ profile_->GetProfileSyncService()->GetDataTypeControllerStates(
+ controller_states);
+
+ description_label_ = new views::Label();
+ description_label_->SetText(
+ l10n_util::GetString(IDS_CUSTOMIZE_SYNC_DESCRIPTION));
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ const gfx::Font& title_font =
+ rb.GetFont(ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD);
+ description_label_->SetFont(title_font);
+ AddChildView(description_label_);
+
+ // If the user hasn't set up sync yet, check the box (because all sync types
+ // should be on by default). If the user has, then check the box for a
+ // data type if that data type is already being synced.
+ if (controller_states->count(syncable::BOOKMARKS)) {
+ bool bookmarks_checked =
+ !configure_on_accept_ ||
+ controller_states->find(syncable::BOOKMARKS)->second
+ == browser_sync::DataTypeController::RUNNING;
+ bookmarks_check_box_ = AddCheckbox(
+ l10n_util::GetString(IDS_SYNC_DATATYPE_BOOKMARKS), bookmarks_checked);
+ }
+
+ if (controller_states->count(syncable::PREFERENCES)) {
+ bool prefs_checked =
+ !configure_on_accept_ ||
+ controller_states->find(syncable::PREFERENCES)->second
+ == browser_sync::DataTypeController::RUNNING;
+ preferences_check_box_ = AddCheckbox(
+ l10n_util::GetString(IDS_SYNC_DATATYPE_PREFERENCES), prefs_checked);
+ }
+
+ if (controller_states->count(syncable::AUTOFILL)) {
+ bool autofill_checked =
+ !configure_on_accept_ ||
+ controller_states->find(syncable::AUTOFILL)->second
+ == browser_sync::DataTypeController::RUNNING;
+ autofill_check_box_ = AddCheckbox(
+ l10n_util::GetString(IDS_SYNC_DATATYPE_AUTOFILL), autofill_checked);
+ }
+}
diff --git a/chrome/browser/views/options/customize_sync_window_view.h b/chrome/browser/views/options/customize_sync_window_view.h
new file mode 100755
index 0000000..61b36f9
--- /dev/null
+++ b/chrome/browser/views/options/customize_sync_window_view.h
@@ -0,0 +1,85 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_VIEWS_OPTIONS_CUSTOMIZE_SYNC_WINDOW_VIEW_H_
+#define CHROME_BROWSER_VIEWS_OPTIONS_CUSTOMIZE_SYNC_WINDOW_VIEW_H_
+
+#include "views/view.h"
+#include "views/window/dialog_delegate.h"
+#include "views/window/window.h"
+
+namespace views {
+class Checkbox;
+class Label;
+}
+
+class Profile;
+
+class CustomizeSyncWindowView : public views::View,
+ public views::DialogDelegate {
+ public:
+ explicit CustomizeSyncWindowView(Profile* profile, bool configure_on_accept);
+ virtual ~CustomizeSyncWindowView() {}
+
+ // Show the CustomizeSyncWindowView for the given profile. |parent_window| is
+ // optional.
+ // TODO(dantasse) when we make this window modal, |parent_window| will not be
+ // optional.
+ static void Show(gfx::NativeWindow parent_window, Profile* profile,
+ bool configure_on_accept);
+
+ // Simulate clicking the "OK" and "Cancel" buttons on the singleton dialog,
+ // if it exists.
+ static void ClickOk();
+ static void ClickCancel();
+
+ // views::View methods:
+ virtual void Layout();
+ virtual gfx::Size GetPreferredSize();
+ virtual void ViewHierarchyChanged(bool is_add, views::View* parent,
+ views::View* child);
+
+ // views::DialogDelegate methods:
+ virtual bool Accept();
+ virtual int GetDialogButtons() const;
+ virtual bool CanResize() const { return false; }
+ virtual bool CanMaximize() const { return false; }
+ virtual bool IsAlwaysOnTop() const { return false; }
+ virtual bool HasAlwaysOnTopMenu() const { return false; }
+ virtual std::wstring GetWindowTitle() const;
+ // TODO(dantasse) make this gaia-dialog-modal by overriding IsModal() when
+ // we replace the HTML sync setup wizard with more native dialogs.
+ virtual void WindowClosing();
+ virtual views::View* GetContentsView();
+
+ private:
+ // Initialize the controls on the dialog.
+ void Init();
+
+ // Adds a new check-box as a child to the view.
+ views::Checkbox* AddCheckbox(const std::wstring& text, bool checked);
+
+ views::Label* description_label_;
+ views::Checkbox* bookmarks_check_box_;
+ views::Checkbox* preferences_check_box_;
+ views::Checkbox* autofill_check_box_;
+
+ // If true, the user's already been syncing, so they're just changing
+ // which datatypes they're syncing. So we configure the DataTypeManager
+ // when the user clicks OK.
+ // If false, the user hasn't configured sync yet (because he/she has come to
+ // this dialog from the sync setup wizard/gaia_login.html). Thus, we don't
+ // configure the DataTypeManager immediately when the user clicks Ok.
+ // Either way, the selected data types will be stored to Preferences.
+ bool configure_on_accept_;
+
+ Profile* profile_;
+
+ // Singleton instance of this class.
+ static CustomizeSyncWindowView* instance_;
+
+ DISALLOW_COPY_AND_ASSIGN(CustomizeSyncWindowView);
+};
+
+#endif // CHROME_BROWSER_VIEWS_OPTIONS_CUSTOMIZE_SYNC_WINDOW_VIEW_H_
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index ecf21dd..de4379b 100755
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -2270,6 +2270,8 @@
'browser/views/options/cookie_filter_page_view.h',
'browser/views/options/cookies_view.cc',
'browser/views/options/cookies_view.h',
+ 'browser/views/options/customize_sync_window_view.cc',
+ 'browser/views/options/customize_sync_window_view.h',
'browser/views/options/exception_editor_view.cc',
'browser/views/options/exception_editor_view.h',
'browser/views/options/exceptions_view.cc',
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index fc65d58..ad7efad 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -690,6 +690,12 @@ const wchar_t kSyncLastSyncedTime[] = L"sync.last_synced_time";
// Boolean specifying whether the user finished setting up sync.
const wchar_t kSyncHasSetupCompleted[] = L"sync.has_setup_completed";
+// Booleans specifying whether the user has selected to sync the following
+// datatypes.
+const wchar_t kSyncBookmarks[] = L"sync.bookmarks";
+const wchar_t kSyncPreferences[] = L"sync.preferences";
+const wchar_t kSyncAutofill[] = L"sync.autofill";
+
// Whether sync auth was bootstrapped for Chrome OS.
const wchar_t kSyncBootstrappedAuth[] = L"sync.bootstrapped_auth";
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 21cf129..9bd65cd 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -251,6 +251,9 @@ extern const wchar_t kDevToolsSplitLocation[];
extern const wchar_t kSyncLastSyncedTime[];
extern const wchar_t kSyncHasSetupCompleted[];
+extern const wchar_t kSyncBookmarks[];
+extern const wchar_t kSyncPreferences[];
+extern const wchar_t kSyncAutofill[];
extern const wchar_t kSyncBootstrappedAuth[];
extern const wchar_t kWebAppCreateOnDesktop[];