diff options
author | nick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-02 02:58:05 +0000 |
---|---|---|
committer | nick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-02 02:58:05 +0000 |
commit | a1c2aef665b4abc30bbd6e2f8af5d5e68fc49eb4 (patch) | |
tree | 3cb23a152fb2363d24b3f8e6218a4e0349df9506 /chrome/browser/gtk | |
parent | d2cf4787e75a7f0f431dede5a86e77f275148e1b (diff) | |
download | chromium_src-a1c2aef665b4abc30bbd6e2f8af5d5e68fc49eb4.zip chromium_src-a1c2aef665b4abc30bbd6e2f8af5d5e68fc49eb4.tar.gz chromium_src-a1c2aef665b4abc30bbd6e2f8af5d5e68fc49eb4.tar.bz2 |
Move enable/disable storage to prefs.
The ProfileSyncService will manage the enabled/disabled types. Remove
CustomizeSyncWindowView's DataTypeManager dependency; it should really
just be operating on the preferences via the ProfileSyncService.
Clarify the difference between types being enabled (meaning the user
wants to sync them) versus being advertisable (meaning we support the
datatype, and advertise that the user has the option of syncing it).
BUG=34209,38340
TEST=After syncing, open the options dialog and recustomize your
options. Verify that the enabled types from the wizard match the
initial state of the options window. After changing the options and
hitting "accept", observe that a breakpoint in DTM::Configure gets
triggered, with exactly the new configuration set. Verify that the
preferences are preserved on restart, as well as across Stop
Syncing / Start Syncing.
Review URL: http://codereview.chromium.org/1556009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43440 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/options/content_page_gtk.cc | 4 | ||||
-rw-r--r-- | chrome/browser/gtk/options/customize_sync_window_gtk.cc | 69 | ||||
-rw-r--r-- | chrome/browser/gtk/options/customize_sync_window_gtk.h | 2 |
3 files changed, 24 insertions, 51 deletions
diff --git a/chrome/browser/gtk/options/content_page_gtk.cc b/chrome/browser/gtk/options/content_page_gtk.cc index 9c1e133..62ef19e 100644 --- a/chrome/browser/gtk/options/content_page_gtk.cc +++ b/chrome/browser/gtk/options/content_page_gtk.cc @@ -599,9 +599,7 @@ void ContentPageGtk::OnSyncStartStopButtonClicked(GtkWidget* widget) { void ContentPageGtk::OnSyncCustomizeButtonClicked(GtkWidget* widget) { // 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. - ShowCustomizeSyncWindow(profile(), true); + ShowCustomizeSyncWindow(profile()); } void ContentPageGtk::OnSyncActionLinkClicked(GtkWidget* widget) { diff --git a/chrome/browser/gtk/options/customize_sync_window_gtk.cc b/chrome/browser/gtk/options/customize_sync_window_gtk.cc index 3936fbf..9f1bf38 100644 --- a/chrome/browser/gtk/options/customize_sync_window_gtk.cc +++ b/chrome/browser/gtk/options/customize_sync_window_gtk.cc @@ -30,13 +30,10 @@ class CustomizeSyncWindowGtk { public: - CustomizeSyncWindowGtk(Profile* profile, bool configure_on_accept); + explicit CustomizeSyncWindowGtk(Profile* profile); ~CustomizeSyncWindowGtk(); void Show(); - void SetConfigureOnAccept(bool configure_on_accept) { - configure_on_accept_ = configure_on_accept; - } void ClickOk(); void ClickCancel(); @@ -58,7 +55,6 @@ class CustomizeSyncWindowGtk { Profile* profile_; - bool configure_on_accept_; GtkWidget* autofill_check_box_; GtkWidget* bookmarks_check_box_; GtkWidget* preferences_check_box_; @@ -75,17 +71,15 @@ static CustomizeSyncWindowGtk* customize_sync_window = NULL; /////////////////////////////////////////////////////////////////////////////// // CustomizeSyncWindowGtk, public: -CustomizeSyncWindowGtk::CustomizeSyncWindowGtk(Profile* profile, - bool configure_on_accept) +CustomizeSyncWindowGtk::CustomizeSyncWindowGtk(Profile* profile) : profile_(profile), - configure_on_accept_(configure_on_accept), autofill_check_box_(NULL), bookmarks_check_box_(NULL), preferences_check_box_(NULL) { - browser_sync::DataTypeController::StateMap states_obj; - browser_sync::DataTypeController::StateMap* controller_states = &states_obj; - profile_->GetProfileSyncService()->GetDataTypeControllerStates( - controller_states); + syncable::ModelTypeSet registered_types; + profile_->GetProfileSyncService()->GetRegisteredDataTypes(®istered_types); + syncable::ModelTypeSet preferred_types; + profile_->GetProfileSyncService()->GetPreferredDataTypes(&preferred_types); std::string dialog_name = l10n_util::GetStringUTF8( IDS_CUSTOMIZE_SYNC_WINDOW_TITLE); @@ -107,31 +101,21 @@ CustomizeSyncWindowGtk::CustomizeSyncWindowGtk(Profile* profile, dialog_, profile)); accessible_widget_helper_->SendOpenWindowNotification(dialog_name); - 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(GTK_DIALOG(dialog_)->vbox, - IDS_SYNC_DATATYPE_BOOKMARKS, - bookmarks_checked); - } + DCHECK(registered_types.count(syncable::BOOKMARKS)); + bool bookmarks_checked = preferred_types.count(syncable::BOOKMARKS) != 0; + bookmarks_check_box_ = AddCheckbox(GTK_DIALOG(dialog_)->vbox, + 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; + if (registered_types.count(syncable::PREFERENCES)) { + bool prefs_checked = preferred_types.count(syncable::PREFERENCES) != 0; preferences_check_box_ = AddCheckbox(GTK_DIALOG(dialog_)->vbox, 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; + if (registered_types.count(syncable::AUTOFILL)) { + bool autofill_checked = preferred_types.count(syncable::AUTOFILL) != 0; autofill_check_box_ = AddCheckbox(GTK_DIALOG(dialog_)->vbox, IDS_SYNC_DATATYPE_AUTOFILL, autofill_checked); @@ -188,37 +172,30 @@ GtkWidget* CustomizeSyncWindowGtk::AddCheckbox(GtkWidget* parent, int label_id, } bool CustomizeSyncWindowGtk::Accept() { - browser_sync::DataTypeManager::TypeSet desired_types; + syncable::ModelTypeSet preferred_types; bool bookmarks_enabled = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(bookmarks_check_box_)); - profile_->GetPrefs()->SetBoolean(prefs::kSyncBookmarks, bookmarks_enabled); if (bookmarks_enabled) { - desired_types.insert(syncable::BOOKMARKS); + preferred_types.insert(syncable::BOOKMARKS); } if (preferences_check_box_) { bool preferences_enabled = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(preferences_check_box_)); - profile_->GetPrefs()->SetBoolean(prefs::kSyncPreferences, - preferences_enabled); if (preferences_enabled) { - desired_types.insert(syncable::PREFERENCES); + preferred_types.insert(syncable::PREFERENCES); } } if (autofill_check_box_) { bool autofill_enabled = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(autofill_check_box_)); - profile_->GetPrefs()->SetBoolean(prefs::kSyncAutofill, autofill_enabled); if (autofill_enabled) { - desired_types.insert(syncable::AUTOFILL); + preferred_types.insert(syncable::AUTOFILL); } } - profile_->GetPrefs()->ScheduleSavePersistentPrefs(); - if (configure_on_accept_) { - profile_->GetProfileSyncService()->ChangeDataTypes(desired_types); - } + profile_->GetProfileSyncService()->ChangePreferredDataTypes(preferred_types); return true; } @@ -243,15 +220,13 @@ void CustomizeSyncWindowGtk::OnResponse( /////////////////////////////////////////////////////////////////////////////// // Factory/finder method: -void ShowCustomizeSyncWindow(Profile* profile, bool configure_on_accept) { +void ShowCustomizeSyncWindow(Profile* profile) { DCHECK(profile); // If there's already an existing window, use it. if (!customize_sync_window) { - customize_sync_window = new CustomizeSyncWindowGtk(profile, - configure_on_accept); + customize_sync_window = new CustomizeSyncWindowGtk(profile); } customize_sync_window->Show(); - customize_sync_window->SetConfigureOnAccept(configure_on_accept); } void CustomizeSyncWindowOk() { diff --git a/chrome/browser/gtk/options/customize_sync_window_gtk.h b/chrome/browser/gtk/options/customize_sync_window_gtk.h index 52c74da..f1e3c2b 100644 --- a/chrome/browser/gtk/options/customize_sync_window_gtk.h +++ b/chrome/browser/gtk/options/customize_sync_window_gtk.h @@ -7,7 +7,7 @@ class Profile; -void ShowCustomizeSyncWindow(Profile* profile, bool configure_on_accept); +void ShowCustomizeSyncWindow(Profile* profile); void CustomizeSyncWindowOk(); void CustomizeSyncWindowCancel(); |