OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/gtk/options/content_settings_window_gtk.h" | 5 #include "chrome/browser/gtk/options/content_settings_window_gtk.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/command_line.h" |
10 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
11 #include "chrome/browser/browser.h" | 12 #include "chrome/browser/browser.h" |
12 #include "chrome/browser/browser_list.h" | 13 #include "chrome/browser/browser_list.h" |
13 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/gtk/accessible_widget_helper_gtk.h" | 15 #include "chrome/browser/gtk/accessible_widget_helper_gtk.h" |
15 #include "chrome/browser/gtk/browser_window_gtk.h" | 16 #include "chrome/browser/gtk/browser_window_gtk.h" |
16 #include "chrome/browser/gtk/gtk_util.h" | 17 #include "chrome/browser/gtk/gtk_util.h" |
17 #include "chrome/browser/pref_service.h" | 18 #include "chrome/browser/pref_service.h" |
18 #include "chrome/browser/profile.h" | 19 #include "chrome/browser/profile.h" |
| 20 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/content_settings_types.h" | 21 #include "chrome/common/content_settings_types.h" |
20 #include "chrome/common/notification_service.h" | 22 #include "chrome/common/notification_service.h" |
21 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
22 #include "grit/chromium_strings.h" | 24 #include "grit/chromium_strings.h" |
23 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
24 #include "grit/locale_settings.h" | 26 #include "grit/locale_settings.h" |
25 | 27 |
26 namespace { | 28 namespace { |
27 | 29 |
28 // The singleton options window object. | 30 // The singleton options window object. |
(...skipping 22 matching lines...) Expand all Loading... |
51 settings_window->ShowContentSettingsTab(page); | 53 settings_window->ShowContentSettingsTab(page); |
52 } | 54 } |
53 | 55 |
54 ContentSettingsWindowGtk::ContentSettingsWindowGtk(GtkWindow* parent, | 56 ContentSettingsWindowGtk::ContentSettingsWindowGtk(GtkWindow* parent, |
55 Profile* profile) | 57 Profile* profile) |
56 : profile_(profile), | 58 : profile_(profile), |
57 cookie_page_(profile), | 59 cookie_page_(profile), |
58 image_page_(profile, CONTENT_SETTINGS_TYPE_IMAGES), | 60 image_page_(profile, CONTENT_SETTINGS_TYPE_IMAGES), |
59 javascript_page_(profile, CONTENT_SETTINGS_TYPE_JAVASCRIPT), | 61 javascript_page_(profile, CONTENT_SETTINGS_TYPE_JAVASCRIPT), |
60 plugin_page_(profile, CONTENT_SETTINGS_TYPE_PLUGINS), | 62 plugin_page_(profile, CONTENT_SETTINGS_TYPE_PLUGINS), |
61 popup_page_(profile, CONTENT_SETTINGS_TYPE_POPUPS) { | 63 popup_page_(profile, CONTENT_SETTINGS_TYPE_POPUPS), |
| 64 geolocation_page_(profile) { |
62 // We don't need to observe changes in this value. | 65 // We don't need to observe changes in this value. |
63 last_selected_page_.Init(prefs::kContentSettingsWindowLastTabIndex, | 66 last_selected_page_.Init(prefs::kContentSettingsWindowLastTabIndex, |
64 profile->GetPrefs(), NULL); | 67 profile->GetPrefs(), NULL); |
65 | 68 |
66 std::string dialog_name = l10n_util::GetStringUTF8( | 69 std::string dialog_name = l10n_util::GetStringUTF8( |
67 IDS_CONTENT_SETTINGS_TITLE); | 70 IDS_CONTENT_SETTINGS_TITLE); |
68 dialog_ = gtk_dialog_new_with_buttons( | 71 dialog_ = gtk_dialog_new_with_buttons( |
69 dialog_name.c_str(), | 72 dialog_name.c_str(), |
70 parent, | 73 parent, |
71 static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), | 74 static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 GTK_NOTEBOOK(notebook_), | 108 GTK_NOTEBOOK(notebook_), |
106 plugin_page_.get_page_widget(), | 109 plugin_page_.get_page_widget(), |
107 gtk_label_new( | 110 gtk_label_new( |
108 l10n_util::GetStringUTF8(IDS_PLUGIN_TAB_LABEL).c_str())); | 111 l10n_util::GetStringUTF8(IDS_PLUGIN_TAB_LABEL).c_str())); |
109 gtk_notebook_append_page( | 112 gtk_notebook_append_page( |
110 GTK_NOTEBOOK(notebook_), | 113 GTK_NOTEBOOK(notebook_), |
111 popup_page_.get_page_widget(), | 114 popup_page_.get_page_widget(), |
112 gtk_label_new( | 115 gtk_label_new( |
113 l10n_util::GetStringUTF8(IDS_POPUP_TAB_LABEL).c_str())); | 116 l10n_util::GetStringUTF8(IDS_POPUP_TAB_LABEL).c_str())); |
114 | 117 |
| 118 int num_pages = CONTENT_SETTINGS_NUM_TYPES - 1; |
| 119 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 120 switches::kEnableGeolocation)) { |
| 121 gtk_notebook_append_page( |
| 122 GTK_NOTEBOOK(notebook_), |
| 123 geolocation_page_.get_page_widget(), |
| 124 gtk_label_new( |
| 125 l10n_util::GetStringUTF8(IDS_GEOLOCATION_TAB_LABEL).c_str())); |
| 126 ++num_pages; |
| 127 } |
| 128 |
115 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog_)->vbox), notebook_); | 129 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog_)->vbox), notebook_); |
116 | 130 |
117 DCHECK_EQ(gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook_)), | 131 DCHECK_EQ(gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook_)), |
118 CONTENT_SETTINGS_NUM_TYPES); | 132 num_pages); |
119 | 133 |
120 // Need to show the notebook before connecting switch-page signal, otherwise | 134 // Need to show the notebook before connecting switch-page signal, otherwise |
121 // we'll immediately get a signal switching to page 0 and overwrite our | 135 // we'll immediately get a signal switching to page 0 and overwrite our |
122 // last_selected_page_ value. | 136 // last_selected_page_ value. |
123 gtk_widget_show_all(dialog_); | 137 gtk_widget_show_all(dialog_); |
124 | 138 |
125 g_signal_connect(notebook_, "switch-page", G_CALLBACK(OnSwitchPage), this); | 139 g_signal_connect(notebook_, "switch-page", G_CALLBACK(OnSwitchPage), this); |
126 | 140 |
127 // We only have one button and don't do any special handling, so just hook it | 141 // We only have one button and don't do any special handling, so just hook it |
128 // directly to gtk_widget_destroy. | 142 // directly to gtk_widget_destroy. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 window->last_selected_page_.SetValue(index); | 185 window->last_selected_page_.SetValue(index); |
172 } | 186 } |
173 | 187 |
174 // static | 188 // static |
175 void ContentSettingsWindowGtk::OnWindowDestroy( | 189 void ContentSettingsWindowGtk::OnWindowDestroy( |
176 GtkWidget* widget, | 190 GtkWidget* widget, |
177 ContentSettingsWindowGtk* window) { | 191 ContentSettingsWindowGtk* window) { |
178 settings_window = NULL; | 192 settings_window = NULL; |
179 MessageLoop::current()->DeleteSoon(FROM_HERE, window); | 193 MessageLoop::current()->DeleteSoon(FROM_HERE, window); |
180 } | 194 } |
OLD | NEW |