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

Side by Side Diff: chrome/browser/dom_ui/advanced_options_utils_gtk.cc

Issue 2847061: Implement dom-ui proxy settings dialog for Linux/Windows.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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 unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #if !defined(OS_CHROMEOS)
6
7 #include "chrome/browser/dom_ui/advanced_options_utils.h"
8
9 #include "app/gtk_signal.h"
10 #include "app/gtk_util.h"
11 #include "base/file_util.h"
12 #include "base/env_var.h"
13 #include "base/process_util.h"
14 #include "base/string_tokenizer.h"
15 #include "base/xdg_util.h"
16 #include "chrome/browser/browser_list.h"
17 #include "chrome/browser/tab_contents/tab_contents.h"
18 #include "chrome/common/process_watcher.h"
19
20 // Command used to configure GNOME proxy settings. The command was renamed
21 // in January 2009, so both are used to work on both old and new systems.
22 const char* kOldGNOMEProxyConfigCommand[] = {"gnome-network-preferences", NULL};
23 const char* kGNOMEProxyConfigCommand[] = {"gnome-network-properties", NULL};
24 // KDE3 and KDE4 are only slightly different, but incompatible. Go figure.
25 const char* kKDE3ProxyConfigCommand[] = {"kcmshell", "proxy", NULL};
26 const char* kKDE4ProxyConfigCommand[] = {"kcmshell4", "proxy", NULL};
27
28 // The URL for Linux proxy configuration help when not running under a
29 // supported desktop environment.
30 const char kLinuxProxyConfigUrl[] = "about:linux-proxy-config";
31
32 // The URL for Linux ssl certificate configuration help.
33 const char* const kLinuxCertificatesConfigUrl =
34 "http://code.google.com/p/chromium/wiki/LinuxCertManagement";
35
36
37 struct ProxyConfigCommand {
38 std::string binary;
39 const char** argv;
40 };
41
42 static bool SearchPATH(ProxyConfigCommand* commands, size_t ncommands,
43 size_t* index) {
44 const char* path = getenv("PATH");
45 if (!path)
46 return false;
47 FilePath bin_path;
48 CStringTokenizer tk(path, path + strlen(path), ":");
49 // Search $PATH looking for the commands in order.
50 while (tk.GetNext()) {
51 for (size_t i = 0; i < ncommands; i++) {
52 bin_path = FilePath(tk.token()).Append(commands[i].argv[0]);
53 if (file_util::PathExists(bin_path)) {
54 commands[i].binary = bin_path.value();
55 if (index)
56 *index = i;
57 return true;
58 }
59 }
60 }
61 // Did not find any of the binaries in $PATH.
62 return false;
63 }
64
65 static void StartProxyConfigUtil(const ProxyConfigCommand& command) {
66 std::vector<std::string> argv;
67 argv.push_back(command.binary);
68 for (size_t i = 1; command.argv[i]; i++)
69 argv.push_back(command.argv[i]);
70 base::file_handle_mapping_vector no_files;
71 base::ProcessHandle handle;
72 if (!base::LaunchApp(argv, no_files, false, &handle)) {
73 LOG(ERROR) << "StartProxyConfigUtil failed to start " << command.binary;
74 BrowserList::GetLastActive()->
75 OpenURL(GURL(kLinuxProxyConfigUrl), GURL(), NEW_FOREGROUND_TAB,
76 PageTransition::LINK);
77 return;
78 }
79 ProcessWatcher::EnsureProcessGetsReaped(handle);
80 }
81
82 void AdvancedOptionsUtilities::ShowNetworkProxySettings(
83 TabContents* tab_contents) {
84 scoped_ptr<base::EnvVarGetter> env_getter(base::EnvVarGetter::Create());
85
86 ProxyConfigCommand command;
87 bool found_command = false;
88 switch (base::GetDesktopEnvironment(env_getter.get())) {
89 case base::DESKTOP_ENVIRONMENT_GNOME: {
90 size_t index;
91 ProxyConfigCommand commands[2];
92 commands[0].argv = kGNOMEProxyConfigCommand;
93 commands[1].argv = kOldGNOMEProxyConfigCommand;
94 found_command = SearchPATH(commands, 2, &index);
95 if (found_command)
96 command = commands[index];
97 break;
98 }
99
100 case base::DESKTOP_ENVIRONMENT_KDE3:
101 command.argv = kKDE3ProxyConfigCommand;
102 found_command = SearchPATH(&command, 1, NULL);
103 break;
104
105 case base::DESKTOP_ENVIRONMENT_KDE4:
106 command.argv = kKDE4ProxyConfigCommand;
107 found_command = SearchPATH(&command, 1, NULL);
108 break;
109
110 case base::DESKTOP_ENVIRONMENT_XFCE:
111 case base::DESKTOP_ENVIRONMENT_OTHER:
112 break;
113 }
114
115 if (found_command) {
116 StartProxyConfigUtil(command);
117 } else {
118 const char* name = base::GetDesktopEnvironmentName(env_getter.get());
119 if (name)
120 LOG(ERROR) << "Could not find " << name << " network settings in $PATH";
121 tab_contents->OpenURL(GURL(kLinuxProxyConfigUrl), GURL(),
122 NEW_FOREGROUND_TAB, PageTransition::LINK);
123 }
124 }
125
126 void AdvancedOptionsUtilities::ShowManageSSLCertificates(
127 TabContents* tab_contents) {
128 tab_contents->OpenURL(GURL(kLinuxCertificatesConfigUrl), GURL(),
129 NEW_WINDOW, PageTransition::LINK);
130 }
131
132 #endif // !defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/advanced_options_utils.h ('k') | chrome/browser/dom_ui/advanced_options_utils_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698