| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/plugin/daemon_controller.h" | 5 #include "remoting/host/plugin/daemon_controller.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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 // noop | 185 // noop |
| 186 } | 186 } |
| 187 | 187 |
| 188 FilePath DaemonControllerLinux::GetConfigPath() { | 188 FilePath DaemonControllerLinux::GetConfigPath() { |
| 189 std::string filename = "host#" + GetMd5(net::GetHostName()) + ".json"; | 189 std::string filename = "host#" + GetMd5(net::GetHostName()) + ".json"; |
| 190 return file_util::GetHomeDir(). | 190 return file_util::GetHomeDir(). |
| 191 Append(".config/chrome-remote-desktop").Append(filename); | 191 Append(".config/chrome-remote-desktop").Append(filename); |
| 192 } | 192 } |
| 193 | 193 |
| 194 void DaemonControllerLinux::DoGetConfig(const GetConfigCallback& callback) { | 194 void DaemonControllerLinux::DoGetConfig(const GetConfigCallback& callback) { |
| 195 JsonHostConfig config(GetConfigPath()); | 195 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
| 196 scoped_ptr<base::DictionaryValue> result; | |
| 197 if (config.Read()) { | |
| 198 result.reset(new base::DictionaryValue()); | |
| 199 | 196 |
| 200 std::string value; | 197 if (GetState() != remoting::DaemonController::STATE_NOT_IMPLEMENTED) { |
| 201 if (config.GetString(kHostIdConfigPath, &value)) | 198 JsonHostConfig config(GetConfigPath()); |
| 202 result->SetString(kHostIdConfigPath, value); | 199 if (config.Read()) { |
| 203 if (config.GetString(kXmppLoginConfigPath, &value)) | 200 std::string value; |
| 204 result->SetString(kXmppLoginConfigPath, value); | 201 if (config.GetString(kHostIdConfigPath, &value)) { |
| 202 result->SetString(kHostIdConfigPath, value); |
| 203 } |
| 204 if (config.GetString(kXmppLoginConfigPath, &value)) { |
| 205 result->SetString(kXmppLoginConfigPath, value); |
| 206 } |
| 207 } else { |
| 208 result.reset(); // Return NULL in case of error. |
| 209 } |
| 205 } | 210 } |
| 211 |
| 206 callback.Run(result.Pass()); | 212 callback.Run(result.Pass()); |
| 207 } | 213 } |
| 208 | 214 |
| 209 void DaemonControllerLinux::DoSetConfigAndStart( | 215 void DaemonControllerLinux::DoSetConfigAndStart( |
| 210 scoped_ptr<base::DictionaryValue> config, | 216 scoped_ptr<base::DictionaryValue> config, |
| 211 const CompletionCallback& done_callback) { | 217 const CompletionCallback& done_callback) { |
| 212 std::vector<std::string> args; | 218 std::vector<std::string> args; |
| 213 args.push_back("--explicit-config"); | 219 args.push_back("--explicit-config"); |
| 214 std::string config_json; | 220 std::string config_json; |
| 215 base::JSONWriter::Write(config.get(), &config_json); | 221 base::JSONWriter::Write(config.get(), &config_json); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 done_callback.Run(result); | 266 done_callback.Run(result); |
| 261 } | 267 } |
| 262 | 268 |
| 263 } // namespace | 269 } // namespace |
| 264 | 270 |
| 265 scoped_ptr<DaemonController> remoting::DaemonController::Create() { | 271 scoped_ptr<DaemonController> remoting::DaemonController::Create() { |
| 266 return scoped_ptr<DaemonController>(new DaemonControllerLinux()); | 272 return scoped_ptr<DaemonController>(new DaemonControllerLinux()); |
| 267 } | 273 } |
| 268 | 274 |
| 269 } // namespace remoting | 275 } // namespace remoting |
| OLD | NEW |