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

Unified Diff: chrome/browser/gtk/options/geolocation_filter_page_gtk.cc

Issue 650180: Initial Geolocation location bar icons. (Closed)
Patch Set: Addresses Peter and Brett's comments. Created 10 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/gtk/options/geolocation_filter_page_gtk.cc
diff --git a/chrome/browser/gtk/options/geolocation_filter_page_gtk.cc b/chrome/browser/gtk/options/geolocation_filter_page_gtk.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6aacff018edd7b8d135c62d806aec5c7143588e1
--- /dev/null
+++ b/chrome/browser/gtk/options/geolocation_filter_page_gtk.cc
@@ -0,0 +1,109 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/gtk/options/geolocation_filter_page_gtk.h"
+
+#include "app/l10n_util.h"
+#include "chrome/browser/host_content_settings_map.h"
+#include "chrome/browser/gtk/gtk_util.h"
+#include "chrome/browser/gtk/options/content_exceptions_window_gtk.h"
+#include "chrome/browser/gtk/options/options_layout_gtk.h"
+#include "chrome/browser/profile.h"
+#include "chrome/common/pref_names.h"
+#include "grit/generated_resources.h"
+#include "grit/locale_settings.h"
+
+GeolocationFilterPageGtk::GeolocationFilterPageGtk(Profile* profile)
+ : OptionsPageBase(profile) {
+ OptionsLayoutBuilderGtk options_builder;
+ options_builder.AddOptionGroup(
+ l10n_util::GetStringUTF8(IDS_GEOLOCATION_SETTING_LABEL),
+ InitGroup(), true);
+ page_ = options_builder.get_page_widget();
+}
+
+GeolocationFilterPageGtk::~GeolocationFilterPageGtk() {
+}
+
+
+GtkWidget* GeolocationFilterPageGtk::InitGroup() {
+ GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
+
+ ask_radio_ = gtk_radio_button_new_with_label(NULL,
+ l10n_util::GetStringUTF8(IDS_GEOLOCATION_ASK_ALL_RADIO).c_str());
+ gtk_box_pack_start(GTK_BOX(vbox), ask_radio_, FALSE, FALSE, 0);
+
+ block_radio_ = gtk_radio_button_new_with_label_from_widget(
+ GTK_RADIO_BUTTON(ask_radio_),
+ l10n_util::GetStringUTF8(IDS_GEOLOCATION_BLOCK_ALL_RADIO).c_str());
+ gtk_box_pack_start(GTK_BOX(vbox), block_radio_, FALSE, FALSE, 0);
+
+ allow_radio_ = gtk_radio_button_new_with_label_from_widget(
+ GTK_RADIO_BUTTON(ask_radio_),
+ l10n_util::GetStringUTF8(IDS_GEOLOCATION_ALLOW_ALL_RADIO).c_str());
+ gtk_box_pack_start(GTK_BOX(vbox), allow_radio_, FALSE, FALSE, 0);
+
+ ContentSetting default_setting = profile()->GetHostContentSettingsMap()->
+ GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION);
+ // Now that these have been added to the view hierarchy, it's safe to call
+ // SetChecked() on them.
+ if (default_setting == CONTENT_SETTING_ASK) {
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ask_radio_), TRUE);
+ } else if (default_setting == CONTENT_SETTING_BLOCK) {
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(block_radio_), TRUE);
+ } else {
+ DCHECK(default_setting == CONTENT_SETTING_ALLOW);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(allow_radio_), TRUE);
+ }
+
+ // Now that we've set the default value, we can connect to the radio button's
+ // toggled signal.
+ g_signal_connect(G_OBJECT(ask_radio_), "toggled",
+ G_CALLBACK(OnAskToggled), this);
+ g_signal_connect(G_OBJECT(block_radio_), "toggled",
+ G_CALLBACK(OnAskToggled), this);
+ g_signal_connect(G_OBJECT(allow_radio_), "toggled",
+ G_CALLBACK(OnAskToggled), this);
+
+ GtkWidget* exceptions_button = gtk_button_new_with_label(
+ l10n_util::GetStringUTF8(IDS_COOKIES_EXCEPTIONS_BUTTON).c_str());
+ g_signal_connect(G_OBJECT(exceptions_button), "clicked",
+ G_CALLBACK(OnExceptionsClicked), this);
+
+ GtkWidget* hbox = gtk_hbox_new(FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), exceptions_button, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+
+ return vbox;
+}
+
+void GeolocationFilterPageGtk::OnAskToggled(
+ GtkWidget* toggle_button,
+ GeolocationFilterPageGtk* geolocation_page) {
+ DCHECK((toggle_button == geolocation_page->ask_radio_) ||
+ (toggle_button == geolocation_page->block_radio_) ||
+ (toggle_button == geolocation_page->allow_radio_));
+
+ ContentSetting content_setting = CONTENT_SETTING_ASK;
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
+ geolocation_page->block_radio_))) {
+ content_setting = CONTENT_SETTING_BLOCK;
+ } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
+ geolocation_page->allow_radio_))) {
+ content_setting = CONTENT_SETTING_ALLOW;
+ }
+ geolocation_page->profile()->GetHostContentSettingsMap()->
+ SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION,
+ content_setting);
+}
+
+void GeolocationFilterPageGtk::OnExceptionsClicked(
+ GtkWidget* button,
+ GeolocationFilterPageGtk* geolocation_page) {
+ HostContentSettingsMap* settings_map =
+ geolocation_page->profile()->GetHostContentSettingsMap();
+ ContentExceptionsWindowGtk::ShowExceptionsWindow(
+ GTK_WINDOW(gtk_widget_get_toplevel(button)),
+ settings_map, CONTENT_SETTINGS_TYPE_GEOLOCATION);
+}
« no previous file with comments | « chrome/browser/gtk/options/geolocation_filter_page_gtk.h ('k') | chrome/browser/host_content_settings_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698