diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-31 17:14:02 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-31 17:14:02 +0000 |
commit | 55209a4b0b801a3bc2f790d4a75d10ccfdf34f6e (patch) | |
tree | 9d78a47b203af9ebd322efcb6fc2e9f026b7e47e /chrome | |
parent | 6e9cebe49f63b4a783acb2446a5eb2e7618c6cbd (diff) | |
download | chromium_src-55209a4b0b801a3bc2f790d4a75d10ccfdf34f6e.zip chromium_src-55209a4b0b801a3bc2f790d4a75d10ccfdf34f6e.tar.gz chromium_src-55209a4b0b801a3bc2f790d4a75d10ccfdf34f6e.tar.bz2 |
Adding preferences and clear browsing data for form autofill.
BUG=None
TEST=Open the 'Clear browsing data' dialog, there should be a check box for from data. Open the options dialogue, 2nd tab, there should be an option for autofill.
Review URL: http://codereview.chromium.org/8740
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4292 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/generated_resources.grd | 17 | ||||
-rw-r--r-- | chrome/app/resources/locale_settings_en-US.rc | 2 | ||||
-rw-r--r-- | chrome/browser/browser.cc | 4 | ||||
-rw-r--r-- | chrome/browser/browsing_data_remover.cc | 5 | ||||
-rw-r--r-- | chrome/browser/browsing_data_remover.h | 3 | ||||
-rw-r--r-- | chrome/browser/views/clear_browsing_data.cc | 25 | ||||
-rw-r--r-- | chrome/browser/views/clear_browsing_data.h | 1 | ||||
-rw-r--r-- | chrome/browser/views/options/advanced_page_view.cc | 4 | ||||
-rw-r--r-- | chrome/browser/views/options/content_page_view.cc | 47 | ||||
-rw-r--r-- | chrome/browser/views/options/content_page_view.h | 6 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 6 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 2 |
12 files changed, 105 insertions, 17 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index b289a03..3a9e5a3 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -2412,14 +2412,6 @@ each locale. --> Add </message> - <!-- Advanced autofill settings --> - <message name="IDS_AUTOFILL_SETTING_WINDOWS_TITLE" desc="Title that appears in the dialogue title bar for advanced autofill settings"> - Form autofill - </message> - <message name="IDS_AUTOFILL_SAVEFORMS" desc="The autofill checkbox label"> - Save and show text typed in similar fields - </message> - <!-- HTTP POST Warning --> <message name="IDS_HTTP_POST_WARNING_TITLE" desc="Title for dialog that warns users about a navigation that results in a repost"> Confirm Form Resubmission @@ -2679,7 +2671,14 @@ each locale. --> <message name="IDS_OPTIONS_PASSWORDS_SHOWPASSWORDS" desc="The label of the 'Show passwords' button"> Show saved passwords </message> - + + <message name="IDS_AUTOFILL_SETTING_WINDOWS_GROUP_NAME" desc="The title of the form autofill group"> + Form autofill: + </message> + <message name="IDS_AUTOFILL_SAVEFORMS" desc="The autofill checkbox label"> + Save and show text typed in similar fields + </message> + <message name="IDS_OPTIONS_FONTSANDLANGUAGES_GROUP_NAME" desc="The label of the 'Fonts and Languages' group"> Fonts and Languages: </message> diff --git a/chrome/app/resources/locale_settings_en-US.rc b/chrome/app/resources/locale_settings_en-US.rc index 19606a6..100e686 100644 --- a/chrome/app/resources/locale_settings_en-US.rc +++ b/chrome/app/resources/locale_settings_en-US.rc @@ -26,7 +26,7 @@ BEGIN IDS_BUGREPORT_DIALOG_WIDTH_CHARS "85" IDS_BUGREPORT_DIALOG_HEIGHT_LINES "17" IDS_CLEARDATA_DIALOG_WIDTH_CHARS "63" - IDS_CLEARDATA_DIALOG_HEIGHT_LINES "14.5" + IDS_CLEARDATA_DIALOG_HEIGHT_LINES "15.5" IDS_IMPORT_DIALOG_WIDTH_CHARS "60" IDS_IMPORT_DIALOG_HEIGHT_LINES "14" IDS_ABOUT_DIALOG_WIDTH_CHARS "75" diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index af82f77..873b766 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -182,11 +182,15 @@ void Browser::RegisterUserPrefs(PrefService* prefs) { net::CookiePolicy::ALLOW_ALL_COOKIES); prefs->RegisterBooleanPref(prefs::kShowHomeButton, false); prefs->RegisterStringPref(prefs::kRecentlySelectedEncoding, L""); + // TODO(peterson): bug #3870 move this to the AutofillManager once it is + // checked-in. + prefs->RegisterBooleanPref(prefs::kFormAutofillEnabled, true); prefs->RegisterBooleanPref(prefs::kDeleteBrowsingHistory, true); prefs->RegisterBooleanPref(prefs::kDeleteDownloadHistory, true); prefs->RegisterBooleanPref(prefs::kDeleteCache, true); prefs->RegisterBooleanPref(prefs::kDeleteCookies, true); prefs->RegisterBooleanPref(prefs::kDeletePasswords, false); + prefs->RegisterBooleanPref(prefs::kDeleteFormData, true); prefs->RegisterIntegerPref(prefs::kDeleteTimePeriod, 0); } diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc index b1823a7..ef9e121 100644 --- a/chrome/browser/browsing_data_remover.cc +++ b/chrome/browser/browsing_data_remover.cc @@ -107,6 +107,11 @@ void BrowsingDataRemover::Remove(int remove_mask) { web_data_service->RemoveLoginsCreatedBetween(delete_begin_, delete_end_); } + if (remove_mask & REMOVE_FORM_DATA) { + // TODO(jcampan): bug #3870 hook-up Peterson's code here. + NOTREACHED() << "to be implemented"; + } + if (remove_mask & REMOVE_CACHE) { // Invoke ClearBrowsingDataView::ClearCache on the IO thread. base::Thread* thread = g_browser_process->io_thread(); diff --git a/chrome/browser/browsing_data_remover.h b/chrome/browser/browsing_data_remover.h index 81819f0..5d48606 100644 --- a/chrome/browser/browsing_data_remover.h +++ b/chrome/browser/browsing_data_remover.h @@ -25,7 +25,8 @@ class BrowsingDataRemover : public NotificationObserver { static const int REMOVE_DOWNLOADS = 1 << 1; static const int REMOVE_COOKIES = 1 << 2; static const int REMOVE_PASSWORDS = 1 << 3; - static const int REMOVE_CACHE = 1 << 4; + static const int REMOVE_FORM_DATA = 1 << 4; + static const int REMOVE_CACHE = 1 << 5; // Observer is notified when the removal is done. Done means keywords have // been deleted, cache cleared and all other tasks scheduled. diff --git a/chrome/browser/views/clear_browsing_data.cc b/chrome/browser/views/clear_browsing_data.cc index 4a948f8..b71bf99 100644 --- a/chrome/browser/views/clear_browsing_data.cc +++ b/chrome/browser/views/clear_browsing_data.cc @@ -39,6 +39,7 @@ ClearBrowsingDataView::ClearBrowsingDataView(Profile* profile) del_cache_checkbox_(NULL), del_cookies_checkbox_(NULL), del_passwords_checkbox_(NULL), + del_form_data_checkbox_(NULL), time_period_label_(NULL), time_period_combobox_(NULL), delete_in_progress_(false), @@ -94,6 +95,10 @@ void ClearBrowsingDataView::Init() { AddCheckbox(l10n_util::GetString(IDS_DEL_PASSWORDS_CHKBOX), profile_->GetPrefs()->GetBoolean(prefs::kDeletePasswords)); + del_form_data_checkbox_ = + AddCheckbox(l10n_util::GetString(IDS_DEL_FORM_DATA_CHKBOX), + profile_->GetPrefs()->GetBoolean(prefs::kDeleteFormData)); + // Add a label which appears before the combo box for the time period. time_period_label_ = new views::Label( l10n_util::GetString(IDS_CLEAR_BROWSING_DATA_TIME_LABEL)); @@ -160,11 +165,18 @@ void ClearBrowsingDataView::Layout() { kRelatedControlVerticalSpacing, sz.width(), sz.height()); + sz = del_form_data_checkbox_->GetPreferredSize(); + del_form_data_checkbox_->SetBounds(2 * kPanelHorizMargin, + del_passwords_checkbox_->y() + + del_passwords_checkbox_->height() + + kRelatedControlVerticalSpacing, + sz.width(), sz.height()); + // Time period label is next below the combo boxes. sz = time_period_label_->GetPreferredSize(); time_period_label_->SetBounds(kPanelHorizMargin, - del_passwords_checkbox_->y() + - del_passwords_checkbox_->height() + + del_form_data_checkbox_->y() + + del_form_data_checkbox_->height() + kRelatedControlVerticalSpacing + kExtraMarginForTimePeriodLabel, sz.width(), sz.height()); @@ -243,7 +255,8 @@ bool ClearBrowsingDataView::IsDialogButtonEnabled(DialogButton button) const { del_downloads_checkbox_->IsSelected() || del_cache_checkbox_->IsSelected() || del_cookies_checkbox_->IsSelected() || - del_passwords_checkbox_->IsSelected(); + del_passwords_checkbox_->IsSelected() || + del_form_data_checkbox_->IsSelected(); } return true; @@ -335,6 +348,9 @@ void ClearBrowsingDataView::ButtonPressed(views::NativeButton* sender) { else if (sender == del_passwords_checkbox_) profile_->GetPrefs()->SetBoolean(prefs::kDeletePasswords, del_passwords_checkbox_->IsSelected() ? true : false); + else if (sender == del_form_data_checkbox_) + profile_->GetPrefs()->SetBoolean(prefs::kDeleteFormData, + del_form_data_checkbox_->IsSelected() ? true : false); // When no checkbox is checked we should not have the action button enabled. // This forces the button to evaluate what state they should be in. @@ -361,6 +377,7 @@ void ClearBrowsingDataView::UpdateControlEnabledState() { del_cache_checkbox_->SetEnabled(!delete_in_progress_); del_cookies_checkbox_->SetEnabled(!delete_in_progress_); del_passwords_checkbox_->SetEnabled(!delete_in_progress_); + del_form_data_checkbox_->SetEnabled(!delete_in_progress_); time_period_combobox_->SetEnabled(!delete_in_progress_); status_label_.SetVisible(delete_in_progress_); @@ -404,6 +421,8 @@ void ClearBrowsingDataView::OnDelete() { remove_mask |= BrowsingDataRemover::REMOVE_COOKIES; if (IsCheckBoxEnabledAndSelected(del_passwords_checkbox_)) remove_mask |= BrowsingDataRemover::REMOVE_PASSWORDS; + if (IsCheckBoxEnabledAndSelected(del_form_data_checkbox_)) + remove_mask |= BrowsingDataRemover::REMOVE_FORM_DATA; if (IsCheckBoxEnabledAndSelected(del_cache_checkbox_)) remove_mask |= BrowsingDataRemover::REMOVE_CACHE; diff --git a/chrome/browser/views/clear_browsing_data.h b/chrome/browser/views/clear_browsing_data.h index f32f31d..24fe15c 100644 --- a/chrome/browser/views/clear_browsing_data.h +++ b/chrome/browser/views/clear_browsing_data.h @@ -98,6 +98,7 @@ class ClearBrowsingDataView : public views::View, views::CheckBox* del_cache_checkbox_; views::CheckBox* del_cookies_checkbox_; views::CheckBox* del_passwords_checkbox_; + views::CheckBox* del_form_data_checkbox_; views::Label* time_period_label_; views::ComboBox* time_period_combobox_; diff --git a/chrome/browser/views/options/advanced_page_view.cc b/chrome/browser/views/options/advanced_page_view.cc index 1744b59..8bb4460 100644 --- a/chrome/browser/views/options/advanced_page_view.cc +++ b/chrome/browser/views/options/advanced_page_view.cc @@ -73,8 +73,7 @@ class ResetDefaultsConfirmBox : public views::DialogDelegate { l10n_util::GetString(IDS_OPTIONS_RESET_MESSAGE).c_str(), std::wstring(), kDialogWidth); - views::Window::CreateChromeWindow(parent_hwnd, gfx::Rect(), - this)->Show(); + views::Window::CreateChromeWindow(parent_hwnd, gfx::Rect(), this)->Show(); } virtual ~ResetDefaultsConfirmBox() { } @@ -112,6 +111,7 @@ void AdvancedPageView::ResetToDefaults() { prefs::kDnsPrefetchingEnabled, prefs::kDownloadDefaultDirectory, prefs::kDownloadExtensionsToOpen, + prefs::kFormAutofillEnabled, prefs::kHomePage, prefs::kHomePageIsNewTabPage, prefs::kMixedContentFiltering, diff --git a/chrome/browser/views/options/content_page_view.cc b/chrome/browser/views/options/content_page_view.cc index 36304e7..edd83b4 100644 --- a/chrome/browser/views/options/content_page_view.cc +++ b/chrome/browser/views/options/content_page_view.cc @@ -221,6 +221,16 @@ void ContentPageView::ButtonPressed(views::NativeButton* sender) { } else if (sender == passwords_show_passwords_button_) { UserMetricsRecordAction(L"Options_ShowPasswordManager", NULL); PasswordManagerView::Show(profile()); + } else if (sender == form_autofill_checkbox_) { + bool enabled = form_autofill_checkbox_->IsSelected(); + if (enabled) { + UserMetricsRecordAction(L"Options_FormAutofill_Enable", + profile()->GetPrefs()); + } else { + UserMetricsRecordAction(L"Options_FormAutofill_Disable", + profile()->GetPrefs()); + } + form_autofill_.SetValue(enabled); } else if (sender == change_content_fonts_button_) { views::Window::CreateChromeWindow( GetRootWindow(), @@ -263,6 +273,11 @@ void ContentPageView::InitControlLayout() { layout->AddView(fonts_lang_group_); layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); + layout->StartRow(0, single_column_view_set_id); + InitFormAutofillGroup(); + layout->AddView(form_autofill_group_); + layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); + // Init member prefs so we can update the controls if prefs change. default_download_location_.Init(prefs::kDownloadDefaultDirectory, profile()->GetPrefs(), this); @@ -270,6 +285,7 @@ void ContentPageView::InitControlLayout() { profile()->GetPrefs(), this); ask_to_save_passwords_.Init(prefs::kPasswordManagerEnabled, profile()->GetPrefs(), this); + form_autofill_.Init(prefs::kFormAutofillEnabled, profile()->GetPrefs(), this); } void ContentPageView::NotifyPrefChanged(const std::wstring* pref_name) { @@ -287,6 +303,9 @@ void ContentPageView::NotifyPrefChanged(const std::wstring* pref_name) { passwords_neversave_radio_->SetIsSelected(true); } } + if (!pref_name || *pref_name == prefs::kFormAutofillEnabled) { + form_autofill_checkbox_->SetIsSelected(form_autofill_.GetValue()); + } } /////////////////////////////////////////////////////////////////////////////// @@ -399,6 +418,32 @@ void ContentPageView::InitPasswordSavingGroup() { true); } +void ContentPageView::InitFormAutofillGroup() { + form_autofill_checkbox_ = new views::CheckBox( + l10n_util::GetString(IDS_AUTOFILL_SAVEFORMS)); + form_autofill_checkbox_->SetListener(this); + form_autofill_checkbox_->SetMultiLine(true); + + using views::GridLayout; + using views::ColumnSet; + + views::View* contents = new views::View; + GridLayout* layout = new GridLayout(contents); + contents->SetLayoutManager(layout); + + const int single_column_view_set_id = 1; + ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id); + column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, + GridLayout::USE_PREF, 0, 0); + + layout->StartRow(0, single_column_view_set_id); + layout->AddView(form_autofill_checkbox_); + + form_autofill_group_ = new OptionsGroupView( + contents, l10n_util::GetString(IDS_AUTOFILL_SETTING_WINDOWS_GROUP_NAME), + L"", false); +} + void ContentPageView::InitFontsLangGroup() { fonts_and_languages_label_ = new views::Label( l10n_util::GetString(IDS_OPTIONS_FONTSETTINGS_INFO)); @@ -429,7 +474,7 @@ void ContentPageView::InitFontsLangGroup() { fonts_lang_group_ = new OptionsGroupView( contents, l10n_util::GetString(IDS_OPTIONS_FONTSANDLANGUAGES_GROUP_NAME), - L"", false); + L"", true); } void ContentPageView::UpdateDownloadDirectoryDisplay() { diff --git a/chrome/browser/views/options/content_page_view.h b/chrome/browser/views/options/content_page_view.h index 1363bb9..93a3a49 100644 --- a/chrome/browser/views/options/content_page_view.h +++ b/chrome/browser/views/options/content_page_view.h @@ -50,6 +50,7 @@ class ContentPageView : public OptionsPageView, // Init all the dialog controls. void InitDownloadLocation(); void InitPasswordSavingGroup(); + void InitFormAutofillGroup(); void InitFontsLangGroup(); // Updates the directory displayed in the default download location view with @@ -69,6 +70,10 @@ class ContentPageView : public OptionsPageView, views::RadioButton* passwords_neversave_radio_; views::NativeButton* passwords_show_passwords_button_; + // Controls for the Form Autofill group + OptionsGroupView* form_autofill_group_; + views::CheckBox* form_autofill_checkbox_; + // Controls for the Popup Blocking group. OptionsGroupView* popups_group_; views::RadioButton* popups_show_minimized_radio_; @@ -82,6 +87,7 @@ class ContentPageView : public OptionsPageView, StringPrefMember default_download_location_; BooleanPrefMember ask_for_save_location_; BooleanPrefMember ask_to_save_passwords_; + BooleanPrefMember form_autofill_; DISALLOW_EVIL_CONSTRUCTORS(ContentPageView); }; diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index a83475e..0cb1b2c 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -130,6 +130,11 @@ const wchar_t kAlwaysCreateDestinationsTab[] = // passwords and fill in known passwords). const wchar_t kPasswordManagerEnabled[] = L"profile.password_manager_enabled"; +// Boolean that is true if the form autofill is on (will record values entered +// in text inputs in forms and shows them in a popup when user type in a text +// input with the same name later on). +const wchar_t kFormAutofillEnabled[] = L"profile.form_autofill_enabled"; + // Boolean that is true when SafeBrowsing is enabled. const wchar_t kSafeBrowsingEnabled[] = L"safebrowsing.enabled"; @@ -200,6 +205,7 @@ const wchar_t kDeleteDownloadHistory[] = const wchar_t kDeleteCache[] = L"browser.clear_data.cache"; const wchar_t kDeleteCookies[] = L"browser.clear_data.cookies"; const wchar_t kDeletePasswords[] = L"browser.clear_data.passwords"; +const wchar_t kDeleteFormData[] = L"browser.clear_data.form_data"; const wchar_t kDeleteTimePeriod[] = L"browser.clear_data.time_period"; // Integer prefs giving the widths of the columns in the bookmark table. Two diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 233c2e3..e5ce12b 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -47,6 +47,7 @@ extern const wchar_t kWebKitTextAreasAreResizable[]; extern const wchar_t kWebKitJavaEnabled[]; extern const wchar_t kAlwaysCreateDestinationsTab[]; extern const wchar_t kPasswordManagerEnabled[]; +extern const wchar_t kFormAutofillEnabled[]; extern const wchar_t kSafeBrowsingEnabled[]; extern const wchar_t kSearchSuggestEnabled[]; extern const wchar_t kCookieBehavior[]; @@ -68,6 +69,7 @@ extern const wchar_t kDeleteDownloadHistory[]; extern const wchar_t kDeleteCache[]; extern const wchar_t kDeleteCookies[]; extern const wchar_t kDeletePasswords[]; +extern const wchar_t kDeleteFormData[]; extern const wchar_t kBookmarkTableNameWidth1[]; extern const wchar_t kBookmarkTableURLWidth1[]; extern const wchar_t kBookmarkTableNameWidth2[]; |