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

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

Issue 610003: Linux: Implement the new AutoFill section of the Options dialog.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 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
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 "app/gfx/gtk_util.h" 7 #include "app/gfx/gtk_util.h"
8 #include "app/l10n_util.h" 8 #include "app/l10n_util.h"
9 #include "app/resource_bundle.h" 9 #include "app/resource_bundle.h"
10 #include "chrome/browser/browser.h" 10 #include "chrome/browser/browser.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 l10n_util::GetStringUTF8(IDS_OPTIONS_BROWSING_DATA_GROUP_NAME), 65 l10n_util::GetStringUTF8(IDS_OPTIONS_BROWSING_DATA_GROUP_NAME),
66 InitBrowsingDataGroup(), false); 66 InitBrowsingDataGroup(), false);
67 options_builder.AddOptionGroup( 67 options_builder.AddOptionGroup(
68 l10n_util::GetStringUTF8(IDS_APPEARANCE_GROUP_NAME), 68 l10n_util::GetStringUTF8(IDS_APPEARANCE_GROUP_NAME),
69 InitThemesGroup(), false); 69 InitThemesGroup(), false);
70 page_ = options_builder.get_page_widget(); 70 page_ = options_builder.get_page_widget();
71 71
72 // Add preferences observers. 72 // Add preferences observers.
73 ask_to_save_passwords_.Init(prefs::kPasswordManagerEnabled, 73 ask_to_save_passwords_.Init(prefs::kPasswordManagerEnabled,
74 profile->GetPrefs(), this); 74 profile->GetPrefs(), this);
75 ask_to_save_form_autofill_.Init(prefs::kFormAutofillEnabled, 75 enable_form_autofill_.Init(prefs::kFormAutofillEnabled,
76 profile->GetPrefs(), this); 76 profile->GetPrefs(), this);
77 if (browser_defaults::kCanToggleSystemTitleBar) { 77 if (browser_defaults::kCanToggleSystemTitleBar) {
78 use_custom_chrome_frame_.Init(prefs::kUseCustomChromeFrame, 78 use_custom_chrome_frame_.Init(prefs::kUseCustomChromeFrame,
79 profile->GetPrefs(), this); 79 profile->GetPrefs(), this);
80 } 80 }
81 81
82 // Load initial values. 82 // Load initial values.
83 NotifyPrefChanged(NULL); 83 NotifyPrefChanged(NULL);
84 84
85 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, 85 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
86 NotificationService::AllSources()); 86 NotificationService::AllSources());
87 ObserveThemeChanged(); 87 ObserveThemeChanged();
88
89 personal_data_ = profile->GetPersonalDataManager();
88 } 90 }
89 91
90 ContentPageGtk::~ContentPageGtk() { 92 ContentPageGtk::~ContentPageGtk() {
91 if (sync_service_) 93 if (sync_service_)
92 sync_service_->RemoveObserver(this); 94 sync_service_->RemoveObserver(this);
95 if (personal_data_)
96 personal_data_->RemoveObserver(this);
93 } 97 }
94 98
95 /////////////////////////////////////////////////////////////////////////////// 99 ///////////////////////////////////////////////////////////////////////////////
96 // ContentsPageView, ProfileSyncServiceObserver implementation: 100 // ContentsPageView, ProfileSyncServiceObserver implementation:
97 101
98 void ContentPageGtk::OnStateChanged() { 102 void ContentPageGtk::OnStateChanged() {
99 // If the UI controls are not yet initialized, then don't do anything. This 103 // If the UI controls are not yet initialized, then don't do anything. This
100 // can happen if the Options dialog is up, but the Content tab is not yet 104 // can happen if the Options dialog is up, but the Content tab is not yet
101 // clicked. 105 // clicked.
102 if (!initializing_) 106 if (!initializing_)
(...skipping 11 matching lines...) Expand all
114 if (!pref_name || *pref_name == prefs::kPasswordManagerEnabled) { 118 if (!pref_name || *pref_name == prefs::kPasswordManagerEnabled) {
115 if (ask_to_save_passwords_.GetValue()) { 119 if (ask_to_save_passwords_.GetValue()) {
116 gtk_toggle_button_set_active( 120 gtk_toggle_button_set_active(
117 GTK_TOGGLE_BUTTON(passwords_asktosave_radio_), TRUE); 121 GTK_TOGGLE_BUTTON(passwords_asktosave_radio_), TRUE);
118 } else { 122 } else {
119 gtk_toggle_button_set_active( 123 gtk_toggle_button_set_active(
120 GTK_TOGGLE_BUTTON(passwords_neversave_radio_), TRUE); 124 GTK_TOGGLE_BUTTON(passwords_neversave_radio_), TRUE);
121 } 125 }
122 } 126 }
123 if (!pref_name || *pref_name == prefs::kFormAutofillEnabled) { 127 if (!pref_name || *pref_name == prefs::kFormAutofillEnabled) {
124 if (ask_to_save_form_autofill_.GetValue()) { 128 if (enable_form_autofill_.GetValue()) {
125 gtk_toggle_button_set_active( 129 gtk_toggle_button_set_active(
126 GTK_TOGGLE_BUTTON(form_autofill_asktosave_radio_), TRUE); 130 GTK_TOGGLE_BUTTON(form_autofill_enable_radio_), TRUE);
127 } else { 131 } else {
128 gtk_toggle_button_set_active( 132 gtk_toggle_button_set_active(
129 GTK_TOGGLE_BUTTON(form_autofill_neversave_radio_), TRUE); 133 GTK_TOGGLE_BUTTON(form_autofill_disable_radio_), TRUE);
130 } 134 }
131 } 135 }
132 if (browser_defaults::kCanToggleSystemTitleBar && 136 if (browser_defaults::kCanToggleSystemTitleBar &&
133 (!pref_name || *pref_name == prefs::kUseCustomChromeFrame)) { 137 (!pref_name || *pref_name == prefs::kUseCustomChromeFrame)) {
134 if (use_custom_chrome_frame_.GetValue()) { 138 if (use_custom_chrome_frame_.GetValue()) {
135 gtk_toggle_button_set_active( 139 gtk_toggle_button_set_active(
136 GTK_TOGGLE_BUTTON(system_title_bar_hide_radio_), TRUE); 140 GTK_TOGGLE_BUTTON(system_title_bar_hide_radio_), TRUE);
137 } else { 141 } else {
138 gtk_toggle_button_set_active( 142 gtk_toggle_button_set_active(
139 GTK_TOGGLE_BUTTON(system_title_bar_show_radio_), TRUE); 143 GTK_TOGGLE_BUTTON(system_title_bar_show_radio_), TRUE);
(...skipping 19 matching lines...) Expand all
159 #else 163 #else
160 BrowserThemeProvider* provider = 164 BrowserThemeProvider* provider =
161 reinterpret_cast<BrowserThemeProvider*>(profile()->GetThemeProvider()); 165 reinterpret_cast<BrowserThemeProvider*>(profile()->GetThemeProvider());
162 bool is_gtk_theme = false; 166 bool is_gtk_theme = false;
163 #endif 167 #endif
164 168
165 bool is_classic_theme = !is_gtk_theme && provider->GetThemeID().empty(); 169 bool is_classic_theme = !is_gtk_theme && provider->GetThemeID().empty();
166 gtk_widget_set_sensitive(themes_reset_button_, !is_classic_theme); 170 gtk_widget_set_sensitive(themes_reset_button_, !is_classic_theme);
167 } 171 }
168 172
173 void ContentPageGtk::OnPersonalDataLoaded() {
174 DCHECK(personal_data_);
175 // We might have been alerted that the PersonalDataManager has loaded, so
176 // remove ourselves as observer.
177 personal_data_->RemoveObserver(this);
178
179 ShowAutoFillDialog(
180 personal_data_, personal_data_->profiles(),
181 personal_data_->credit_cards());
182 }
183
169 GtkWidget* ContentPageGtk::InitPasswordSavingGroup() { 184 GtkWidget* ContentPageGtk::InitPasswordSavingGroup() {
170 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); 185 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
171 186
172 // Ask to save radio button. 187 // Ask to save radio button.
173 passwords_asktosave_radio_ = gtk_radio_button_new_with_label(NULL, 188 passwords_asktosave_radio_ = gtk_radio_button_new_with_label(NULL,
174 l10n_util::GetStringUTF8(IDS_OPTIONS_PASSWORDS_ASKTOSAVE).c_str()); 189 l10n_util::GetStringUTF8(IDS_OPTIONS_PASSWORDS_ASKTOSAVE).c_str());
175 g_signal_connect(passwords_asktosave_radio_, "toggled", 190 g_signal_connect(passwords_asktosave_radio_, "toggled",
176 G_CALLBACK(OnPasswordRadioToggled), this); 191 G_CALLBACK(OnPasswordRadioToggled), this);
177 gtk_box_pack_start(GTK_BOX(vbox), passwords_asktosave_radio_, FALSE, 192 gtk_box_pack_start(GTK_BOX(vbox), passwords_asktosave_radio_, FALSE,
178 FALSE, 0); 193 FALSE, 0);
(...skipping 17 matching lines...) Expand all
196 G_CALLBACK(OnPasswordsExceptionsButtonClicked), this); 211 G_CALLBACK(OnPasswordsExceptionsButtonClicked), this);
197 gtk_box_pack_start(GTK_BOX(button_hbox), passwords_exceptions_button, FALSE, 212 gtk_box_pack_start(GTK_BOX(button_hbox), passwords_exceptions_button, FALSE,
198 FALSE, 0); 213 FALSE, 0);
199 214
200 return vbox; 215 return vbox;
201 } 216 }
202 217
203 GtkWidget* ContentPageGtk::InitFormAutofillGroup() { 218 GtkWidget* ContentPageGtk::InitFormAutofillGroup() {
204 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); 219 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
205 220
206 // Ask to save radio button. 221 // Enable radio button.
207 form_autofill_asktosave_radio_ = gtk_radio_button_new_with_label(NULL, 222 form_autofill_enable_radio_ = gtk_radio_button_new_with_label(NULL,
208 l10n_util::GetStringUTF8(IDS_OPTIONS_AUTOFILL_SAVE).c_str()); 223 l10n_util::GetStringUTF8(IDS_OPTIONS_AUTOFILL_ENABLE).c_str());
209 g_signal_connect(form_autofill_asktosave_radio_, "toggled", 224 g_signal_connect(G_OBJECT(form_autofill_enable_radio_), "toggled",
210 G_CALLBACK(OnAutofillRadioToggled), this); 225 G_CALLBACK(OnAutofillRadioToggled), this);
211 gtk_box_pack_start(GTK_BOX(vbox), form_autofill_asktosave_radio_, FALSE, 226 gtk_box_pack_start(GTK_BOX(vbox), form_autofill_enable_radio_, FALSE,
212 FALSE, 0); 227 FALSE, 0);
213 228
214 // Never save radio button. 229 // Disable radio button.
215 form_autofill_neversave_radio_ = gtk_radio_button_new_with_label_from_widget( 230 form_autofill_disable_radio_ = gtk_radio_button_new_with_label_from_widget(
216 GTK_RADIO_BUTTON(form_autofill_asktosave_radio_), 231 GTK_RADIO_BUTTON(form_autofill_enable_radio_),
217 l10n_util::GetStringUTF8(IDS_OPTIONS_AUTOFILL_NEVERSAVE).c_str()); 232 l10n_util::GetStringUTF8(IDS_OPTIONS_AUTOFILL_DISABLE).c_str());
218 g_signal_connect(form_autofill_neversave_radio_, "toggled", 233 g_signal_connect(G_OBJECT(form_autofill_disable_radio_), "toggled",
219 G_CALLBACK(OnAutofillRadioToggled), this); 234 G_CALLBACK(OnAutofillRadioToggled), this);
220 gtk_box_pack_start(GTK_BOX(vbox), form_autofill_neversave_radio_, FALSE, 235 gtk_box_pack_start(GTK_BOX(vbox), form_autofill_disable_radio_, FALSE,
221 FALSE, 0); 236 FALSE, 0);
222 237
238 GtkWidget* button_hbox = gtk_hbox_new(FALSE, gtk_util::kControlSpacing);
239 gtk_container_add(GTK_CONTAINER(vbox), button_hbox);
240
241 // Autofill button.
242 GtkWidget* autofill_button = gtk_button_new_with_label(
243 l10n_util::GetStringUTF8(IDS_OPTIONS_AUTOFILL_SETTINGS).c_str());
244 if (!personal_data_)
245 gtk_widget_set_sensitive(autofill_button, FALSE);
246
247 g_signal_connect(G_OBJECT(autofill_button), "clicked",
248 G_CALLBACK(OnAutoFillButtonClicked), this);
249 gtk_box_pack_start(GTK_BOX(button_hbox), autofill_button, FALSE, FALSE, 0);
250
223 return vbox; 251 return vbox;
224 } 252 }
225 253
226 GtkWidget* ContentPageGtk::InitBrowsingDataGroup() { 254 GtkWidget* ContentPageGtk::InitBrowsingDataGroup() {
227 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); 255 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
228 256
229 // Horizontal two button layout. 257 // Horizontal two button layout.
230 GtkWidget* button_hbox = gtk_hbox_new(FALSE, gtk_util::kControlSpacing); 258 GtkWidget* button_hbox = gtk_hbox_new(FALSE, gtk_util::kControlSpacing);
231 gtk_container_add(GTK_CONTAINER(vbox), button_hbox); 259 gtk_container_add(GTK_CONTAINER(vbox), button_hbox);
232 260
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 &kSyncLabelErrorBgColor); 397 &kSyncLabelErrorBgColor);
370 gtk_widget_modify_bg(sync_action_link_background_, GTK_STATE_NORMAL, 398 gtk_widget_modify_bg(sync_action_link_background_, GTK_STATE_NORMAL,
371 &kSyncLabelErrorBgColor); 399 &kSyncLabelErrorBgColor);
372 } else { 400 } else {
373 gtk_widget_modify_bg(sync_status_label_background_, GTK_STATE_NORMAL, NULL); 401 gtk_widget_modify_bg(sync_status_label_background_, GTK_STATE_NORMAL, NULL);
374 gtk_widget_modify_bg(sync_action_link_background_, GTK_STATE_NORMAL, NULL); 402 gtk_widget_modify_bg(sync_action_link_background_, GTK_STATE_NORMAL, NULL);
375 } 403 }
376 } 404 }
377 405
378 // static 406 // static
407 void ContentPageGtk::OnAutoFillButtonClicked(GtkButton* widget,
408 ContentPageGtk* page) {
409 DCHECK(page->personal_data_);
410 // If the personal data manager has not loaded the data yet, set ourselves as
411 // its observer so that we can listen for the OnPersonalDataLoaded signal.
412 if (!page->personal_data_->IsDataLoaded())
413 page->personal_data_->SetObserver(page);
414 else
415 page->OnPersonalDataLoaded();
416 }
417
418 // static
379 void ContentPageGtk::OnImportButtonClicked(GtkButton* widget, 419 void ContentPageGtk::OnImportButtonClicked(GtkButton* widget,
380 ContentPageGtk* page) { 420 ContentPageGtk* page) {
381 ImportDialogGtk::Show( 421 ImportDialogGtk::Show(
382 GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(widget))), 422 GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(widget))),
383 page->profile(), ALL); 423 page->profile(), ALL);
384 } 424 }
385 425
386 // static 426 // static
387 void ContentPageGtk::OnGtkThemeButtonClicked(GtkButton* widget, 427 void ContentPageGtk::OnGtkThemeButtonClicked(GtkButton* widget,
388 ContentPageGtk* page) { 428 ContentPageGtk* page) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 if (page->initializing_) 509 if (page->initializing_)
470 return; 510 return;
471 511
472 // We get two signals when selecting a radio button, one for the old radio 512 // We get two signals when selecting a radio button, one for the old radio
473 // being toggled off and one for the new one being toggled on. Ignore the 513 // being toggled off and one for the new one being toggled on. Ignore the
474 // signal for the toggling off the old button. 514 // signal for the toggling off the old button.
475 if (!gtk_toggle_button_get_active(widget)) 515 if (!gtk_toggle_button_get_active(widget))
476 return; 516 return;
477 517
478 bool enabled = gtk_toggle_button_get_active( 518 bool enabled = gtk_toggle_button_get_active(
479 GTK_TOGGLE_BUTTON(page->form_autofill_asktosave_radio_)); 519 GTK_TOGGLE_BUTTON(page->form_autofill_enable_radio_));
480 if (enabled) { 520 if (enabled) {
481 page->UserMetricsRecordAction("Options_FormAutofill_Enable", 521 page->UserMetricsRecordAction("Options_FormAutofill_Enable",
482 page->profile()->GetPrefs()); 522 page->profile()->GetPrefs());
483 } else { 523 } else {
484 page->UserMetricsRecordAction("Options_FormAutofill_Disable", 524 page->UserMetricsRecordAction("Options_FormAutofill_Disable",
485 page->profile()->GetPrefs()); 525 page->profile()->GetPrefs());
486 } 526 }
487 page->ask_to_save_form_autofill_.SetValue(enabled); 527 page->enable_form_autofill_.SetValue(enabled);
488 } 528 }
489 529
490 // static 530 // static
491 void ContentPageGtk::OnSyncStartStopButtonClicked(GtkButton* widget, 531 void ContentPageGtk::OnSyncStartStopButtonClicked(GtkButton* widget,
492 ContentPageGtk* page) { 532 ContentPageGtk* page) {
493 DCHECK(page->sync_service_); 533 DCHECK(page->sync_service_);
494 534
495 if (page->sync_service_->HasSyncSetupCompleted()) { 535 if (page->sync_service_->HasSyncSetupCompleted()) {
496 GtkWidget* dialog = gtk_message_dialog_new( 536 GtkWidget* dialog = gtk_message_dialog_new(
497 GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(widget))), 537 GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(widget))),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 574
535 // static 575 // static
536 void ContentPageGtk::OnStopSyncDialogResponse(GtkWidget* widget, int response, 576 void ContentPageGtk::OnStopSyncDialogResponse(GtkWidget* widget, int response,
537 ContentPageGtk* page) { 577 ContentPageGtk* page) {
538 if (response == GTK_RESPONSE_ACCEPT) { 578 if (response == GTK_RESPONSE_ACCEPT) {
539 page->sync_service_->DisableForUser(); 579 page->sync_service_->DisableForUser();
540 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); 580 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS);
541 } 581 }
542 gtk_widget_destroy(widget); 582 gtk_widget_destroy(widget);
543 } 583 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/options/content_page_gtk.h ('k') | chrome/browser/views/options/content_page_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698