| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/settings_utils.h" |
| 8 | 8 |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/environment.h" | 12 #include "base/environment.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
| 15 #include "base/nix/xdg_util.h" | 15 #include "base/nix/xdg_util.h" |
| 16 #include "base/process/launch.h" | 16 #include "base/process/launch.h" |
| 17 #include "base/strings/string_split.h" | 17 #include "base/strings/string_split.h" |
| 18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 20 #include "chrome/browser/tab_contents/tab_util.h" | 20 #include "chrome/browser/tab_contents/tab_util.h" |
| 21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/render_process_host.h" | 22 #include "content/public/browser/render_process_host.h" |
| 23 #include "content/public/browser/render_view_host.h" | 23 #include "content/public/browser/render_view_host.h" |
| 24 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 25 | 25 |
| 26 using content::BrowserThread; | 26 using content::BrowserThread; |
| 27 using content::OpenURLParams; | 27 using content::OpenURLParams; |
| 28 using content::Referrer; | 28 using content::Referrer; |
| 29 using content::WebContents; | |
| 30 | 29 |
| 31 namespace options { | 30 namespace settings_utils { |
| 32 | 31 |
| 33 // Command used to configure GNOME 2 proxy settings. | 32 // Command used to configure GNOME 2 proxy settings. |
| 34 const char* kGNOME2ProxyConfigCommand[] = {"gnome-network-properties", NULL}; | 33 const char* kGNOME2ProxyConfigCommand[] = {"gnome-network-properties", NULL}; |
| 35 // In GNOME 3, we might need to run gnome-control-center instead. We try this | 34 // In GNOME 3, we might need to run gnome-control-center instead. We try this |
| 36 // only after gnome-network-properties is not found, because older GNOME also | 35 // only after gnome-network-properties is not found, because older GNOME also |
| 37 // has this but it doesn't do the same thing. See below where we use it. | 36 // has this but it doesn't do the same thing. See below where we use it. |
| 38 const char* kGNOME3ProxyConfigCommand[] = {"gnome-control-center", "network", | 37 const char* kGNOME3ProxyConfigCommand[] = {"gnome-control-center", "network", |
| 39 NULL}; | 38 NULL}; |
| 40 // KDE3, 4, and 5 are only slightly different, but incompatible. Go figure. | 39 // KDE3, 4, and 5 are only slightly different, but incompatible. Go figure. |
| 41 const char* kKDE3ProxyConfigCommand[] = {"kcmshell", "proxy", NULL}; | 40 const char* kKDE3ProxyConfigCommand[] = {"kcmshell", "proxy", NULL}; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 52 void ShowLinuxProxyConfigUrl(int render_process_id, int render_view_id) { | 51 void ShowLinuxProxyConfigUrl(int render_process_id, int render_view_id) { |
| 53 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 52 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 54 scoped_ptr<base::Environment> env(base::Environment::Create()); | 53 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 55 const char* name = base::nix::GetDesktopEnvironmentName(env.get()); | 54 const char* name = base::nix::GetDesktopEnvironmentName(env.get()); |
| 56 if (name) | 55 if (name) |
| 57 LOG(ERROR) << "Could not find " << name << " network settings in $PATH"; | 56 LOG(ERROR) << "Could not find " << name << " network settings in $PATH"; |
| 58 OpenURLParams params( | 57 OpenURLParams params( |
| 59 GURL(kLinuxProxyConfigUrl), Referrer(), NEW_FOREGROUND_TAB, | 58 GURL(kLinuxProxyConfigUrl), Referrer(), NEW_FOREGROUND_TAB, |
| 60 ui::PAGE_TRANSITION_LINK, false); | 59 ui::PAGE_TRANSITION_LINK, false); |
| 61 | 60 |
| 62 WebContents* web_contents = | 61 content::WebContents* web_contents = |
| 63 tab_util::GetWebContentsByID(render_process_id, render_view_id); | 62 tab_util::GetWebContentsByID(render_process_id, render_view_id); |
| 64 if (web_contents) | 63 if (web_contents) |
| 65 web_contents->OpenURL(params); | 64 web_contents->OpenURL(params); |
| 66 } | 65 } |
| 67 | 66 |
| 68 // Start the given proxy configuration utility. | 67 // Start the given proxy configuration utility. |
| 69 bool StartProxyConfigUtil(const char* command[]) { | 68 bool StartProxyConfigUtil(const char* command[]) { |
| 70 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 69 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 71 // base::LaunchProcess() returns true ("success") if the fork() | 70 // base::LaunchProcess() returns true ("success") if the fork() |
| 72 // succeeds, but not necessarily the exec(). We'd like to be able to | 71 // succeeds, but not necessarily the exec(). We'd like to be able to |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 } | 149 } |
| 151 | 150 |
| 152 if (launched) | 151 if (launched) |
| 153 return; | 152 return; |
| 154 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 153 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 155 base::Bind(&ShowLinuxProxyConfigUrl, render_process_id, render_view_id)); | 154 base::Bind(&ShowLinuxProxyConfigUrl, render_process_id, render_view_id)); |
| 156 } | 155 } |
| 157 | 156 |
| 158 } // anonymous namespace | 157 } // anonymous namespace |
| 159 | 158 |
| 160 void AdvancedOptionsUtilities::ShowNetworkProxySettings( | 159 void ShowNetworkProxySettings(content::WebContents* web_contents) { |
| 161 WebContents* web_contents) { | |
| 162 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 160 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 163 base::Bind(&DetectAndStartProxyConfigUtil, | 161 base::Bind(&DetectAndStartProxyConfigUtil, |
| 164 web_contents->GetRenderProcessHost()->GetID(), | 162 web_contents->GetRenderProcessHost()->GetID(), |
| 165 web_contents->GetRenderViewHost()->GetRoutingID())); | 163 web_contents->GetRenderViewHost()->GetRoutingID())); |
| 166 } | 164 } |
| 167 | 165 |
| 168 } // namespace options | 166 } // namespace settings_utils |
| 169 | 167 |
| 170 #endif // !defined(OS_CHROMEOS) | 168 #endif // !defined(OS_CHROMEOS) |
| OLD | NEW |