| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #if !defined(OS_CHROMEOS) | 5 #if !defined(OS_CHROMEOS) |
| 6 | 6 |
| 7 #include "chrome/browser/ui/webui/options/advanced_options_utils.h" | 7 #include "chrome/browser/ui/webui/options/advanced_options_utils.h" |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/environment.h" | 10 #include "base/environment.h" |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/nix/xdg_util.h" | 13 #include "base/nix/xdg_util.h" |
| 14 #include "base/process_util.h" | 14 #include "base/process_util.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "content/browser/tab_contents/tab_contents.h" | 16 #include "content/browser/tab_contents/tab_contents.h" |
| 17 #include "content/common/process_watcher.h" | |
| 18 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 19 | 18 |
| 20 using content::BrowserThread; | 19 using content::BrowserThread; |
| 21 | 20 |
| 22 // Command used to configure GNOME 2 proxy settings. | 21 // Command used to configure GNOME 2 proxy settings. |
| 23 const char* kGNOME2ProxyConfigCommand[] = {"gnome-network-properties", NULL}; | 22 const char* kGNOME2ProxyConfigCommand[] = {"gnome-network-properties", NULL}; |
| 24 // In GNOME 3, we might need to run gnome-control-center instead. We try this | 23 // In GNOME 3, we might need to run gnome-control-center instead. We try this |
| 25 // only after gnome-network-properties is not found, because older GNOME also | 24 // only after gnome-network-properties is not found, because older GNOME also |
| 26 // has this but it doesn't do the same thing. See below where we use it. | 25 // has this but it doesn't do the same thing. See below where we use it. |
| 27 const char* kGNOME3ProxyConfigCommand[] = {"gnome-control-center", "network", | 26 const char* kGNOME3ProxyConfigCommand[] = {"gnome-control-center", "network", |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 if (!found) | 76 if (!found) |
| 78 return false; | 77 return false; |
| 79 std::vector<std::string> argv; | 78 std::vector<std::string> argv; |
| 80 for (size_t i = 0; command[i]; ++i) | 79 for (size_t i = 0; command[i]; ++i) |
| 81 argv.push_back(command[i]); | 80 argv.push_back(command[i]); |
| 82 base::ProcessHandle handle; | 81 base::ProcessHandle handle; |
| 83 if (!base::LaunchProcess(argv, base::LaunchOptions(), &handle)) { | 82 if (!base::LaunchProcess(argv, base::LaunchOptions(), &handle)) { |
| 84 LOG(ERROR) << "StartProxyConfigUtil failed to start " << command[0]; | 83 LOG(ERROR) << "StartProxyConfigUtil failed to start " << command[0]; |
| 85 return false; | 84 return false; |
| 86 } | 85 } |
| 87 ProcessWatcher::EnsureProcessGetsReaped(handle); | 86 base::EnsureProcessGetsReaped(handle); |
| 88 return true; | 87 return true; |
| 89 } | 88 } |
| 90 | 89 |
| 91 // Detect, and if possible, start the appropriate proxy config utility. On | 90 // Detect, and if possible, start the appropriate proxy config utility. On |
| 92 // failure to do so, show the Linux proxy config URL in a new tab instead. | 91 // failure to do so, show the Linux proxy config URL in a new tab instead. |
| 93 void DetectAndStartProxyConfigUtil(TabContents* tab_contents) { | 92 void DetectAndStartProxyConfigUtil(TabContents* tab_contents) { |
| 94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 93 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 95 scoped_ptr<base::Environment> env(base::Environment::Create()); | 94 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 96 | 95 |
| 97 bool launched = false; | 96 bool launched = false; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 131 |
| 133 } // anonymous namespace | 132 } // anonymous namespace |
| 134 | 133 |
| 135 void AdvancedOptionsUtilities::ShowNetworkProxySettings( | 134 void AdvancedOptionsUtilities::ShowNetworkProxySettings( |
| 136 TabContents* tab_contents) { | 135 TabContents* tab_contents) { |
| 137 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 136 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 138 base::Bind(&DetectAndStartProxyConfigUtil, tab_contents)); | 137 base::Bind(&DetectAndStartProxyConfigUtil, tab_contents)); |
| 139 } | 138 } |
| 140 | 139 |
| 141 #endif // !defined(OS_CHROMEOS) | 140 #endif // !defined(OS_CHROMEOS) |
| OLD | NEW |