diff options
author | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-31 13:01:05 +0000 |
---|---|---|
committer | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-31 13:01:05 +0000 |
commit | 11c7220b3222487762cb387151c5716731e6efc9 (patch) | |
tree | 2be3f83b4f2ea5af2b5a63b8d0a4bd71dd8eae4c /chrome | |
parent | 7cd8724ff2b6a0b5b25414afa12f3877eaf4f421 (diff) | |
download | chromium_src-11c7220b3222487762cb387151c5716731e6efc9.zip chromium_src-11c7220b3222487762cb387151c5716731e6efc9.tar.gz chromium_src-11c7220b3222487762cb387151c5716731e6efc9.tar.bz2 |
Adds a geolocation tab in the content settings dialog on Linux.
This is based on http://codereview.chromium.org/1526004/show.
BUG=39816
TEST=Open content settings dialog, observe Location tab. (Note: Exceptions button is not wired up.)
Review URL: http://codereview.chromium.org/1590002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43207 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
4 files changed, 73 insertions, 23 deletions
diff --git a/chrome/browser/gtk/options/content_filter_page_gtk.cc b/chrome/browser/gtk/options/content_filter_page_gtk.cc index a445aa1..5732051 100644 --- a/chrome/browser/gtk/options/content_filter_page_gtk.cc +++ b/chrome/browser/gtk/options/content_filter_page_gtk.cc @@ -6,6 +6,7 @@ #include "app/l10n_util.h" #include "chrome/browser/browser.h" +#include "chrome/browser/geolocation/geolocation_content_settings_map.h" #include "chrome/browser/host_content_settings_map.h" #include "chrome/browser/profile.h" #include "chrome/browser/gtk/browser_window_gtk.h" @@ -21,17 +22,18 @@ ContentFilterPageGtk::ContentFilterPageGtk(Profile* profile, ContentSettingsType content_type) : OptionsPageBase(profile), - content_type_(content_type) { - static const int kTitleIDs[CONTENT_SETTINGS_NUM_TYPES] = { + content_type_(content_type), + ask_radio_(NULL) { + static const int kTitleIDs[] = { 0, // This dialog isn't used for cookies. IDS_IMAGES_SETTING_LABEL, IDS_JS_SETTING_LABEL, IDS_PLUGIN_SETTING_LABEL, IDS_POPUP_SETTING_LABEL, + IDS_GEOLOCATION_SETTING_LABEL, }; - DCHECK_EQ(arraysize(kTitleIDs), - static_cast<size_t>(CONTENT_SETTINGS_NUM_TYPES)); - + COMPILE_ASSERT(arraysize(kTitleIDs) == CONTENT_SETTINGS_NUM_TYPES, + kTitleIDs_IncorrectSize); OptionsLayoutBuilderGtk options_builder; options_builder.AddOptionGroup( l10n_util::GetStringUTF8(kTitleIDs[content_type_]), @@ -46,39 +48,65 @@ ContentFilterPageGtk::~ContentFilterPageGtk() { GtkWidget* ContentFilterPageGtk::InitGroup() { GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); - static const int kAllowIDs[CONTENT_SETTINGS_NUM_TYPES] = { + static const int kAllowIDs[] = { 0, // This dialog isn't used for cookies. IDS_IMAGES_LOAD_RADIO, IDS_JS_ALLOW_RADIO, IDS_PLUGIN_LOAD_RADIO, IDS_POPUP_ALLOW_RADIO, + IDS_GEOLOCATION_ALLOW_RADIO, }; - DCHECK_EQ(arraysize(kAllowIDs), - static_cast<size_t>(CONTENT_SETTINGS_NUM_TYPES)); + COMPILE_ASSERT(arraysize(kAllowIDs) == CONTENT_SETTINGS_NUM_TYPES, + kAllowIDs_IncorrectSize); allow_radio_ = gtk_radio_button_new_with_label(NULL, l10n_util::GetStringUTF8(kAllowIDs[content_type_]).c_str()); gtk_box_pack_start(GTK_BOX(vbox), allow_radio_, FALSE, FALSE, 0); - static const int kBlockIDs[CONTENT_SETTINGS_NUM_TYPES] = { + static const int kAskIDs[] = { + 0, // This dialog isn't used for cookies. + 0, + 0, + 0, + 0, + IDS_GEOLOCATION_ASK_RADIO, + }; + COMPILE_ASSERT(arraysize(kAskIDs) == CONTENT_SETTINGS_NUM_TYPES, + kAskIDs_IncorrectSize); + if (kAskIDs[content_type_]) { + ask_radio_ = gtk_radio_button_new_with_label_from_widget( + GTK_RADIO_BUTTON(allow_radio_), + l10n_util::GetStringUTF8(kAskIDs[content_type_]).c_str()); + gtk_box_pack_start(GTK_BOX(vbox), ask_radio_, FALSE, FALSE, 0); + } + + static const int kBlockIDs[] = { 0, // This dialog isn't used for cookies. IDS_IMAGES_NOLOAD_RADIO, IDS_JS_DONOTALLOW_RADIO, IDS_PLUGIN_NOLOAD_RADIO, IDS_POPUP_BLOCK_RADIO, + IDS_GEOLOCATION_BLOCK_RADIO, }; - DCHECK_EQ(arraysize(kBlockIDs), - static_cast<size_t>(CONTENT_SETTINGS_NUM_TYPES)); + COMPILE_ASSERT(arraysize(kBlockIDs) == CONTENT_SETTINGS_NUM_TYPES, + kBlockIDs_IncorrectSize); block_radio_ = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(allow_radio_), l10n_util::GetStringUTF8(kBlockIDs[content_type_]).c_str()); gtk_box_pack_start(GTK_BOX(vbox), block_radio_, FALSE, FALSE, 0); - ContentSetting default_setting = profile()->GetHostContentSettingsMap()-> - GetDefaultContentSetting(content_type_); + ContentSetting default_setting = + content_type_ == CONTENT_SETTINGS_TYPE_GEOLOCATION ? + profile()->GetGeolocationContentSettingsMap()-> + GetDefaultContentSetting() : + profile()->GetHostContentSettingsMap()-> + GetDefaultContentSetting(content_type_); // Now that these have been added to the view hierarchy, it's safe to call // SetChecked() on them. if (default_setting == CONTENT_SETTING_ALLOW) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(allow_radio_), TRUE); + } else if (default_setting == CONTENT_SETTING_ASK) { + DCHECK(ask_radio_); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ask_radio_), TRUE); } else { DCHECK(default_setting == CONTENT_SETTING_BLOCK); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(block_radio_), TRUE); @@ -88,6 +116,10 @@ GtkWidget* ContentFilterPageGtk::InitGroup() { // toggled signal. g_signal_connect(G_OBJECT(allow_radio_), "toggled", G_CALLBACK(OnAllowToggledThunk), this); + if (ask_radio_) { + g_signal_connect(G_OBJECT(ask_radio_), "toggled", + G_CALLBACK(OnAllowToggledThunk), this); + } g_signal_connect(G_OBJECT(block_radio_), "toggled", G_CALLBACK(OnAllowToggledThunk), this); @@ -117,17 +149,26 @@ GtkWidget* ContentFilterPageGtk::InitGroup() { void ContentFilterPageGtk::OnAllowToggled(GtkWidget* toggle_button) { DCHECK((toggle_button == allow_radio_) || + (toggle_button == ask_radio_) || (toggle_button == block_radio_)); - - bool allow = gtk_toggle_button_get_active( - GTK_TOGGLE_BUTTON(allow_radio_)); - profile()->GetHostContentSettingsMap()-> - SetDefaultContentSetting( - content_type_, - allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); + ContentSetting default_setting = + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(allow_radio_)) ? + CONTENT_SETTING_ALLOW : + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(block_radio_)) ? + CONTENT_SETTING_BLOCK : CONTENT_SETTING_ASK; + DCHECK(ask_radio_ || default_setting != CONTENT_SETTING_ASK); + if (content_type_ == CONTENT_SETTINGS_TYPE_GEOLOCATION) { + profile()->GetGeolocationContentSettingsMap()->SetDefaultContentSetting( + default_setting); + } else { + profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( + content_type_, default_setting); + } } void ContentFilterPageGtk::OnExceptionsClicked(GtkWidget* button) { + if (content_type_ == CONTENT_SETTINGS_TYPE_GEOLOCATION) + return; // TODO(bulach): Implement geolocation exceptions dialog. HostContentSettingsMap* settings_map = profile()->GetHostContentSettingsMap(); ContentExceptionsWindowGtk::ShowExceptionsWindow( diff --git a/chrome/browser/gtk/options/content_filter_page_gtk.h b/chrome/browser/gtk/options/content_filter_page_gtk.h index 35822ac..f7f4de9 100644 --- a/chrome/browser/gtk/options/content_filter_page_gtk.h +++ b/chrome/browser/gtk/options/content_filter_page_gtk.h @@ -39,6 +39,7 @@ class ContentFilterPageGtk : public OptionsPageBase { // Controls for the content filter tab page. GtkWidget* allow_radio_; + GtkWidget* ask_radio_; GtkWidget* block_radio_; DISALLOW_COPY_AND_ASSIGN(ContentFilterPageGtk); diff --git a/chrome/browser/gtk/options/content_settings_window_gtk.cc b/chrome/browser/gtk/options/content_settings_window_gtk.cc index 82737389..2ec8c45 100644 --- a/chrome/browser/gtk/options/content_settings_window_gtk.cc +++ b/chrome/browser/gtk/options/content_settings_window_gtk.cc @@ -7,6 +7,7 @@ #include <string> #include "app/l10n_util.h" +#include "base/command_line.h" #include "base/message_loop.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" @@ -16,6 +17,7 @@ #include "chrome/browser/gtk/gtk_util.h" #include "chrome/browser/pref_service.h" #include "chrome/browser/profile.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/content_settings_types.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" @@ -58,7 +60,8 @@ ContentSettingsWindowGtk::ContentSettingsWindowGtk(GtkWindow* parent, image_page_(profile, CONTENT_SETTINGS_TYPE_IMAGES), javascript_page_(profile, CONTENT_SETTINGS_TYPE_JAVASCRIPT), plugin_page_(profile, CONTENT_SETTINGS_TYPE_PLUGINS), - popup_page_(profile, CONTENT_SETTINGS_TYPE_POPUPS) { + popup_page_(profile, CONTENT_SETTINGS_TYPE_POPUPS), + geolocation_page_(profile, CONTENT_SETTINGS_TYPE_GEOLOCATION) { // We don't need to observe changes in this value. last_selected_page_.Init(prefs::kContentSettingsWindowLastTabIndex, profile->GetPrefs(), NULL); @@ -111,12 +114,16 @@ ContentSettingsWindowGtk::ContentSettingsWindowGtk(GtkWindow* parent, popup_page_.get_page_widget(), gtk_label_new( l10n_util::GetStringUTF8(IDS_POPUP_TAB_LABEL).c_str())); + gtk_notebook_append_page( + GTK_NOTEBOOK(notebook_), + geolocation_page_.get_page_widget(), + gtk_label_new( + l10n_util::GetStringUTF8(IDS_GEOLOCATION_TAB_LABEL).c_str())); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog_)->vbox), notebook_); - // TODO(joth): remove -1 when geolocation tab is added. DCHECK_EQ(gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook_)), - CONTENT_SETTINGS_NUM_TYPES - 1); + CONTENT_SETTINGS_NUM_TYPES); // Need to show the notebook before connecting switch-page signal, otherwise // we'll immediately get a signal switching to page 0 and overwrite our diff --git a/chrome/browser/gtk/options/content_settings_window_gtk.h b/chrome/browser/gtk/options/content_settings_window_gtk.h index c622e51..89fafd1 100644 --- a/chrome/browser/gtk/options/content_settings_window_gtk.h +++ b/chrome/browser/gtk/options/content_settings_window_gtk.h @@ -57,6 +57,7 @@ class ContentSettingsWindowGtk { ContentFilterPageGtk javascript_page_; ContentFilterPageGtk plugin_page_; ContentFilterPageGtk popup_page_; + ContentFilterPageGtk geolocation_page_; // Helper object to manage accessibility metadata. scoped_ptr<AccessibleWidgetHelper> accessible_widget_helper_; |