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

Side by Side Diff: remoting/host/setup/daemon_controller_delegate_linux.cc

Issue 290173011: Cleanup: Use base::CommandLine in remoting/ (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 7 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
« no previous file with comments | « remoting/host/service_urls.cc ('k') | remoting/host/setup/me2me_native_messaging_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "remoting/host/setup/daemon_controller_delegate_linux.h" 5 #include "remoting/host/setup/daemon_controller_delegate_linux.h"
6 6
7 #include <unistd.h> 7 #include <unistd.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // PATH, don't do it as root. 78 // PATH, don't do it as root.
79 if (getuid() == 0) { 79 if (getuid() == 0) {
80 LOG(ERROR) << "Refusing to run script as root."; 80 LOG(ERROR) << "Refusing to run script as root.";
81 return false; 81 return false;
82 } 82 }
83 base::FilePath script_path; 83 base::FilePath script_path;
84 if (!GetScriptPath(&script_path)) { 84 if (!GetScriptPath(&script_path)) {
85 LOG(ERROR) << "GetScriptPath() failed."; 85 LOG(ERROR) << "GetScriptPath() failed.";
86 return false; 86 return false;
87 } 87 }
88 CommandLine command_line(script_path); 88 base::CommandLine command_line(script_path);
89 for (unsigned int i = 0; i < args.size(); ++i) { 89 for (unsigned int i = 0; i < args.size(); ++i) {
90 command_line.AppendArg(args[i]); 90 command_line.AppendArg(args[i]);
91 } 91 }
92 base::ProcessHandle process_handle; 92 base::ProcessHandle process_handle;
93 93
94 // Redirect the child's stdout to the parent's stderr. In the case where this 94 // Redirect the child's stdout to the parent's stderr. In the case where this
95 // parent process is a Native Messaging host, its stdout is used to send 95 // parent process is a Native Messaging host, its stdout is used to send
96 // messages to the web-app. 96 // messages to the web-app.
97 base::FileHandleMappingVector fds_to_remap; 97 base::FileHandleMappingVector fds_to_remap;
98 fds_to_remap.push_back(std::pair<int, int>(STDERR_FILENO, STDOUT_FILENO)); 98 fds_to_remap.push_back(std::pair<int, int>(STDERR_FILENO, STDOUT_FILENO));
(...skipping 26 matching lines...) Expand all
125 } 125 }
126 126
127 DaemonControllerDelegateLinux::~DaemonControllerDelegateLinux() { 127 DaemonControllerDelegateLinux::~DaemonControllerDelegateLinux() {
128 } 128 }
129 129
130 DaemonController::State DaemonControllerDelegateLinux::GetState() { 130 DaemonController::State DaemonControllerDelegateLinux::GetState() {
131 base::FilePath script_path; 131 base::FilePath script_path;
132 if (!GetScriptPath(&script_path)) { 132 if (!GetScriptPath(&script_path)) {
133 return DaemonController::STATE_NOT_IMPLEMENTED; 133 return DaemonController::STATE_NOT_IMPLEMENTED;
134 } 134 }
135 CommandLine command_line(script_path); 135 base::CommandLine command_line(script_path);
136 command_line.AppendArg("--get-status"); 136 command_line.AppendArg("--get-status");
137 137
138 std::string status; 138 std::string status;
139 int exit_code = 0; 139 int exit_code = 0;
140 bool result = 140 bool result =
141 base::GetAppOutputWithExitCode(command_line, &status, &exit_code); 141 base::GetAppOutputWithExitCode(command_line, &status, &exit_code);
142 if (!result) { 142 if (!result) {
143 // TODO(jamiewalch): When we have a good story for installing, return 143 // TODO(jamiewalch): When we have a good story for installing, return
144 // NOT_INSTALLED rather than NOT_IMPLEMENTED (the former suppresses 144 // NOT_INSTALLED rather than NOT_IMPLEMENTED (the former suppresses
145 // the relevant UI in the web-app). 145 // the relevant UI in the web-app).
(...skipping 29 matching lines...) Expand all
175 JsonHostConfig config(GetConfigPath()); 175 JsonHostConfig config(GetConfigPath());
176 if (config.Read()) { 176 if (config.Read()) {
177 std::string value; 177 std::string value;
178 if (config.GetString(kHostIdConfigPath, &value)) { 178 if (config.GetString(kHostIdConfigPath, &value)) {
179 result->SetString(kHostIdConfigPath, value); 179 result->SetString(kHostIdConfigPath, value);
180 } 180 }
181 if (config.GetString(kXmppLoginConfigPath, &value)) { 181 if (config.GetString(kXmppLoginConfigPath, &value)) {
182 result->SetString(kXmppLoginConfigPath, value); 182 result->SetString(kXmppLoginConfigPath, value);
183 } 183 }
184 } else { 184 } else {
185 result.reset(); // Return NULL in case of error. 185 result.reset(); // Return NULL in case of error.
186 } 186 }
187 } 187 }
188 188
189 return result.Pass(); 189 return result.Pass();
190 } 190 }
191 191
192 void DaemonControllerDelegateLinux::InstallHost( 192 void DaemonControllerDelegateLinux::InstallHost(
193 const DaemonController::CompletionCallback& done) { 193 const DaemonController::CompletionCallback& done) {
194 NOTREACHED(); 194 NOTREACHED();
195 } 195 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 275
276 void DaemonControllerDelegateLinux::SetWindow(void* window_handle) { 276 void DaemonControllerDelegateLinux::SetWindow(void* window_handle) {
277 // noop 277 // noop
278 } 278 }
279 279
280 std::string DaemonControllerDelegateLinux::GetVersion() { 280 std::string DaemonControllerDelegateLinux::GetVersion() {
281 base::FilePath script_path; 281 base::FilePath script_path;
282 if (!GetScriptPath(&script_path)) { 282 if (!GetScriptPath(&script_path)) {
283 return std::string(); 283 return std::string();
284 } 284 }
285 CommandLine command_line(script_path); 285 base::CommandLine command_line(script_path);
286 command_line.AppendArg("--host-version"); 286 command_line.AppendArg("--host-version");
287 287
288 std::string version; 288 std::string version;
289 int exit_code = 0; 289 int exit_code = 0;
290 int result = 290 int result =
291 base::GetAppOutputWithExitCode(command_line, &version, &exit_code); 291 base::GetAppOutputWithExitCode(command_line, &version, &exit_code);
292 if (!result || exit_code != 0) { 292 if (!result || exit_code != 0) {
293 LOG(ERROR) << "Failed to run \"" << command_line.GetCommandLineString() 293 LOG(ERROR) << "Failed to run \"" << command_line.GetCommandLineString()
294 << "\". Exit code: " << exit_code; 294 << "\". Exit code: " << exit_code;
295 return std::string(); 295 return std::string();
(...skipping 19 matching lines...) Expand all
315 return consent; 315 return consent;
316 } 316 }
317 317
318 scoped_refptr<DaemonController> DaemonController::Create() { 318 scoped_refptr<DaemonController> DaemonController::Create() {
319 scoped_ptr<DaemonController::Delegate> delegate( 319 scoped_ptr<DaemonController::Delegate> delegate(
320 new DaemonControllerDelegateLinux()); 320 new DaemonControllerDelegateLinux());
321 return new DaemonController(delegate.Pass()); 321 return new DaemonController(delegate.Pass());
322 } 322 }
323 323
324 } // namespace remoting 324 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/service_urls.cc ('k') | remoting/host/setup/me2me_native_messaging_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698