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

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

Issue 2975003: Makes the auto fill dialogs match the mocks. (Closed)
Patch Set: Moves function declarations out of autofill_dialog.h Created 10 years, 5 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
« no previous file with comments | « chrome/browser/gtk/options/content_page_gtk.h ('k') | chrome/chrome_browser.gypi » ('j') | 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 InitBrowsingDataGroup(), false); 107 InitBrowsingDataGroup(), false);
108 #endif 108 #endif
109 options_builder->AddOptionGroup( 109 options_builder->AddOptionGroup(
110 l10n_util::GetStringUTF8(IDS_APPEARANCE_GROUP_NAME), 110 l10n_util::GetStringUTF8(IDS_APPEARANCE_GROUP_NAME),
111 InitThemesGroup(), false); 111 InitThemesGroup(), false);
112 page_ = options_builder->get_page_widget(); 112 page_ = options_builder->get_page_widget();
113 113
114 // Add preferences observers. 114 // Add preferences observers.
115 ask_to_save_passwords_.Init(prefs::kPasswordManagerEnabled, 115 ask_to_save_passwords_.Init(prefs::kPasswordManagerEnabled,
116 profile->GetPrefs(), this); 116 profile->GetPrefs(), this);
117 enable_form_autofill_.Init(prefs::kAutoFillEnabled,
118 profile->GetPrefs(), this);
119 117
120 if (browser_defaults::kCanToggleSystemTitleBar) { 118 if (browser_defaults::kCanToggleSystemTitleBar) {
121 use_custom_chrome_frame_.Init(prefs::kUseCustomChromeFrame, 119 use_custom_chrome_frame_.Init(prefs::kUseCustomChromeFrame,
122 profile->GetPrefs(), this); 120 profile->GetPrefs(), this);
123 } 121 }
124 122
125 // Load initial values. 123 // Load initial values.
126 NotifyPrefChanged(NULL); 124 NotifyPrefChanged(NULL);
127 125
128 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, 126 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
(...skipping 27 matching lines...) Expand all
156 initializing_ = true; 154 initializing_ = true;
157 if (!pref_name || *pref_name == prefs::kPasswordManagerEnabled) { 155 if (!pref_name || *pref_name == prefs::kPasswordManagerEnabled) {
158 if (ask_to_save_passwords_.GetValue()) { 156 if (ask_to_save_passwords_.GetValue()) {
159 gtk_toggle_button_set_active( 157 gtk_toggle_button_set_active(
160 GTK_TOGGLE_BUTTON(passwords_asktosave_radio_), TRUE); 158 GTK_TOGGLE_BUTTON(passwords_asktosave_radio_), TRUE);
161 } else { 159 } else {
162 gtk_toggle_button_set_active( 160 gtk_toggle_button_set_active(
163 GTK_TOGGLE_BUTTON(passwords_neversave_radio_), TRUE); 161 GTK_TOGGLE_BUTTON(passwords_neversave_radio_), TRUE);
164 } 162 }
165 } 163 }
166 if (!pref_name || *pref_name == prefs::kAutoFillEnabled) {
167 if (enable_form_autofill_.GetValue()) {
168 gtk_toggle_button_set_active(
169 GTK_TOGGLE_BUTTON(form_autofill_enable_radio_), TRUE);
170 gtk_widget_set_sensitive(autofill_button_, TRUE);
171 } else {
172 gtk_toggle_button_set_active(
173 GTK_TOGGLE_BUTTON(form_autofill_disable_radio_), TRUE);
174 gtk_widget_set_sensitive(autofill_button_, FALSE);
175 }
176 }
177 if (browser_defaults::kCanToggleSystemTitleBar && 164 if (browser_defaults::kCanToggleSystemTitleBar &&
178 (!pref_name || *pref_name == prefs::kUseCustomChromeFrame)) { 165 (!pref_name || *pref_name == prefs::kUseCustomChromeFrame)) {
179 if (use_custom_chrome_frame_.GetValue()) { 166 if (use_custom_chrome_frame_.GetValue()) {
180 gtk_toggle_button_set_active( 167 gtk_toggle_button_set_active(
181 GTK_TOGGLE_BUTTON(system_title_bar_hide_radio_), TRUE); 168 GTK_TOGGLE_BUTTON(system_title_bar_hide_radio_), TRUE);
182 } else { 169 } else {
183 gtk_toggle_button_set_active( 170 gtk_toggle_button_set_active(
184 GTK_TOGGLE_BUTTON(system_title_bar_show_radio_), TRUE); 171 GTK_TOGGLE_BUTTON(system_title_bar_show_radio_), TRUE);
185 } 172 }
186 } 173 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 G_CALLBACK(OnShowPasswordsButtonClickedThunk), this); 228 G_CALLBACK(OnShowPasswordsButtonClickedThunk), this);
242 gtk_box_pack_start(GTK_BOX(button_hbox), show_passwords_button, FALSE, 229 gtk_box_pack_start(GTK_BOX(button_hbox), show_passwords_button, FALSE,
243 FALSE, 0); 230 FALSE, 0);
244 231
245 return vbox; 232 return vbox;
246 } 233 }
247 234
248 GtkWidget* ContentPageGtk::InitFormAutoFillGroup() { 235 GtkWidget* ContentPageGtk::InitFormAutoFillGroup() {
249 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); 236 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
250 237
251 // Enable radio button.
252 form_autofill_enable_radio_ = gtk_radio_button_new_with_label(NULL,
253 l10n_util::GetStringUTF8(IDS_OPTIONS_AUTOFILL_ENABLE).c_str());
254 g_signal_connect(G_OBJECT(form_autofill_enable_radio_), "toggled",
255 G_CALLBACK(OnAutoFillRadioToggledThunk), this);
256 gtk_box_pack_start(GTK_BOX(vbox), form_autofill_enable_radio_, FALSE,
257 FALSE, 0);
258
259 // Disable radio button.
260 form_autofill_disable_radio_ = gtk_radio_button_new_with_label_from_widget(
261 GTK_RADIO_BUTTON(form_autofill_enable_radio_),
262 l10n_util::GetStringUTF8(IDS_OPTIONS_AUTOFILL_DISABLE).c_str());
263 g_signal_connect(G_OBJECT(form_autofill_disable_radio_), "toggled",
264 G_CALLBACK(OnAutoFillRadioToggledThunk), this);
265 gtk_box_pack_start(GTK_BOX(vbox), form_autofill_disable_radio_, FALSE,
266 FALSE, 0);
267
268 GtkWidget* button_hbox = gtk_hbox_new(FALSE, gtk_util::kControlSpacing); 238 GtkWidget* button_hbox = gtk_hbox_new(FALSE, gtk_util::kControlSpacing);
269 gtk_container_add(GTK_CONTAINER(vbox), button_hbox); 239 gtk_container_add(GTK_CONTAINER(vbox), button_hbox);
270 240
271 // AutoFill button. 241 // AutoFill button.
272 autofill_button_ = gtk_button_new_with_label( 242 GtkWidget* autofill_button = gtk_button_new_with_label(
273 l10n_util::GetStringUTF8(IDS_AUTOFILL_OPTIONS).c_str()); 243 l10n_util::GetStringUTF8(IDS_AUTOFILL_OPTIONS).c_str());
274 if (!profile()->GetPrefs()->GetBoolean(prefs::kAutoFillEnabled))
275 gtk_widget_set_sensitive(autofill_button_, FALSE);
276 244
277 g_signal_connect(G_OBJECT(autofill_button_), "clicked", 245 g_signal_connect(G_OBJECT(autofill_button), "clicked",
278 G_CALLBACK(OnAutoFillButtonClickedThunk), this); 246 G_CALLBACK(OnAutoFillButtonClickedThunk), this);
279 gtk_box_pack_start(GTK_BOX(button_hbox), autofill_button_, FALSE, FALSE, 0); 247 gtk_box_pack_start(GTK_BOX(button_hbox), autofill_button, FALSE, FALSE, 0);
280 248
281 return vbox; 249 return vbox;
282 } 250 }
283 251
284 GtkWidget* ContentPageGtk::InitBrowsingDataGroup() { 252 GtkWidget* ContentPageGtk::InitBrowsingDataGroup() {
285 GtkWidget* button_box = gtk_hbox_new(FALSE, gtk_util::kControlSpacing); 253 GtkWidget* button_box = gtk_hbox_new(FALSE, gtk_util::kControlSpacing);
286 254
287 // Import button. 255 // Import button.
288 GtkWidget* import_button = gtk_button_new_with_label( 256 GtkWidget* import_button = gtk_button_new_with_label(
289 l10n_util::GetStringUTF8(IDS_OPTIONS_IMPORT_DATA_BUTTON).c_str()); 257 l10n_util::GetStringUTF8(IDS_OPTIONS_IMPORT_DATA_BUTTON).c_str());
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 UserMetricsRecordAction(UserMetricsAction("Options_PasswordManager_Enable"), 500 UserMetricsRecordAction(UserMetricsAction("Options_PasswordManager_Enable"),
533 profile()->GetPrefs()); 501 profile()->GetPrefs());
534 } else { 502 } else {
535 UserMetricsRecordAction( 503 UserMetricsRecordAction(
536 UserMetricsAction("Options_PasswordManager_Disable"), 504 UserMetricsAction("Options_PasswordManager_Disable"),
537 profile()->GetPrefs()); 505 profile()->GetPrefs());
538 } 506 }
539 ask_to_save_passwords_.SetValue(enabled); 507 ask_to_save_passwords_.SetValue(enabled);
540 } 508 }
541 509
542 void ContentPageGtk::OnAutoFillRadioToggled(GtkWidget* widget) {
543 if (initializing_)
544 return;
545
546 // We get two signals when selecting a radio button, one for the old radio
547 // being toggled off and one for the new one being toggled on. Ignore the
548 // signal for the toggling off the old button.
549 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
550 return;
551
552 bool enabled = gtk_toggle_button_get_active(
553 GTK_TOGGLE_BUTTON(form_autofill_enable_radio_));
554 if (enabled) {
555 UserMetricsRecordAction(UserMetricsAction("Options_FormAutofill_Enable"),
556 profile()->GetPrefs());
557 gtk_widget_set_sensitive(autofill_button_, TRUE);
558 } else {
559 UserMetricsRecordAction(UserMetricsAction("Options_FormAutofill_Disable"),
560 profile()->GetPrefs());
561 gtk_widget_set_sensitive(autofill_button_, FALSE);
562 }
563 enable_form_autofill_.SetValue(enabled);
564 }
565
566 void ContentPageGtk::OnSyncStartStopButtonClicked(GtkWidget* widget) { 510 void ContentPageGtk::OnSyncStartStopButtonClicked(GtkWidget* widget) {
567 DCHECK(sync_service_); 511 DCHECK(sync_service_);
568 512
569 if (sync_service_->HasSyncSetupCompleted()) { 513 if (sync_service_->HasSyncSetupCompleted()) {
570 GtkWidget* dialog = gtk_message_dialog_new( 514 GtkWidget* dialog = gtk_message_dialog_new(
571 GTK_WINDOW(gtk_widget_get_toplevel(widget)), 515 GTK_WINDOW(gtk_widget_get_toplevel(widget)),
572 static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL), 516 static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL),
573 GTK_MESSAGE_WARNING, 517 GTK_MESSAGE_WARNING,
574 GTK_BUTTONS_NONE, 518 GTK_BUTTONS_NONE,
575 "%s", 519 "%s",
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 sync_service_->ShowLoginDialog(); 555 sync_service_->ShowLoginDialog();
612 } 556 }
613 557
614 void ContentPageGtk::OnStopSyncDialogResponse(GtkWidget* widget, int response) { 558 void ContentPageGtk::OnStopSyncDialogResponse(GtkWidget* widget, int response) {
615 if (response == GTK_RESPONSE_ACCEPT) { 559 if (response == GTK_RESPONSE_ACCEPT) {
616 sync_service_->DisableForUser(); 560 sync_service_->DisableForUser();
617 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); 561 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS);
618 } 562 }
619 gtk_widget_destroy(widget); 563 gtk_widget_destroy(widget);
620 } 564 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/options/content_page_gtk.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698