summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-17 19:32:10 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-17 19:32:10 +0000
commit6bad2e767545973222ff72d69f48a0664dc7c422 (patch)
tree1a7573dbf9b45b906ca8fd67634bc7134e6963c4 /chrome
parent4d71f12a4b02aacd35d50c2b38d3b8d06d05f5ff (diff)
downloadchromium_src-6bad2e767545973222ff72d69f48a0664dc7c422.zip
chromium_src-6bad2e767545973222ff72d69f48a0664dc7c422.tar.gz
chromium_src-6bad2e767545973222ff72d69f48a0664dc7c422.tar.bz2
Linux: Implement the new AutoFill section of the Options dialog.
* Updated the text of the radio buttons. * Added a button that opens the AutoFill dialog. BUG=33025 TEST=manually Patch from Thiago Farina <thiago.farina@gmail.com> Review URL: http://codereview.chromium.org/579020 Review URL: http://codereview.chromium.org/610003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39251 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/generated_resources.grd8
-rw-r--r--chrome/app/nibs/Preferences.xib4
-rw-r--r--chrome/browser/autofill/autofill_dialog_gtk.cc7
-rw-r--r--chrome/browser/gtk/options/content_page_gtk.cc76
-rw-r--r--chrome/browser/gtk/options/content_page_gtk.h20
-rw-r--r--chrome/browser/views/options/content_page_view.cc34
-rw-r--r--chrome/browser/views/options/content_page_view.h4
7 files changed, 103 insertions, 50 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 556df69..502d4f8 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -4835,11 +4835,11 @@ Keep your key file in a safe place. You will need it to create new versions of y
Form Autofill
</message>
</if>
- <message name="IDS_OPTIONS_AUTOFILL_SAVE" desc="The label of the 'Ask me to save autofill' radio button">
- Save text from forms to make them easier to fill out
+ <message name="IDS_OPTIONS_AUTOFILL_ENABLE" desc="The label of the 'Ask me to enable autofill' radio button">
+ Enable Autofill to fill in web forms with a single click
</message>
- <message name="IDS_OPTIONS_AUTOFILL_NEVERSAVE" desc="The label of the 'Never save autofill' radio button">
- Never save text from forms
+ <message name="IDS_OPTIONS_AUTOFILL_DISABLE" desc="The label of the 'Disable autofill' radio button">
+ Disable Autofill
</message>
<message name="IDS_OPTIONS_AUTOFILL_SETTINGS" desc="The label of the 'Change autofill settings' button">
Change autofill settings
diff --git a/chrome/app/nibs/Preferences.xib b/chrome/app/nibs/Preferences.xib
index 12ec5d1..cb66596c 100644
--- a/chrome/app/nibs/Preferences.xib
+++ b/chrome/app/nibs/Preferences.xib
@@ -2089,7 +2089,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<object class="NSButtonCell" id="674682819">
<int key="NSCellFlags">-2080244224</int>
<int key="NSCellFlags2">0</int>
- <string key="NSContents">^IDS_OPTIONS_AUTOFILL_SAVE</string>
+ <string key="NSContents">^IDS_OPTIONS_AUTOFILL_ENABLE</string>
<reference key="NSSupport" ref="445696277"/>
<int key="NSTag">1</int>
<reference key="NSControlView" ref="854747859"/>
@@ -2104,7 +2104,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<object class="NSButtonCell" id="201008548">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">0</int>
- <string key="NSContents">^IDS_OPTIONS_AUTOFILL_NEVERSAVE</string>
+ <string key="NSContents">^IDS_OPTIONS_AUTOFILL_DISABLE</string>
<reference key="NSSupport" ref="445696277"/>
<reference key="NSControlView" ref="854747859"/>
<int key="NSButtonFlags">1211912703</int>
diff --git a/chrome/browser/autofill/autofill_dialog_gtk.cc b/chrome/browser/autofill/autofill_dialog_gtk.cc
index 20f673d..df55e3a 100644
--- a/chrome/browser/autofill/autofill_dialog_gtk.cc
+++ b/chrome/browser/autofill/autofill_dialog_gtk.cc
@@ -138,9 +138,10 @@ void FormTableSetLabel(
// We have two table rows per form table row.
row *= 2;
- const char* text =
- (label_id) ? l10n_util::GetStringUTF8(label_id).c_str() : 0;
- GtkWidget* label = gtk_label_new(text);
+ std::string text;
+ if (label_id)
+ text = l10n_util::GetStringUTF8(label_id);
+ GtkWidget* label = gtk_label_new(text.c_str());
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_table_attach(GTK_TABLE(table), label,
col, col + len, // Left col, right col.
diff --git a/chrome/browser/gtk/options/content_page_gtk.cc b/chrome/browser/gtk/options/content_page_gtk.cc
index 6d46b92..901c70a 100644
--- a/chrome/browser/gtk/options/content_page_gtk.cc
+++ b/chrome/browser/gtk/options/content_page_gtk.cc
@@ -72,8 +72,8 @@ ContentPageGtk::ContentPageGtk(Profile* profile)
// Add preferences observers.
ask_to_save_passwords_.Init(prefs::kPasswordManagerEnabled,
profile->GetPrefs(), this);
- ask_to_save_form_autofill_.Init(prefs::kFormAutofillEnabled,
- profile->GetPrefs(), this);
+ enable_form_autofill_.Init(prefs::kFormAutofillEnabled,
+ profile->GetPrefs(), this);
if (browser_defaults::kCanToggleSystemTitleBar) {
use_custom_chrome_frame_.Init(prefs::kUseCustomChromeFrame,
profile->GetPrefs(), this);
@@ -85,11 +85,15 @@ ContentPageGtk::ContentPageGtk(Profile* profile)
registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
NotificationService::AllSources());
ObserveThemeChanged();
+
+ personal_data_ = profile->GetPersonalDataManager();
}
ContentPageGtk::~ContentPageGtk() {
if (sync_service_)
sync_service_->RemoveObserver(this);
+ if (personal_data_)
+ personal_data_->RemoveObserver(this);
}
///////////////////////////////////////////////////////////////////////////////
@@ -121,12 +125,12 @@ void ContentPageGtk::NotifyPrefChanged(const std::wstring* pref_name) {
}
}
if (!pref_name || *pref_name == prefs::kFormAutofillEnabled) {
- if (ask_to_save_form_autofill_.GetValue()) {
+ if (enable_form_autofill_.GetValue()) {
gtk_toggle_button_set_active(
- GTK_TOGGLE_BUTTON(form_autofill_asktosave_radio_), TRUE);
+ GTK_TOGGLE_BUTTON(form_autofill_enable_radio_), TRUE);
} else {
gtk_toggle_button_set_active(
- GTK_TOGGLE_BUTTON(form_autofill_neversave_radio_), TRUE);
+ GTK_TOGGLE_BUTTON(form_autofill_disable_radio_), TRUE);
}
}
if (browser_defaults::kCanToggleSystemTitleBar &&
@@ -166,6 +170,17 @@ void ContentPageGtk::ObserveThemeChanged() {
gtk_widget_set_sensitive(themes_reset_button_, !is_classic_theme);
}
+void ContentPageGtk::OnPersonalDataLoaded() {
+ DCHECK(personal_data_);
+ // We might have been alerted that the PersonalDataManager has loaded, so
+ // remove ourselves as observer.
+ personal_data_->RemoveObserver(this);
+
+ ShowAutoFillDialog(
+ personal_data_, personal_data_->profiles(),
+ personal_data_->credit_cards());
+}
+
GtkWidget* ContentPageGtk::InitPasswordSavingGroup() {
GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
@@ -203,23 +218,36 @@ GtkWidget* ContentPageGtk::InitPasswordSavingGroup() {
GtkWidget* ContentPageGtk::InitFormAutofillGroup() {
GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
- // Ask to save radio button.
- form_autofill_asktosave_radio_ = gtk_radio_button_new_with_label(NULL,
- l10n_util::GetStringUTF8(IDS_OPTIONS_AUTOFILL_SAVE).c_str());
- g_signal_connect(form_autofill_asktosave_radio_, "toggled",
+ // Enable radio button.
+ form_autofill_enable_radio_ = gtk_radio_button_new_with_label(NULL,
+ l10n_util::GetStringUTF8(IDS_OPTIONS_AUTOFILL_ENABLE).c_str());
+ g_signal_connect(G_OBJECT(form_autofill_enable_radio_), "toggled",
G_CALLBACK(OnAutofillRadioToggled), this);
- gtk_box_pack_start(GTK_BOX(vbox), form_autofill_asktosave_radio_, FALSE,
+ gtk_box_pack_start(GTK_BOX(vbox), form_autofill_enable_radio_, FALSE,
FALSE, 0);
- // Never save radio button.
- form_autofill_neversave_radio_ = gtk_radio_button_new_with_label_from_widget(
- GTK_RADIO_BUTTON(form_autofill_asktosave_radio_),
- l10n_util::GetStringUTF8(IDS_OPTIONS_AUTOFILL_NEVERSAVE).c_str());
- g_signal_connect(form_autofill_neversave_radio_, "toggled",
+ // Disable radio button.
+ form_autofill_disable_radio_ = gtk_radio_button_new_with_label_from_widget(
+ GTK_RADIO_BUTTON(form_autofill_enable_radio_),
+ l10n_util::GetStringUTF8(IDS_OPTIONS_AUTOFILL_DISABLE).c_str());
+ g_signal_connect(G_OBJECT(form_autofill_disable_radio_), "toggled",
G_CALLBACK(OnAutofillRadioToggled), this);
- gtk_box_pack_start(GTK_BOX(vbox), form_autofill_neversave_radio_, FALSE,
+ gtk_box_pack_start(GTK_BOX(vbox), form_autofill_disable_radio_, FALSE,
FALSE, 0);
+ GtkWidget* button_hbox = gtk_hbox_new(FALSE, gtk_util::kControlSpacing);
+ gtk_container_add(GTK_CONTAINER(vbox), button_hbox);
+
+ // Autofill button.
+ GtkWidget* autofill_button = gtk_button_new_with_label(
+ l10n_util::GetStringUTF8(IDS_OPTIONS_AUTOFILL_SETTINGS).c_str());
+ if (!personal_data_)
+ gtk_widget_set_sensitive(autofill_button, FALSE);
+
+ g_signal_connect(G_OBJECT(autofill_button), "clicked",
+ G_CALLBACK(OnAutoFillButtonClicked), this);
+ gtk_box_pack_start(GTK_BOX(button_hbox), autofill_button, FALSE, FALSE, 0);
+
return vbox;
}
@@ -376,6 +404,18 @@ void ContentPageGtk::UpdateSyncControls() {
}
// static
+void ContentPageGtk::OnAutoFillButtonClicked(GtkButton* widget,
+ ContentPageGtk* page) {
+ DCHECK(page->personal_data_);
+ // If the personal data manager has not loaded the data yet, set ourselves as
+ // its observer so that we can listen for the OnPersonalDataLoaded signal.
+ if (!page->personal_data_->IsDataLoaded())
+ page->personal_data_->SetObserver(page);
+ else
+ page->OnPersonalDataLoaded();
+}
+
+// static
void ContentPageGtk::OnImportButtonClicked(GtkButton* widget,
ContentPageGtk* page) {
ImportDialogGtk::Show(
@@ -476,7 +516,7 @@ void ContentPageGtk::OnAutofillRadioToggled(GtkToggleButton* widget,
return;
bool enabled = gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON(page->form_autofill_asktosave_radio_));
+ GTK_TOGGLE_BUTTON(page->form_autofill_enable_radio_));
if (enabled) {
page->UserMetricsRecordAction("Options_FormAutofill_Enable",
page->profile()->GetPrefs());
@@ -484,7 +524,7 @@ void ContentPageGtk::OnAutofillRadioToggled(GtkToggleButton* widget,
page->UserMetricsRecordAction("Options_FormAutofill_Disable",
page->profile()->GetPrefs());
}
- page->ask_to_save_form_autofill_.SetValue(enabled);
+ page->enable_form_autofill_.SetValue(enabled);
}
// static
diff --git a/chrome/browser/gtk/options/content_page_gtk.h b/chrome/browser/gtk/options/content_page_gtk.h
index 610c5ab..1dbab9c 100644
--- a/chrome/browser/gtk/options/content_page_gtk.h
+++ b/chrome/browser/gtk/options/content_page_gtk.h
@@ -7,13 +7,15 @@
#include <gtk/gtk.h>
+#include "chrome/browser/autofill/personal_data_manager.h"
#include "chrome/browser/options_page_base.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/common/pref_member.h"
class ContentPageGtk : public OptionsPageBase,
- public ProfileSyncServiceObserver {
+ public ProfileSyncServiceObserver,
+ public PersonalDataManager::Observer {
public:
explicit ContentPageGtk(Profile* profile);
~ContentPageGtk();
@@ -37,6 +39,9 @@ class ContentPageGtk : public OptionsPageBase,
const NotificationSource& source,
const NotificationDetails& details);
+ // Overriden from PersonalDataManager::Observer.
+ virtual void OnPersonalDataLoaded();
+
// Update content area after a theme changed.
void ObserveThemeChanged();
@@ -47,6 +52,9 @@ class ContentPageGtk : public OptionsPageBase,
GtkWidget* InitThemesGroup();
GtkWidget* InitSyncGroup();
+ // Callback for autofill button.
+ static void OnAutoFillButtonClicked(GtkButton* widget, ContentPageGtk* page);
+
// Callback for import button.
static void OnImportButtonClicked(GtkButton* widget, ContentPageGtk* page);
@@ -96,8 +104,8 @@ class ContentPageGtk : public OptionsPageBase,
GtkWidget* passwords_neversave_radio_;
// Widgets for the Form Autofill group.
- GtkWidget* form_autofill_asktosave_radio_;
- GtkWidget* form_autofill_neversave_radio_;
+ GtkWidget* form_autofill_enable_radio_;
+ GtkWidget* form_autofill_disable_radio_;
// Widgets for the Appearance group.
GtkWidget* system_title_bar_show_radio_;
@@ -119,7 +127,7 @@ class ContentPageGtk : public OptionsPageBase,
// Pref members.
BooleanPrefMember ask_to_save_passwords_;
- BooleanPrefMember ask_to_save_form_autofill_;
+ BooleanPrefMember enable_form_autofill_;
BooleanPrefMember use_custom_chrome_frame_;
// Flag to ignore gtk callbacks while we are loading prefs, to avoid
@@ -132,6 +140,10 @@ class ContentPageGtk : public OptionsPageBase,
// and NULL-ed out on destruction.
ProfileSyncService* sync_service_;
+ // The personal data manager, used to save and load personal data to/from the
+ // web database. This can be NULL.
+ PersonalDataManager* personal_data_;
+
DISALLOW_COPY_AND_ASSIGN(ContentPageGtk);
};
diff --git a/chrome/browser/views/options/content_page_view.cc b/chrome/browser/views/options/content_page_view.cc
index bc27afc..89f6fb2 100644
--- a/chrome/browser/views/options/content_page_view.cc
+++ b/chrome/browser/views/options/content_page_view.cc
@@ -53,8 +53,8 @@ ContentPageView::ContentPageView(Profile* profile)
passwords_asktosave_radio_(NULL),
passwords_neversave_radio_(NULL),
change_autofill_settings_button_(NULL),
- form_autofill_asktosave_radio_(NULL),
- form_autofill_neversave_radio_(NULL),
+ form_autofill_enable_radio_(NULL),
+ form_autofill_disable_radio_(NULL),
themes_group_(NULL),
themes_reset_button_(NULL),
themes_gallery_link_(NULL),
@@ -96,9 +96,9 @@ void ContentPageView::ButtonPressed(
profile()->GetPrefs());
}
ask_to_save_passwords_.SetValue(enabled);
- } else if (sender == form_autofill_asktosave_radio_ ||
- sender == form_autofill_neversave_radio_) {
- bool enabled = form_autofill_asktosave_radio_->checked();
+ } else if (sender == form_autofill_enable_radio_ ||
+ sender == form_autofill_disable_radio_) {
+ bool enabled = form_autofill_enable_radio_->checked();
if (enabled) {
UserMetricsRecordAction("Options_FormAutofill_Enable",
profile()->GetPrefs());
@@ -223,9 +223,9 @@ void ContentPageView::NotifyPrefChanged(const std::wstring* pref_name) {
}
if (!pref_name || *pref_name == prefs::kFormAutofillEnabled) {
if (ask_to_save_form_autofill_.GetValue()) {
- form_autofill_asktosave_radio_->SetChecked(true);
+ form_autofill_enable_radio_->SetChecked(true);
} else {
- form_autofill_neversave_radio_->SetChecked(true);
+ form_autofill_disable_radio_->SetChecked(true);
}
}
if (!pref_name || *pref_name == prefs::kCurrentThemeID) {
@@ -310,16 +310,16 @@ void ContentPageView::InitPasswordSavingGroup() {
}
void ContentPageView::InitFormAutofillGroup() {
- form_autofill_asktosave_radio_ = new views::RadioButton(
- l10n_util::GetString(IDS_OPTIONS_AUTOFILL_SAVE),
+ form_autofill_enable_radio_ = new views::RadioButton(
+ l10n_util::GetString(IDS_OPTIONS_AUTOFILL_ENABLE),
kFormAutofillRadioGroup);
- form_autofill_asktosave_radio_->set_listener(this);
- form_autofill_asktosave_radio_->SetMultiLine(true);
- form_autofill_neversave_radio_ = new views::RadioButton(
- l10n_util::GetString(IDS_OPTIONS_AUTOFILL_NEVERSAVE),
+ form_autofill_enable_radio_->set_listener(this);
+ form_autofill_enable_radio_->SetMultiLine(true);
+ form_autofill_disable_radio_ = new views::RadioButton(
+ l10n_util::GetString(IDS_OPTIONS_AUTOFILL_DISABLE),
kFormAutofillRadioGroup);
- form_autofill_neversave_radio_->set_listener(this);
- form_autofill_neversave_radio_->SetMultiLine(true);
+ form_autofill_disable_radio_->set_listener(this);
+ form_autofill_disable_radio_->SetMultiLine(true);
change_autofill_settings_button_ = new views::NativeButton(
this, l10n_util::GetString(IDS_OPTIONS_AUTOFILL_SETTINGS));
@@ -344,10 +344,10 @@ void ContentPageView::InitFormAutofillGroup() {
GridLayout::USE_PREF, 0, 0);
layout->StartRow(0, fill_column_view_set_id);
- layout->AddView(form_autofill_asktosave_radio_);
+ layout->AddView(form_autofill_enable_radio_);
layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
layout->StartRow(0, fill_column_view_set_id);
- layout->AddView(form_autofill_neversave_radio_);
+ layout->AddView(form_autofill_disable_radio_);
layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
layout->StartRow(0, leading_column_view_set_id);
layout->AddView(change_autofill_settings_button_);
diff --git a/chrome/browser/views/options/content_page_view.h b/chrome/browser/views/options/content_page_view.h
index aa08199..767ab9b 100644
--- a/chrome/browser/views/options/content_page_view.h
+++ b/chrome/browser/views/options/content_page_view.h
@@ -88,8 +88,8 @@ class ContentPageView : public OptionsPageView,
// Controls for the Form Autofill group
views::NativeButton* change_autofill_settings_button_;
OptionsGroupView* form_autofill_group_;
- views::RadioButton* form_autofill_asktosave_radio_;
- views::RadioButton* form_autofill_neversave_radio_;
+ views::RadioButton* form_autofill_enable_radio_;
+ views::RadioButton* form_autofill_disable_radio_;
// Controls for the Themes group
OptionsGroupView* themes_group_;