OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/advanced_contents_gtk.h" | 5 #include "chrome/browser/gtk/options/advanced_contents_gtk.h" |
6 | 6 |
| 7 #include <sys/types.h> |
| 8 #include <sys/wait.h> |
| 9 |
7 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
8 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/linux_util.h" |
9 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/process_util.h" |
10 #include "chrome/browser/browser_list.h" | 15 #include "chrome/browser/browser_list.h" |
11 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/download/download_manager.h" | 17 #include "chrome/browser/download/download_manager.h" |
13 #include "chrome/browser/fonts_languages_window.h" | 18 #include "chrome/browser/fonts_languages_window.h" |
14 #include "chrome/browser/gtk/gtk_chrome_link_button.h" | 19 #include "chrome/browser/gtk/gtk_chrome_link_button.h" |
15 #include "chrome/browser/gtk/options/options_layout_gtk.h" | 20 #include "chrome/browser/gtk/options/options_layout_gtk.h" |
16 #include "chrome/browser/net/dns_global.h" | 21 #include "chrome/browser/net/dns_global.h" |
17 #include "chrome/browser/options_page_base.h" | 22 #include "chrome/browser/options_page_base.h" |
18 #include "chrome/browser/options_util.h" | 23 #include "chrome/browser/options_util.h" |
19 #include "chrome/browser/profile.h" | 24 #include "chrome/browser/profile.h" |
20 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 25 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
21 #include "chrome/common/chrome_paths.h" | 26 #include "chrome/common/chrome_paths.h" |
22 #include "chrome/common/gtk_util.h" | 27 #include "chrome/common/gtk_util.h" |
23 #include "chrome/common/pref_member.h" | 28 #include "chrome/common/pref_member.h" |
24 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 30 #include "chrome/common/process_watcher.h" |
25 #include "grit/chromium_strings.h" | 31 #include "grit/chromium_strings.h" |
26 #include "grit/generated_resources.h" | 32 #include "grit/generated_resources.h" |
27 #include "grit/locale_settings.h" | 33 #include "grit/locale_settings.h" |
28 #include "net/base/cookie_policy.h" | 34 #include "net/base/cookie_policy.h" |
29 | 35 |
30 namespace { | 36 namespace { |
31 | 37 |
| 38 // Command used to configure the gconf proxy settings. |
| 39 const char kProxyConfigBinary[] = "gnome-network-preferences"; |
| 40 |
32 // The pixel width we wrap labels at. | 41 // The pixel width we wrap labels at. |
33 // TODO(evanm): make the labels wrap at the appropriate width. | 42 // TODO(evanm): make the labels wrap at the appropriate width. |
34 const int kWrapWidth = 475; | 43 const int kWrapWidth = 475; |
35 | 44 |
36 GtkWidget* CreateWrappedLabel(int string_id) { | 45 GtkWidget* CreateWrappedLabel(int string_id) { |
37 GtkWidget* label = gtk_label_new( | 46 GtkWidget* label = gtk_label_new( |
38 l10n_util::GetStringUTF8(string_id).c_str()); | 47 l10n_util::GetStringUTF8(string_id).c_str()); |
39 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | 48 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
40 gtk_widget_set_size_request(label, kWrapWidth, -1); | 49 gtk_widget_set_size_request(label, kWrapWidth, -1); |
41 return label; | 50 return label; |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 class NetworkSection : public OptionsPageBase { | 252 class NetworkSection : public OptionsPageBase { |
244 public: | 253 public: |
245 explicit NetworkSection(Profile* profile); | 254 explicit NetworkSection(Profile* profile); |
246 virtual ~NetworkSection() {} | 255 virtual ~NetworkSection() {} |
247 | 256 |
248 GtkWidget* get_page_widget() const { | 257 GtkWidget* get_page_widget() const { |
249 return page_; | 258 return page_; |
250 } | 259 } |
251 | 260 |
252 private: | 261 private: |
| 262 // The callback functions for invoking the proxy config dialog. |
| 263 static void OnChangeProxiesButtonClicked(GtkButton *button, |
| 264 NetworkSection* section); |
| 265 |
253 // The widget containing the options for this section. | 266 // The widget containing the options for this section. |
254 GtkWidget* page_; | 267 GtkWidget* page_; |
255 | 268 |
256 DISALLOW_COPY_AND_ASSIGN(NetworkSection); | 269 DISALLOW_COPY_AND_ASSIGN(NetworkSection); |
257 }; | 270 }; |
258 | 271 |
259 NetworkSection::NetworkSection(Profile* profile) | 272 NetworkSection::NetworkSection(Profile* profile) |
260 : OptionsPageBase(profile) { | 273 : OptionsPageBase(profile) { |
261 page_ = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); | 274 page_ = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); |
262 gtk_box_pack_start(GTK_BOX(page_), gtk_label_new("TODO network options"), | 275 |
| 276 GtkWidget* proxy_description_label = CreateWrappedLabel( |
| 277 IDS_OPTIONS_PROXIES_LABEL); |
| 278 gtk_misc_set_alignment(GTK_MISC(proxy_description_label), 0, 0); |
| 279 gtk_box_pack_start(GTK_BOX(page_), proxy_description_label, |
| 280 FALSE, FALSE, 0); |
| 281 |
| 282 GtkWidget* change_proxies_button = gtk_button_new_with_label( |
| 283 l10n_util::GetStringUTF8( |
| 284 IDS_OPTIONS_PROXIES_CONFIGURE_BUTTON).c_str()); |
| 285 g_signal_connect(change_proxies_button, "clicked", |
| 286 G_CALLBACK(OnChangeProxiesButtonClicked), this); |
| 287 // Stick it in an hbox so it doesn't expand to the whole width. |
| 288 GtkWidget* button_hbox = gtk_hbox_new(FALSE, 0); |
| 289 gtk_box_pack_start(GTK_BOX(button_hbox), |
| 290 change_proxies_button, |
| 291 FALSE, FALSE, 0); |
| 292 gtk_box_pack_start(GTK_BOX(page_), |
| 293 OptionsLayoutBuilderGtk::IndentWidget(button_hbox), |
263 FALSE, FALSE, 0); | 294 FALSE, FALSE, 0); |
264 } | 295 } |
265 | 296 |
| 297 // static |
| 298 void NetworkSection::OnChangeProxiesButtonClicked(GtkButton *button, |
| 299 NetworkSection* section) { |
| 300 section->UserMetricsRecordAction(L"Options_ChangeProxies", NULL); |
| 301 |
| 302 scoped_ptr<base::EnvironmentVariableGetter> env_getter( |
| 303 base::EnvironmentVariableGetter::Create()); |
| 304 if (base::UseGnomeForSettings(env_getter.get())) { |
| 305 std::vector<std::string> argv; |
| 306 argv.push_back(kProxyConfigBinary); |
| 307 base::file_handle_mapping_vector no_files; |
| 308 base::environment_vector env; |
| 309 base::ProcessHandle handle; |
| 310 env.push_back(std::make_pair("GTK_PATH", |
| 311 getenv("CHROMIUM_SAVED_GTK_PATH"))); |
| 312 if (!base::LaunchApp(argv, env, no_files, false, &handle)) { |
| 313 LOG(ERROR) << "OpenProxyConfigDialogTask failed"; |
| 314 return; |
| 315 } |
| 316 ProcessWatcher::EnsureProcessGetsReaped(handle); |
| 317 } else { |
| 318 BrowserList::GetLastActive()-> |
| 319 OpenURL(GURL(l10n_util::GetStringUTF8(IDS_LINUX_PROXY_CONFIG_URL)), |
| 320 GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); |
| 321 } |
| 322 } |
| 323 |
266 /////////////////////////////////////////////////////////////////////////////// | 324 /////////////////////////////////////////////////////////////////////////////// |
267 // PrivacySection | 325 // PrivacySection |
268 | 326 |
269 class PrivacySection : public OptionsPageBase { | 327 class PrivacySection : public OptionsPageBase { |
270 public: | 328 public: |
271 explicit PrivacySection(Profile* profile); | 329 explicit PrivacySection(Profile* profile); |
272 virtual ~PrivacySection() {} | 330 virtual ~PrivacySection() {} |
273 | 331 |
274 GtkWidget* get_page_widget() const { | 332 GtkWidget* get_page_widget() const { |
275 return page_; | 333 return page_; |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 l10n_util::GetStringUTF8(IDS_OPTIONS_ADVANCED_SECTION_TITLE_CONTENT), | 818 l10n_util::GetStringUTF8(IDS_OPTIONS_ADVANCED_SECTION_TITLE_CONTENT), |
761 web_content_section_->get_page_widget(), false); | 819 web_content_section_->get_page_widget(), false); |
762 | 820 |
763 security_section_.reset(new SecuritySection(profile_)); | 821 security_section_.reset(new SecuritySection(profile_)); |
764 options_builder.AddOptionGroup( | 822 options_builder.AddOptionGroup( |
765 l10n_util::GetStringUTF8(IDS_OPTIONS_ADVANCED_SECTION_TITLE_SECURITY), | 823 l10n_util::GetStringUTF8(IDS_OPTIONS_ADVANCED_SECTION_TITLE_SECURITY), |
766 security_section_->get_page_widget(), false); | 824 security_section_->get_page_widget(), false); |
767 | 825 |
768 page_ = options_builder.get_page_widget(); | 826 page_ = options_builder.get_page_widget(); |
769 } | 827 } |
OLD | NEW |