Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: chrome/browser/gtk/options/content_page_gtk.cc

Issue 1124005: gtk: Tie the AutoFill button in the options dialog to the kEnableAutoFill pre... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/gtk/options/content_page_gtk.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/gtk/options/content_page_gtk.h" 5 #include "chrome/browser/gtk/options/content_page_gtk.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "app/gtk_util.h" 9 #include "app/gtk_util.h"
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } 52 }
53 53
54 // Prepare the group options layout. 54 // Prepare the group options layout.
55 OptionsLayoutBuilderGtk options_builder; 55 OptionsLayoutBuilderGtk options_builder;
56 if (sync_service_) { 56 if (sync_service_) {
57 options_builder.AddOptionGroup( 57 options_builder.AddOptionGroup(
58 l10n_util::GetStringUTF8(IDS_SYNC_OPTIONS_GROUP_NAME), 58 l10n_util::GetStringUTF8(IDS_SYNC_OPTIONS_GROUP_NAME),
59 InitSyncGroup(), false); 59 InitSyncGroup(), false);
60 UpdateSyncControls(); 60 UpdateSyncControls();
61 } 61 }
62
62 options_builder.AddOptionGroup( 63 options_builder.AddOptionGroup(
63 l10n_util::GetStringUTF8(IDS_OPTIONS_PASSWORDS_GROUP_NAME), 64 l10n_util::GetStringUTF8(IDS_OPTIONS_PASSWORDS_GROUP_NAME),
64 InitPasswordSavingGroup(), false); 65 InitPasswordSavingGroup(), false);
65 options_builder.AddOptionGroup( 66 options_builder.AddOptionGroup(
66 l10n_util::GetStringUTF8(IDS_AUTOFILL_SETTING_WINDOWS_GROUP_NAME), 67 l10n_util::GetStringUTF8(IDS_AUTOFILL_SETTING_WINDOWS_GROUP_NAME),
67 InitFormAutofillGroup(), false); 68 InitFormAutoFillGroup(), false);
68 options_builder.AddOptionGroup( 69 options_builder.AddOptionGroup(
69 l10n_util::GetStringUTF8(IDS_OPTIONS_BROWSING_DATA_GROUP_NAME), 70 l10n_util::GetStringUTF8(IDS_OPTIONS_BROWSING_DATA_GROUP_NAME),
70 InitBrowsingDataGroup(), false); 71 InitBrowsingDataGroup(), false);
71 options_builder.AddOptionGroup( 72 options_builder.AddOptionGroup(
72 l10n_util::GetStringUTF8(IDS_APPEARANCE_GROUP_NAME), 73 l10n_util::GetStringUTF8(IDS_APPEARANCE_GROUP_NAME),
73 InitThemesGroup(), false); 74 InitThemesGroup(), false);
74 page_ = options_builder.get_page_widget(); 75 page_ = options_builder.get_page_widget();
75 76
76 // Add preferences observers. 77 // Add preferences observers.
77 ask_to_save_passwords_.Init(prefs::kPasswordManagerEnabled, 78 ask_to_save_passwords_.Init(prefs::kPasswordManagerEnabled,
78 profile->GetPrefs(), this); 79 profile->GetPrefs(), this);
79 enable_form_autofill_.Init(prefs::kAutoFillEnabled, 80 enable_form_autofill_.Init(prefs::kAutoFillEnabled,
80 profile->GetPrefs(), this); 81 profile->GetPrefs(), this);
82
81 if (browser_defaults::kCanToggleSystemTitleBar) { 83 if (browser_defaults::kCanToggleSystemTitleBar) {
82 use_custom_chrome_frame_.Init(prefs::kUseCustomChromeFrame, 84 use_custom_chrome_frame_.Init(prefs::kUseCustomChromeFrame,
83 profile->GetPrefs(), this); 85 profile->GetPrefs(), this);
84 } 86 }
85 87
86 // Load initial values. 88 // Load initial values.
87 NotifyPrefChanged(NULL); 89 NotifyPrefChanged(NULL);
88 90
89 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, 91 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
90 NotificationService::AllSources()); 92 NotificationService::AllSources());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 GTK_TOGGLE_BUTTON(passwords_asktosave_radio_), TRUE); 127 GTK_TOGGLE_BUTTON(passwords_asktosave_radio_), TRUE);
126 } else { 128 } else {
127 gtk_toggle_button_set_active( 129 gtk_toggle_button_set_active(
128 GTK_TOGGLE_BUTTON(passwords_neversave_radio_), TRUE); 130 GTK_TOGGLE_BUTTON(passwords_neversave_radio_), TRUE);
129 } 131 }
130 } 132 }
131 if (!pref_name || *pref_name == prefs::kAutoFillEnabled) { 133 if (!pref_name || *pref_name == prefs::kAutoFillEnabled) {
132 if (enable_form_autofill_.GetValue()) { 134 if (enable_form_autofill_.GetValue()) {
133 gtk_toggle_button_set_active( 135 gtk_toggle_button_set_active(
134 GTK_TOGGLE_BUTTON(form_autofill_enable_radio_), TRUE); 136 GTK_TOGGLE_BUTTON(form_autofill_enable_radio_), TRUE);
137 gtk_widget_set_sensitive(autofill_button_, TRUE);
135 } else { 138 } else {
136 gtk_toggle_button_set_active( 139 gtk_toggle_button_set_active(
137 GTK_TOGGLE_BUTTON(form_autofill_disable_radio_), TRUE); 140 GTK_TOGGLE_BUTTON(form_autofill_disable_radio_), TRUE);
141 gtk_widget_set_sensitive(autofill_button_, FALSE);
138 } 142 }
139 } 143 }
140 if (browser_defaults::kCanToggleSystemTitleBar && 144 if (browser_defaults::kCanToggleSystemTitleBar &&
141 (!pref_name || *pref_name == prefs::kUseCustomChromeFrame)) { 145 (!pref_name || *pref_name == prefs::kUseCustomChromeFrame)) {
142 if (use_custom_chrome_frame_.GetValue()) { 146 if (use_custom_chrome_frame_.GetValue()) {
143 gtk_toggle_button_set_active( 147 gtk_toggle_button_set_active(
144 GTK_TOGGLE_BUTTON(system_title_bar_hide_radio_), TRUE); 148 GTK_TOGGLE_BUTTON(system_title_bar_hide_radio_), TRUE);
145 } else { 149 } else {
146 gtk_toggle_button_set_active( 150 gtk_toggle_button_set_active(
147 GTK_TOGGLE_BUTTON(system_title_bar_show_radio_), TRUE); 151 GTK_TOGGLE_BUTTON(system_title_bar_show_radio_), TRUE);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 GtkWidget* show_passwords_button = gtk_button_new_with_label( 214 GtkWidget* show_passwords_button = gtk_button_new_with_label(
211 l10n_util::GetStringUTF8(IDS_OPTIONS_PASSWORDS_SHOWPASSWORDS).c_str()); 215 l10n_util::GetStringUTF8(IDS_OPTIONS_PASSWORDS_SHOWPASSWORDS).c_str());
212 g_signal_connect(show_passwords_button, "clicked", 216 g_signal_connect(show_passwords_button, "clicked",
213 G_CALLBACK(OnShowPasswordsButtonClickedThunk), this); 217 G_CALLBACK(OnShowPasswordsButtonClickedThunk), this);
214 gtk_box_pack_start(GTK_BOX(button_hbox), show_passwords_button, FALSE, 218 gtk_box_pack_start(GTK_BOX(button_hbox), show_passwords_button, FALSE,
215 FALSE, 0); 219 FALSE, 0);
216 220
217 return vbox; 221 return vbox;
218 } 222 }
219 223
220 GtkWidget* ContentPageGtk::InitFormAutofillGroup() { 224 GtkWidget* ContentPageGtk::InitFormAutoFillGroup() {
221 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); 225 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
222 226
223 // Enable radio button. 227 // Enable radio button.
224 form_autofill_enable_radio_ = gtk_radio_button_new_with_label(NULL, 228 form_autofill_enable_radio_ = gtk_radio_button_new_with_label(NULL,
225 l10n_util::GetStringUTF8(IDS_OPTIONS_AUTOFILL_ENABLE).c_str()); 229 l10n_util::GetStringUTF8(IDS_OPTIONS_AUTOFILL_ENABLE).c_str());
226 g_signal_connect(G_OBJECT(form_autofill_enable_radio_), "toggled", 230 g_signal_connect(G_OBJECT(form_autofill_enable_radio_), "toggled",
227 G_CALLBACK(OnAutofillRadioToggledThunk), this); 231 G_CALLBACK(OnAutoFillRadioToggledThunk), this);
228 gtk_box_pack_start(GTK_BOX(vbox), form_autofill_enable_radio_, FALSE, 232 gtk_box_pack_start(GTK_BOX(vbox), form_autofill_enable_radio_, FALSE,
229 FALSE, 0); 233 FALSE, 0);
230 234
231 // Disable radio button. 235 // Disable radio button.
232 form_autofill_disable_radio_ = gtk_radio_button_new_with_label_from_widget( 236 form_autofill_disable_radio_ = gtk_radio_button_new_with_label_from_widget(
233 GTK_RADIO_BUTTON(form_autofill_enable_radio_), 237 GTK_RADIO_BUTTON(form_autofill_enable_radio_),
234 l10n_util::GetStringUTF8(IDS_OPTIONS_AUTOFILL_DISABLE).c_str()); 238 l10n_util::GetStringUTF8(IDS_OPTIONS_AUTOFILL_DISABLE).c_str());
235 g_signal_connect(G_OBJECT(form_autofill_disable_radio_), "toggled", 239 g_signal_connect(G_OBJECT(form_autofill_disable_radio_), "toggled",
236 G_CALLBACK(OnAutofillRadioToggledThunk), this); 240 G_CALLBACK(OnAutoFillRadioToggledThunk), this);
237 gtk_box_pack_start(GTK_BOX(vbox), form_autofill_disable_radio_, FALSE, 241 gtk_box_pack_start(GTK_BOX(vbox), form_autofill_disable_radio_, FALSE,
238 FALSE, 0); 242 FALSE, 0);
239 243
240 GtkWidget* button_hbox = gtk_hbox_new(FALSE, gtk_util::kControlSpacing); 244 GtkWidget* button_hbox = gtk_hbox_new(FALSE, gtk_util::kControlSpacing);
241 gtk_container_add(GTK_CONTAINER(vbox), button_hbox); 245 gtk_container_add(GTK_CONTAINER(vbox), button_hbox);
242 246
243 // Autofill button. 247 // AutoFill button.
244 GtkWidget* autofill_button = gtk_button_new_with_label( 248 autofill_button_ = gtk_button_new_with_label(
245 l10n_util::GetStringUTF8(IDS_OPTIONS_AUTOFILL_SETTINGS).c_str()); 249 l10n_util::GetStringUTF8(IDS_OPTIONS_AUTOFILL_SETTINGS).c_str());
246 if (!personal_data_) 250 if (!profile()->GetPrefs()->GetBoolean(prefs::kAutoFillEnabled))
247 gtk_widget_set_sensitive(autofill_button, FALSE); 251 gtk_widget_set_sensitive(autofill_button_, FALSE);
248 252
249 g_signal_connect(G_OBJECT(autofill_button), "clicked", 253 g_signal_connect(G_OBJECT(autofill_button_), "clicked",
250 G_CALLBACK(OnAutofillButtonClickedThunk), this); 254 G_CALLBACK(OnAutoFillButtonClickedThunk), this);
251 gtk_box_pack_start(GTK_BOX(button_hbox), autofill_button, FALSE, FALSE, 0); 255 gtk_box_pack_start(GTK_BOX(button_hbox), autofill_button_, FALSE, FALSE, 0);
252 256
253 return vbox; 257 return vbox;
254 } 258 }
255 259
256 GtkWidget* ContentPageGtk::InitBrowsingDataGroup() { 260 GtkWidget* ContentPageGtk::InitBrowsingDataGroup() {
257 GtkWidget* button_box = gtk_hbox_new(FALSE, gtk_util::kControlSpacing); 261 GtkWidget* button_box = gtk_hbox_new(FALSE, gtk_util::kControlSpacing);
258 262
259 // Import button. 263 // Import button.
260 GtkWidget* import_button = gtk_button_new_with_label( 264 GtkWidget* import_button = gtk_button_new_with_label(
261 l10n_util::GetStringUTF8(IDS_OPTIONS_IMPORT_DATA_BUTTON).c_str()); 265 l10n_util::GetStringUTF8(IDS_OPTIONS_IMPORT_DATA_BUTTON).c_str());
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 gtk_widget_modify_bg(sync_status_label_background_, GTK_STATE_NORMAL, 398 gtk_widget_modify_bg(sync_status_label_background_, GTK_STATE_NORMAL,
395 &kSyncLabelErrorBgColor); 399 &kSyncLabelErrorBgColor);
396 gtk_widget_modify_bg(sync_action_link_background_, GTK_STATE_NORMAL, 400 gtk_widget_modify_bg(sync_action_link_background_, GTK_STATE_NORMAL,
397 &kSyncLabelErrorBgColor); 401 &kSyncLabelErrorBgColor);
398 } else { 402 } else {
399 gtk_widget_modify_bg(sync_status_label_background_, GTK_STATE_NORMAL, NULL); 403 gtk_widget_modify_bg(sync_status_label_background_, GTK_STATE_NORMAL, NULL);
400 gtk_widget_modify_bg(sync_action_link_background_, GTK_STATE_NORMAL, NULL); 404 gtk_widget_modify_bg(sync_action_link_background_, GTK_STATE_NORMAL, NULL);
401 } 405 }
402 } 406 }
403 407
404 void ContentPageGtk::OnAutofillButtonClicked(GtkWidget* widget) { 408 void ContentPageGtk::OnAutoFillButtonClicked(GtkWidget* widget) {
405 DCHECK(personal_data_); 409 DCHECK(personal_data_);
406 // If the personal data manager has not loaded the data yet, set ourselves as 410 // If the personal data manager has not loaded the data yet, set ourselves as
407 // its observer so that we can listen for the OnPersonalDataLoaded signal. 411 // its observer so that we can listen for the OnPersonalDataLoaded signal.
408 if (!personal_data_->IsDataLoaded()) 412 if (!personal_data_->IsDataLoaded())
409 personal_data_->SetObserver(this); 413 personal_data_->SetObserver(this);
410 else 414 else
411 OnPersonalDataLoaded(); 415 OnPersonalDataLoaded();
412 } 416 }
413 417
414 void ContentPageGtk::OnImportButtonClicked(GtkWidget* widget) { 418 void ContentPageGtk::OnImportButtonClicked(GtkWidget* widget) {
415 ImportDialogGtk::Show( 419 ImportDialogGtk::Show(
416 GTK_WINDOW(gtk_widget_get_toplevel(widget)), 420 GTK_WINDOW(gtk_widget_get_toplevel(widget)),
417 profile(), importer::ALL); 421 profile(), importer::ALL);
418 } 422 }
419 423
420 void ContentPageGtk::OnGtkThemeButtonClicked(GtkWidget* widget) { 424 void ContentPageGtk::OnGtkThemeButtonClicked(GtkWidget* widget) {
421 UserMetricsRecordAction("Options_GtkThemeSet", 425 UserMetricsRecordAction("Options_GtkThemeSet", profile()->GetPrefs());
422 profile()->GetPrefs());
423 profile()->SetNativeTheme(); 426 profile()->SetNativeTheme();
424 } 427 }
425 428
426 void ContentPageGtk::OnResetDefaultThemeButtonClicked(GtkWidget* widget) { 429 void ContentPageGtk::OnResetDefaultThemeButtonClicked(GtkWidget* widget) {
427 UserMetricsRecordAction("Options_ThemesReset", 430 UserMetricsRecordAction("Options_ThemesReset", profile()->GetPrefs());
428 profile()->GetPrefs());
429 profile()->ClearTheme(); 431 profile()->ClearTheme();
430 } 432 }
431 433
432 void ContentPageGtk::OnGetThemesButtonClicked(GtkWidget* widget) { 434 void ContentPageGtk::OnGetThemesButtonClicked(GtkWidget* widget) {
433 UserMetricsRecordAction("Options_ThemesGallery", 435 UserMetricsRecordAction("Options_ThemesGallery", profile()->GetPrefs());
434 profile()->GetPrefs());
435 BrowserList::GetLastActive()->OpenThemeGalleryTabAndActivate(); 436 BrowserList::GetLastActive()->OpenThemeGalleryTabAndActivate();
436 } 437 }
437 438
438 void ContentPageGtk::OnSystemTitleBarRadioToggled(GtkWidget* widget) { 439 void ContentPageGtk::OnSystemTitleBarRadioToggled(GtkWidget* widget) {
439 DCHECK(browser_defaults::kCanToggleSystemTitleBar); 440 DCHECK(browser_defaults::kCanToggleSystemTitleBar);
440 if (initializing_) 441 if (initializing_)
441 return; 442 return;
442 443
443 // We get two signals when selecting a radio button, one for the old radio 444 // We get two signals when selecting a radio button, one for the old radio
444 // being toggled off and one for the new one being toggled on. Ignore the 445 // being toggled off and one for the new one being toggled on. Ignore the
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 if (enabled) { 479 if (enabled) {
479 UserMetricsRecordAction("Options_PasswordManager_Enable", 480 UserMetricsRecordAction("Options_PasswordManager_Enable",
480 profile()->GetPrefs()); 481 profile()->GetPrefs());
481 } else { 482 } else {
482 UserMetricsRecordAction("Options_PasswordManager_Disable", 483 UserMetricsRecordAction("Options_PasswordManager_Disable",
483 profile()->GetPrefs()); 484 profile()->GetPrefs());
484 } 485 }
485 ask_to_save_passwords_.SetValue(enabled); 486 ask_to_save_passwords_.SetValue(enabled);
486 } 487 }
487 488
488 void ContentPageGtk::OnAutofillRadioToggled(GtkWidget* widget) { 489 void ContentPageGtk::OnAutoFillRadioToggled(GtkWidget* widget) {
489 if (initializing_) 490 if (initializing_)
490 return; 491 return;
491 492
492 // We get two signals when selecting a radio button, one for the old radio 493 // We get two signals when selecting a radio button, one for the old radio
493 // being toggled off and one for the new one being toggled on. Ignore the 494 // being toggled off and one for the new one being toggled on. Ignore the
494 // signal for the toggling off the old button. 495 // signal for the toggling off the old button.
495 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) 496 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
496 return; 497 return;
497 498
498 bool enabled = gtk_toggle_button_get_active( 499 bool enabled = gtk_toggle_button_get_active(
499 GTK_TOGGLE_BUTTON(form_autofill_enable_radio_)); 500 GTK_TOGGLE_BUTTON(form_autofill_enable_radio_));
500 if (enabled) { 501 if (enabled) {
501 UserMetricsRecordAction("Options_FormAutofill_Enable", 502 UserMetricsRecordAction("Options_FormAutofill_Enable",
502 profile()->GetPrefs()); 503 profile()->GetPrefs());
504 gtk_widget_set_sensitive(autofill_button_, TRUE);
503 } else { 505 } else {
504 UserMetricsRecordAction("Options_FormAutofill_Disable", 506 UserMetricsRecordAction("Options_FormAutofill_Disable",
505 profile()->GetPrefs()); 507 profile()->GetPrefs());
508 gtk_widget_set_sensitive(autofill_button_, FALSE);
506 } 509 }
507 enable_form_autofill_.SetValue(enabled); 510 enable_form_autofill_.SetValue(enabled);
508 } 511 }
509 512
510 void ContentPageGtk::OnSyncStartStopButtonClicked(GtkWidget* widget) { 513 void ContentPageGtk::OnSyncStartStopButtonClicked(GtkWidget* widget) {
511 DCHECK(sync_service_); 514 DCHECK(sync_service_);
512 515
513 if (sync_service_->HasSyncSetupCompleted()) { 516 if (sync_service_->HasSyncSetupCompleted()) {
514 GtkWidget* dialog = gtk_message_dialog_new( 517 GtkWidget* dialog = gtk_message_dialog_new(
515 GTK_WINDOW(gtk_widget_get_toplevel(widget)), 518 GTK_WINDOW(gtk_widget_get_toplevel(widget)),
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 sync_service_->ShowLoginDialog(); 551 sync_service_->ShowLoginDialog();
549 } 552 }
550 553
551 void ContentPageGtk::OnStopSyncDialogResponse(GtkWidget* widget, int response) { 554 void ContentPageGtk::OnStopSyncDialogResponse(GtkWidget* widget, int response) {
552 if (response == GTK_RESPONSE_ACCEPT) { 555 if (response == GTK_RESPONSE_ACCEPT) {
553 sync_service_->DisableForUser(); 556 sync_service_->DisableForUser();
554 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); 557 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS);
555 } 558 }
556 gtk_widget_destroy(widget); 559 gtk_widget_destroy(widget);
557 } 560 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/options/content_page_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698