diff options
author | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-22 00:22:49 +0000 |
---|---|---|
committer | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-22 00:22:49 +0000 |
commit | 87fc168b364ef36033f72e545a4894bd7ce9354f (patch) | |
tree | 8dd7a36186859c6b42be3156178373d91599e310 /chrome/browser/gtk/options/advanced_contents_gtk.cc | |
parent | bda0b8792b40ce11649995a622344b0aa91b7a9d (diff) | |
download | chromium_src-87fc168b364ef36033f72e545a4894bd7ce9354f.zip chromium_src-87fc168b364ef36033f72e545a4894bd7ce9354f.tar.gz chromium_src-87fc168b364ef36033f72e545a4894bd7ce9354f.tar.bz2 |
Try again: Add proxy config (using gnome-network-preferences)
BUG=11507
TEST=Open options, click change proxy, gnome-network-preferences should launch. If gnome isn't installed or running, LinuxProxyConfig wiki page should load.
Review URL: http://codereview.chromium.org/155792
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21246 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/options/advanced_contents_gtk.cc')
-rw-r--r-- | chrome/browser/gtk/options/advanced_contents_gtk.cc | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/chrome/browser/gtk/options/advanced_contents_gtk.cc b/chrome/browser/gtk/options/advanced_contents_gtk.cc index 8f7a6d5..5cf7141 100644 --- a/chrome/browser/gtk/options/advanced_contents_gtk.cc +++ b/chrome/browser/gtk/options/advanced_contents_gtk.cc @@ -4,9 +4,14 @@ #include "chrome/browser/gtk/options/advanced_contents_gtk.h" +#include <sys/types.h> +#include <sys/wait.h> + #include "app/l10n_util.h" #include "base/basictypes.h" +#include "base/linux_util.h" #include "base/path_service.h" +#include "base/process_util.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/download/download_manager.h" @@ -22,6 +27,7 @@ #include "chrome/common/gtk_util.h" #include "chrome/common/pref_member.h" #include "chrome/common/pref_names.h" +#include "chrome/common/process_watcher.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" @@ -29,6 +35,9 @@ namespace { +// Command used to configure the gconf proxy settings. +const char kProxyConfigBinary[] = "gnome-network-preferences"; + // The pixel width we wrap labels at. // TODO(evanm): make the labels wrap at the appropriate width. const int kWrapWidth = 475; @@ -250,6 +259,10 @@ class NetworkSection : public OptionsPageBase { } private: + // The callback functions for invoking the proxy config dialog. + static void OnChangeProxiesButtonClicked(GtkButton *button, + NetworkSection* section); + // The widget containing the options for this section. GtkWidget* page_; @@ -259,8 +272,53 @@ class NetworkSection : public OptionsPageBase { NetworkSection::NetworkSection(Profile* profile) : OptionsPageBase(profile) { page_ = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); - gtk_box_pack_start(GTK_BOX(page_), gtk_label_new("TODO network options"), + + GtkWidget* proxy_description_label = CreateWrappedLabel( + IDS_OPTIONS_PROXIES_LABEL); + gtk_misc_set_alignment(GTK_MISC(proxy_description_label), 0, 0); + gtk_box_pack_start(GTK_BOX(page_), proxy_description_label, + FALSE, FALSE, 0); + + GtkWidget* change_proxies_button = gtk_button_new_with_label( + l10n_util::GetStringUTF8( + IDS_OPTIONS_PROXIES_CONFIGURE_BUTTON).c_str()); + g_signal_connect(change_proxies_button, "clicked", + G_CALLBACK(OnChangeProxiesButtonClicked), this); + // Stick it in an hbox so it doesn't expand to the whole width. + GtkWidget* button_hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(button_hbox), + change_proxies_button, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(page_), + OptionsLayoutBuilderGtk::IndentWidget(button_hbox), + FALSE, FALSE, 0); +} + +// static +void NetworkSection::OnChangeProxiesButtonClicked(GtkButton *button, + NetworkSection* section) { + section->UserMetricsRecordAction(L"Options_ChangeProxies", NULL); + + scoped_ptr<base::EnvironmentVariableGetter> env_getter( + base::EnvironmentVariableGetter::Create()); + if (base::UseGnomeForSettings(env_getter.get())) { + std::vector<std::string> argv; + argv.push_back(kProxyConfigBinary); + base::file_handle_mapping_vector no_files; + base::environment_vector env; + base::ProcessHandle handle; + env.push_back(std::make_pair("GTK_PATH", + getenv("CHROMIUM_SAVED_GTK_PATH"))); + if (!base::LaunchApp(argv, env, no_files, false, &handle)) { + LOG(ERROR) << "OpenProxyConfigDialogTask failed"; + return; + } + ProcessWatcher::EnsureProcessGetsReaped(handle); + } else { + BrowserList::GetLastActive()-> + OpenURL(GURL(l10n_util::GetStringUTF8(IDS_LINUX_PROXY_CONFIG_URL)), + GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); + } } /////////////////////////////////////////////////////////////////////////////// |