diff options
author | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-13 23:25:01 +0000 |
---|---|---|
committer | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-13 23:25:01 +0000 |
commit | d8241d65b71b1409c9f6581b9ceee68f9bf35c3e (patch) | |
tree | 6af0e3f255fbea9b0dcb28644f10feb1269fb26f /chrome | |
parent | 88335d31a472e3782a931f7706e1aba13753254b (diff) | |
download | chromium_src-d8241d65b71b1409c9f6581b9ceee68f9bf35c3e.zip chromium_src-d8241d65b71b1409c9f6581b9ceee68f9bf35c3e.tar.gz chromium_src-d8241d65b71b1409c9f6581b9ceee68f9bf35c3e.tar.bz2 |
Add cookie behavior combobox.
BUG=11507
TEST=Disable cookie saving and try to login to iGoogle. Reenable and try again.
Review URL: http://codereview.chromium.org/149574
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20564 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/gtk/options/advanced_contents_gtk.cc | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/chrome/browser/gtk/options/advanced_contents_gtk.cc b/chrome/browser/gtk/options/advanced_contents_gtk.cc index d5f4259..ade476b 100644 --- a/chrome/browser/gtk/options/advanced_contents_gtk.cc +++ b/chrome/browser/gtk/options/advanced_contents_gtk.cc @@ -18,6 +18,7 @@ #include "chrome/installer/util/google_update_settings.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" +#include "net/base/cookie_policy.h" namespace { @@ -122,6 +123,8 @@ class PrivacySection : public OptionsPageBase { PrivacySection* options_window); static void OnLoggingChange(GtkWidget* widget, PrivacySection* options_window); + static void OnCookieBehaviorChanged(GtkComboBox* combo_box, + PrivacySection* privacy_section); // The widget containing the options for this section. GtkWidget* page_; @@ -132,6 +135,7 @@ class PrivacySection : public OptionsPageBase { GtkWidget* enable_dns_prefetching_checkbox_; GtkWidget* enable_safe_browsing_checkbox_; GtkWidget* reporting_enabled_checkbox_; + GtkWidget* cookie_behavior_combobox_; // Preferences for this section: BooleanPrefMember alternate_error_pages_; @@ -196,7 +200,27 @@ PrivacySection::PrivacySection(Profile* profile) g_signal_connect(reporting_enabled_checkbox_, "clicked", G_CALLBACK(OnLoggingChange), this); - // TODO(mattm): cookie combobox and button + cookie_behavior_combobox_ = gtk_combo_box_new_text(); + gtk_combo_box_append_text( + GTK_COMBO_BOX(cookie_behavior_combobox_), + l10n_util::GetStringUTF8(IDS_OPTIONS_COOKIES_ACCEPT_ALL_COOKIES).c_str()); + gtk_combo_box_append_text( + GTK_COMBO_BOX(cookie_behavior_combobox_), + l10n_util::GetStringUTF8( + IDS_OPTIONS_COOKIES_RESTRICT_THIRD_PARTY_COOKIES).c_str()); + gtk_combo_box_append_text( + GTK_COMBO_BOX(cookie_behavior_combobox_), + l10n_util::GetStringUTF8(IDS_OPTIONS_COOKIES_BLOCK_ALL_COOKIES).c_str()); + g_signal_connect(G_OBJECT(cookie_behavior_combobox_), "changed", + G_CALLBACK(OnCookieBehaviorChanged), this); + + GtkWidget* cookie_controls = gtk_util::CreateLabeledControlsGroup( + l10n_util::GetStringUTF8(IDS_OPTIONS_COOKIES_ACCEPT_LABEL).c_str(), + cookie_behavior_combobox_, + NULL); + gtk_box_pack_start(GTK_BOX(page_), cookie_controls, FALSE, FALSE, 0); + + // TODO(mattm): show cookies button gtk_box_pack_start(GTK_BOX(page_), gtk_label_new("TODO rest of the privacy options"), FALSE, FALSE, 0); @@ -294,6 +318,28 @@ void PrivacySection::OnLoggingChange(GtkWidget* widget, GoogleUpdateSettings::SetCollectStatsConsent(enabled); } +// static +void PrivacySection::OnCookieBehaviorChanged(GtkComboBox* combo_box, + PrivacySection* privacy_section) { + if (privacy_section->initializing_) + return; + net::CookiePolicy::Type cookie_policy = + net::CookiePolicy::FromInt(gtk_combo_box_get_active(combo_box)); + const wchar_t* kUserMetrics[] = { + L"Options_AllowAllCookies", + L"Options_BlockThirdPartyCookies", + L"Options_BlockAllCookies" + }; + if (cookie_policy < 0 || + static_cast<size_t>(cookie_policy) >= arraysize(kUserMetrics)) { + NOTREACHED(); + return; + } + privacy_section->UserMetricsRecordAction( + kUserMetrics[cookie_policy], privacy_section->profile()->GetPrefs()); + privacy_section->cookie_behavior_.SetValue(cookie_policy); +} + void PrivacySection::NotifyPrefChanged(const std::wstring* pref_name) { initializing_ = true; if (!pref_name || *pref_name == prefs::kAlternateErrorPagesEnabled) { @@ -322,7 +368,9 @@ void PrivacySection::NotifyPrefChanged(const std::wstring* pref_name) { // TODO(mattm): ResolveMetricsReportingEnabled()? } if (!pref_name || *pref_name == prefs::kCookieBehavior) { - // TODO(mattm): set cookie combobox state + gtk_combo_box_set_active( + GTK_COMBO_BOX(cookie_behavior_combobox_), + net::CookiePolicy::FromInt(cookie_behavior_.GetValue())); } initializing_ = false; } |