Chromium Code Reviews| 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); | |
|
Sergey Ulanov
2012/04/27 01:29:22
nit: add {} to match style of other ifs in this fi
Wez
2012/04/28 05:16:37
Done.
| |
| 203 if (config.GetString(kXmppLoginConfigPath, &value)) | |
| 204 result->SetString(kXmppLoginConfigPath, value); | |
| 205 } else { | |
| 206 result.reset(); // Return NULL in case of error. | |
| 207 } | |
| 205 } | 208 } |
| 209 | |
| 206 callback.Run(result.Pass()); | 210 callback.Run(result.Pass()); |
| 207 } | 211 } |
| 208 | 212 |
| 209 void DaemonControllerLinux::DoSetConfigAndStart( | 213 void DaemonControllerLinux::DoSetConfigAndStart( |
| 210 scoped_ptr<base::DictionaryValue> config, | 214 scoped_ptr<base::DictionaryValue> config, |
| 211 const CompletionCallback& done_callback) { | 215 const CompletionCallback& done_callback) { |
| 212 std::vector<std::string> args; | 216 std::vector<std::string> args; |
| 213 args.push_back("--explicit-config"); | 217 args.push_back("--explicit-config"); |
| 214 std::string config_json; | 218 std::string config_json; |
| 215 base::JSONWriter::Write(config.get(), &config_json); | 219 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); | 264 done_callback.Run(result); |
| 261 } | 265 } |
| 262 | 266 |
| 263 } // namespace | 267 } // namespace |
| 264 | 268 |
| 265 scoped_ptr<DaemonController> remoting::DaemonController::Create() { | 269 scoped_ptr<DaemonController> remoting::DaemonController::Create() { |
| 266 return scoped_ptr<DaemonController>(new DaemonControllerLinux()); | 270 return scoped_ptr<DaemonController>(new DaemonControllerLinux()); |
| 267 } | 271 } |
| 268 | 272 |
| 269 } // namespace remoting | 273 } // namespace remoting |
| OLD | NEW |