summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorskrul@chromium.org <skrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-23 21:06:46 +0000
committerskrul@chromium.org <skrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-23 21:06:46 +0000
commit9ad84b9c3279c033e173f88005a44177b2e3be7c (patch)
tree8b1d3190a78ad8e0c45161f470706fe0c01eec58
parente7a5cd23ed66532d025ac6f1628d9d1f8cad0621 (diff)
downloadchromium_src-9ad84b9c3279c033e173f88005a44177b2e3be7c.zip
chromium_src-9ad84b9c3279c033e173f88005a44177b2e3be7c.tar.gz
chromium_src-9ad84b9c3279c033e173f88005a44177b2e3be7c.tar.bz2
Surface the "Set up sync" button on ChromiumOS when sync is stopped permanently.
BUG=49402 Review URL: http://codereview.chromium.org/3041016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53527 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/gtk/options/content_page_gtk.cc46
-rw-r--r--chrome/browser/gtk/options/content_page_gtk.h2
-rw-r--r--chrome/browser/sync/profile_sync_service.cc17
-rw-r--r--chrome/browser/sync/profile_sync_service.h5
-rw-r--r--chrome/common/pref_names.cc4
-rw-r--r--chrome/common/pref_names.h1
6 files changed, 51 insertions, 24 deletions
diff --git a/chrome/browser/gtk/options/content_page_gtk.cc b/chrome/browser/gtk/options/content_page_gtk.cc
index 1532e2c..a660795 100644
--- a/chrome/browser/gtk/options/content_page_gtk.cc
+++ b/chrome/browser/gtk/options/content_page_gtk.cc
@@ -75,8 +75,8 @@ ContentPageGtk::ContentPageGtk(Profile* profile)
#if !defined(OS_CHROMEOS)
sync_action_link_background_(NULL),
sync_action_link_(NULL),
- sync_start_stop_button_(NULL),
#endif
+ sync_start_stop_button_(NULL),
sync_customize_button_(NULL),
privacy_dashboard_link_(NULL),
initializing_(true),
@@ -112,11 +112,9 @@ ContentPageGtk::ContentPageGtk(Profile* profile)
options_builder->AddOptionGroup(
l10n_util::GetStringUTF8(IDS_AUTOFILL_SETTING_WINDOWS_GROUP_NAME),
InitFormAutoFillGroup(), false);
-#if !defined(OS_CHROMEOS)
options_builder->AddOptionGroup(
l10n_util::GetStringUTF8(IDS_OPTIONS_BROWSING_DATA_GROUP_NAME),
InitBrowsingDataGroup(), false);
-#endif
options_builder->AddOptionGroup(
l10n_util::GetStringUTF8(IDS_APPEARANCE_GROUP_NAME),
InitThemesGroup(), false);
@@ -358,13 +356,11 @@ GtkWidget* ContentPageGtk::InitSyncGroup() {
// depend on the spacing above.
GtkWidget* button_hbox = gtk_hbox_new(FALSE, gtk_util::kLabelSpacing);
gtk_container_add(GTK_CONTAINER(vbox), button_hbox);
-#if !defined(OS_CHROMEOS)
sync_start_stop_button_ = gtk_button_new_with_label("");
g_signal_connect(sync_start_stop_button_, "clicked",
G_CALLBACK(OnSyncStartStopButtonClickedThunk), this);
gtk_box_pack_start(GTK_BOX(button_hbox), sync_start_stop_button_, FALSE,
FALSE, 0);
-#endif
sync_customize_button_ = gtk_button_new_with_label("");
g_signal_connect(sync_customize_button_, "clicked",
G_CALLBACK(OnSyncCustomizeButtonClickedThunk), this);
@@ -399,29 +395,49 @@ void ContentPageGtk::UpdateSyncControls() {
string16 status_label;
string16 link_label;
std::string customize_button_label;
- std::string button_label;
bool managed = sync_service_->IsManaged();
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::GetStringUTF8(IDS_SYNC_CUSTOMIZE_BUTTON_LABEL);
+
+ std::string start_stop_button_label;
+ bool is_start_stop_button_visible = false;
+ bool is_start_stop_button_sensitive = false;
if (sync_setup_completed) {
- button_label = l10n_util::GetStringUTF8(IDS_SYNC_STOP_SYNCING_BUTTON_LABEL);
+ start_stop_button_label =
+ l10n_util::GetStringUTF8(IDS_SYNC_STOP_SYNCING_BUTTON_LABEL);
+#if defined(OS_CHROMEOS)
+ is_start_stop_button_visible = false;
+#else
+ is_start_stop_button_visible = true;
+#endif
+ is_start_stop_button_sensitive = !managed;
} else if (sync_service_->SetupInProgress()) {
- button_label = l10n_util::GetStringUTF8(IDS_SYNC_NTP_SETUP_IN_PROGRESS);
+ start_stop_button_label =
+ l10n_util::GetStringUTF8(IDS_SYNC_NTP_SETUP_IN_PROGRESS);
+ is_start_stop_button_visible = true;
+ is_start_stop_button_sensitive = false;
} else {
- button_label = l10n_util::GetStringUTF8(IDS_SYNC_START_SYNC_BUTTON_LABEL);
+ start_stop_button_label =
+ l10n_util::GetStringUTF8(IDS_SYNC_START_SYNC_BUTTON_LABEL);
+ is_start_stop_button_visible = true;
+ is_start_stop_button_sensitive = !managed;
}
+ gtk_widget_set_no_show_all(sync_start_stop_button_,
+ !is_start_stop_button_visible);
+ if (is_start_stop_button_visible)
+ gtk_widget_show(sync_start_stop_button_);
+ else
+ gtk_widget_hide(sync_start_stop_button_);
+ gtk_widget_set_sensitive(sync_start_stop_button_,
+ is_start_stop_button_sensitive);
+ gtk_button_set_label(GTK_BUTTON(sync_start_stop_button_),
+ start_stop_button_label.c_str());
gtk_label_set_label(GTK_LABEL(sync_status_label_),
UTF16ToUTF8(status_label).c_str());
-#if !defined(OS_CHROMEOS)
- gtk_widget_set_sensitive(sync_start_stop_button_,
- !sync_service_->WizardIsVisible() && !managed);
- gtk_button_set_label(GTK_BUTTON(sync_start_stop_button_),
- button_label.c_str());
-#endif
gtk_widget_set_child_visible(sync_customize_button_,
sync_setup_completed && !status_has_error);
diff --git a/chrome/browser/gtk/options/content_page_gtk.h b/chrome/browser/gtk/options/content_page_gtk.h
index f7239e0..2489959 100644
--- a/chrome/browser/gtk/options/content_page_gtk.h
+++ b/chrome/browser/gtk/options/content_page_gtk.h
@@ -81,9 +81,7 @@ class ContentPageGtk : public OptionsPageBase,
GtkWidget* sync_status_label_;
GtkWidget* sync_action_link_background_;
GtkWidget* sync_action_link_;
-#if !defined(OS_CHROMEOS)
GtkWidget* sync_start_stop_button_;
-#endif
GtkWidget* sync_customize_button_;
GtkWidget* privacy_dashboard_link_;
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 2b9098b..ce3d7e4 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -144,7 +144,8 @@ void ProfileSyncService::Initialize() {
DisableForUser(); // Clean up in case of previous crash / setup abort.
// Automatically start sync in Chromium OS.
- if (bootstrap_sync_authentication_) {
+ if (bootstrap_sync_authentication_ &&
+ !profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)) {
// If the LSID is empty, we're in a CrOS UI test that is not testing sync
// behavior, so we don't want the sync service to start.
if (profile()->GetTokenService() &&
@@ -216,6 +217,7 @@ void ProfileSyncService::RegisterPreferences() {
return;
pref_service->RegisterInt64Pref(prefs::kSyncLastSyncedTime, 0);
pref_service->RegisterBooleanPref(prefs::kSyncHasSetupCompleted, false);
+ pref_service->RegisterBooleanPref(prefs::kSyncSuppressStart, false);
// If you've never synced before, or if you're using Chrome OS, all datatypes
// are on by default.
@@ -366,6 +368,7 @@ bool ProfileSyncService::HasSyncSetupCompleted() const {
void ProfileSyncService::SetSyncSetupCompleted() {
PrefService* prefs = profile()->GetPrefs();
prefs->SetBoolean(prefs::kSyncHasSetupCompleted, true);
+ prefs->SetBoolean(prefs::kSyncSuppressStart, false);
prefs->ScheduleSavePersistentPrefs();
}
@@ -448,7 +451,11 @@ void ProfileSyncService::OnBackendInitialized() {
FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged());
if (bootstrap_sync_authentication_) {
- SetSyncSetupCompleted();
+ if (profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)) {
+ ShowChooseDataTypes(NULL);
+ } else {
+ SetSyncSetupCompleted();
+ }
}
if (HasSyncSetupCompleted())
@@ -495,7 +502,7 @@ void ProfileSyncService::OnStopSyncingPermanently() {
wizard_.Step(SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR);
expect_sync_configuration_aborted_ = true;
}
-
+ profile_->GetPrefs()->SetBoolean(prefs::kSyncSuppressStart, true);
DisableForUser();
}
@@ -543,6 +550,10 @@ SyncBackendHost::Status ProfileSyncService::QueryDetailedSyncStatus() {
}
}
+bool ProfileSyncService::SetupInProgress() const {
+ return !HasSyncSetupCompleted() && WizardIsVisible();
+}
+
std::wstring ProfileSyncService::BuildSyncStatusSummaryText(
const sync_api::SyncManager::Status::Summary& summary) {
switch (summary) {
diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h
index 9615124..7acb034 100644
--- a/chrome/browser/sync/profile_sync_service.h
+++ b/chrome/browser/sync/profile_sync_service.h
@@ -175,10 +175,7 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
// progress, the sync system is already authenticated, or some error
// occurred preventing the action. We make it the duty of ProfileSyncService
// to open the dialog to easily ensure only one is ever showing.
- bool SetupInProgress() const {
- return !HasSyncSetupCompleted() &&
- (WizardIsVisible() || bootstrap_sync_authentication_);
- }
+ bool SetupInProgress() const;
bool WizardIsVisible() const {
return wizard_.IsVisible();
}
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index e04994f..807e58e 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -888,6 +888,10 @@ const wchar_t kSyncExtensions[] = L"sync.extensions";
// sync.
const wchar_t kSyncManaged[] = L"sync.managed";
+// Boolean to prevent sync from automatically starting up. This is
+// used when sync is disabled by the user via the privacy dashboard.
+const wchar_t kSyncSuppressStart[] = L"sync.suppress_start";
+
// Create web application shortcut dialog preferences.
const wchar_t kWebAppCreateOnDesktop[] = L"browser.web_app.create_on_desktop";
const wchar_t kWebAppCreateInAppsMenu[] =
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 9897ec0..0e98f18 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -322,6 +322,7 @@ extern const wchar_t kSyncThemes[];
extern const wchar_t kSyncTypedUrls[];
extern const wchar_t kSyncExtensions[];
extern const wchar_t kSyncManaged[];
+extern const wchar_t kSyncSuppressStart[];
extern const wchar_t kWebAppCreateOnDesktop[];
extern const wchar_t kWebAppCreateInAppsMenu[];