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

Side by Side Diff: chrome/browser/ui/webui/settings_utils_linux.cc

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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
OLDNEW
1 // Copyright 2016 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/settings_utils.h" 7 #include "chrome/browser/ui/webui/settings_utils.h"
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 // The URL for Linux proxy configuration help when not running under a 44 // The URL for Linux proxy configuration help when not running under a
45 // supported desktop environment. 45 // supported desktop environment.
46 const char kLinuxProxyConfigUrl[] = "about:linux-proxy-config"; 46 const char kLinuxProxyConfigUrl[] = "about:linux-proxy-config";
47 47
48 namespace { 48 namespace {
49 49
50 // Show the proxy config URL in the given tab. 50 // Show the proxy config URL in the given tab.
51 void ShowLinuxProxyConfigUrl(int render_process_id, int render_view_id) { 51 void ShowLinuxProxyConfigUrl(int render_process_id, int render_view_id) {
52 DCHECK_CURRENTLY_ON(BrowserThread::UI); 52 DCHECK_CURRENTLY_ON(BrowserThread::UI);
53 scoped_ptr<base::Environment> env(base::Environment::Create()); 53 std::unique_ptr<base::Environment> env(base::Environment::Create());
54 const char* name = base::nix::GetDesktopEnvironmentName(env.get()); 54 const char* name = base::nix::GetDesktopEnvironmentName(env.get());
55 if (name) 55 if (name)
56 LOG(ERROR) << "Could not find " << name << " network settings in $PATH"; 56 LOG(ERROR) << "Could not find " << name << " network settings in $PATH";
57 OpenURLParams params( 57 OpenURLParams params(
58 GURL(kLinuxProxyConfigUrl), Referrer(), NEW_FOREGROUND_TAB, 58 GURL(kLinuxProxyConfigUrl), Referrer(), NEW_FOREGROUND_TAB,
59 ui::PAGE_TRANSITION_LINK, false); 59 ui::PAGE_TRANSITION_LINK, false);
60 60
61 content::WebContents* web_contents = 61 content::WebContents* web_contents =
62 tab_util::GetWebContentsByID(render_process_id, render_view_id); 62 tab_util::GetWebContentsByID(render_process_id, render_view_id);
63 if (web_contents) 63 if (web_contents)
64 web_contents->OpenURL(params); 64 web_contents->OpenURL(params);
65 } 65 }
66 66
67 // Start the given proxy configuration utility. 67 // Start the given proxy configuration utility.
68 bool StartProxyConfigUtil(const char* command[]) { 68 bool StartProxyConfigUtil(const char* command[]) {
69 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 69 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
70 // base::LaunchProcess() returns true ("success") if the fork() 70 // base::LaunchProcess() returns true ("success") if the fork()
71 // 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
72 // use StartProxyConfigUtil() to search possible options and stop on 72 // use StartProxyConfigUtil() to search possible options and stop on
73 // success, so we search $PATH first to predict whether the exec is 73 // success, so we search $PATH first to predict whether the exec is
74 // expected to succeed. 74 // expected to succeed.
75 // TODO(mdm): this is a useful check, and is very similar to some 75 // TODO(mdm): this is a useful check, and is very similar to some
76 // code in proxy_config_service_linux.cc. It should probably be in 76 // code in proxy_config_service_linux.cc. It should probably be in
77 // base:: somewhere. 77 // base:: somewhere.
78 scoped_ptr<base::Environment> env(base::Environment::Create()); 78 std::unique_ptr<base::Environment> env(base::Environment::Create());
79 std::string path; 79 std::string path;
80 if (!env->GetVar("PATH", &path)) { 80 if (!env->GetVar("PATH", &path)) {
81 LOG(ERROR) << "No $PATH variable. Assuming no " << command[0] << "."; 81 LOG(ERROR) << "No $PATH variable. Assuming no " << command[0] << ".";
82 return false; 82 return false;
83 } 83 }
84 84
85 bool found = false; 85 bool found = false;
86 for (const base::StringPiece& cur_path : 86 for (const base::StringPiece& cur_path :
87 base::SplitStringPiece(path, ":", base::KEEP_WHITESPACE, 87 base::SplitStringPiece(path, ":", base::KEEP_WHITESPACE,
88 base::SPLIT_WANT_NONEMPTY)) { 88 base::SPLIT_WANT_NONEMPTY)) {
(...skipping 16 matching lines...) Expand all
105 } 105 }
106 base::EnsureProcessGetsReaped(process.Pid()); 106 base::EnsureProcessGetsReaped(process.Pid());
107 return true; 107 return true;
108 } 108 }
109 109
110 // Detect, and if possible, start the appropriate proxy config utility. On 110 // Detect, and if possible, start the appropriate proxy config utility. On
111 // failure to do so, show the Linux proxy config URL in a new tab instead. 111 // failure to do so, show the Linux proxy config URL in a new tab instead.
112 void DetectAndStartProxyConfigUtil(int render_process_id, 112 void DetectAndStartProxyConfigUtil(int render_process_id,
113 int render_view_id) { 113 int render_view_id) {
114 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 114 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
115 scoped_ptr<base::Environment> env(base::Environment::Create()); 115 std::unique_ptr<base::Environment> env(base::Environment::Create());
116 116
117 bool launched = false; 117 bool launched = false;
118 switch (base::nix::GetDesktopEnvironment(env.get())) { 118 switch (base::nix::GetDesktopEnvironment(env.get())) {
119 case base::nix::DESKTOP_ENVIRONMENT_GNOME: 119 case base::nix::DESKTOP_ENVIRONMENT_GNOME:
120 case base::nix::DESKTOP_ENVIRONMENT_UNITY: { 120 case base::nix::DESKTOP_ENVIRONMENT_UNITY: {
121 launched = StartProxyConfigUtil(kGNOME2ProxyConfigCommand); 121 launched = StartProxyConfigUtil(kGNOME2ProxyConfigCommand);
122 if (!launched) { 122 if (!launched) {
123 // We try this second, even though it's the newer way, because this 123 // We try this second, even though it's the newer way, because this
124 // command existed in older versions of GNOME, but it didn't do the 124 // command existed in older versions of GNOME, but it didn't do the
125 // same thing. The older command is gone though, so this should do 125 // same thing. The older command is gone though, so this should do
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 void ShowNetworkProxySettings(content::WebContents* web_contents) { 159 void ShowNetworkProxySettings(content::WebContents* web_contents) {
160 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 160 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
161 base::Bind(&DetectAndStartProxyConfigUtil, 161 base::Bind(&DetectAndStartProxyConfigUtil,
162 web_contents->GetRenderProcessHost()->GetID(), 162 web_contents->GetRenderProcessHost()->GetID(),
163 web_contents->GetRenderViewHost()->GetRoutingID())); 163 web_contents->GetRenderViewHost()->GetRoutingID()));
164 } 164 }
165 165
166 } // namespace settings_utils 166 } // namespace settings_utils
167 167
168 #endif // !defined(OS_CHROMEOS) 168 #endif // !defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698