Chromium Code Reviews

Unified Diff: chrome/browser/gtk/options/content_page_gtk.cc

Issue 2905003: Implement support for disabling sync through configuration management. (Closed)
Patch Set: Fix PrefsControllerTest on MAC. Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « chrome/browser/gtk/options/content_page_gtk.h ('k') | chrome/browser/managed_prefs_banner_base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/gtk/options/content_page_gtk.cc
diff --git a/chrome/browser/gtk/options/content_page_gtk.cc b/chrome/browser/gtk/options/content_page_gtk.cc
index 6307f15ea675f20fe4a410708c79c8ef7b5c05d9..4c33130c978394dc2df6e6ddc58e0f08707102b4 100644
--- a/chrome/browser/gtk/options/content_page_gtk.cc
+++ b/chrome/browser/gtk/options/content_page_gtk.cc
@@ -42,6 +42,11 @@ namespace {
// Background color for the status label when it's showing an error.
static const GdkColor kSyncLabelErrorBgColor = GDK_COLOR_RGB(0xff, 0x9a, 0x9a);
+// Set of preferences which might be unavailable for editing when managed.
+const wchar_t* kContentManagablePrefs[] = {
+ prefs::kSyncManaged
+};
+
// Helper for WrapLabelAtAllocationHack.
void OnLabelAllocate(GtkWidget* label, GtkAllocation* allocation) {
gtk_widget_set_size_request(label, allocation->width, -1);
@@ -79,7 +84,9 @@ ContentPageGtk::ContentPageGtk(Profile* profile)
#endif
sync_customize_button_(NULL),
initializing_(true),
- sync_service_(NULL) {
+ sync_service_(NULL),
+ managed_prefs_banner_(profile->GetPrefs(), kContentManagablePrefs,
+ arraysize(kContentManagablePrefs)) {
if (profile->GetProfileSyncService()) {
sync_service_ = profile->GetProfileSyncService();
sync_service_->AddObserver(this);
@@ -88,6 +95,7 @@ ContentPageGtk::ContentPageGtk(Profile* profile)
// Prepare the group options layout.
scoped_ptr<OptionsLayoutBuilderGtk>
options_builder(OptionsLayoutBuilderGtk::CreateOptionallyCompactLayout());
+ options_builder->AddWidget(managed_prefs_banner_.banner_widget(), false);
if (sync_service_) {
options_builder->AddOptionGroup(
l10n_util::GetStringUTF8(IDS_SYNC_OPTIONS_GROUP_NAME),
@@ -402,6 +410,7 @@ void ContentPageGtk::UpdateSyncControls() {
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;
@@ -419,7 +428,7 @@ void ContentPageGtk::UpdateSyncControls() {
UTF16ToUTF8(status_label).c_str());
#if !defined(OS_CHROMEOS)
gtk_widget_set_sensitive(sync_start_stop_button_,
- !sync_service_->WizardIsVisible());
+ !sync_service_->WizardIsVisible() && !managed);
gtk_button_set_label(GTK_BUTTON(sync_start_stop_button_),
button_label.c_str());
#endif
@@ -428,6 +437,7 @@ void ContentPageGtk::UpdateSyncControls() {
sync_setup_completed && !status_has_error);
gtk_button_set_label(GTK_BUTTON(sync_customize_button_),
customize_button_label.c_str());
+ gtk_widget_set_sensitive(sync_customize_button_, !managed);
#if !defined(OS_CHROMEOS)
gtk_chrome_link_button_set_label(GTK_CHROME_LINK_BUTTON(sync_action_link_),
UTF16ToUTF8(link_label).c_str());
@@ -438,6 +448,7 @@ void ContentPageGtk::UpdateSyncControls() {
gtk_widget_set_no_show_all(sync_action_link_background_, FALSE);
gtk_widget_show(sync_action_link_background_);
}
+ gtk_widget_set_sensitive(sync_action_link_, !managed);
#endif
if (status_has_error) {
gtk_widget_modify_bg(sync_status_label_background_, GTK_STATE_NORMAL,
@@ -564,7 +575,7 @@ void ContentPageGtk::OnAutoFillRadioToggled(GtkWidget* widget) {
}
void ContentPageGtk::OnSyncStartStopButtonClicked(GtkWidget* widget) {
- DCHECK(sync_service_);
+ DCHECK(sync_service_ && !sync_service_->IsManaged());
if (sync_service_->HasSyncSetupCompleted()) {
GtkWidget* dialog = gtk_message_dialog_new(
@@ -602,12 +613,13 @@ 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());
+ DCHECK(sync_service_ && !sync_service_->IsManaged() &&
+ sync_service_->HasSyncSetupCompleted());
sync_service_->ShowChooseDataTypes();
}
void ContentPageGtk::OnSyncActionLinkClicked(GtkWidget* widget) {
- DCHECK(sync_service_);
+ DCHECK(sync_service_ && !sync_service_->IsManaged());
sync_service_->ShowLoginDialog();
}
« no previous file with comments | « chrome/browser/gtk/options/content_page_gtk.h ('k') | chrome/browser/managed_prefs_banner_base.h » ('j') | no next file with comments »

Powered by Google App Engine