| 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 "cloud_print/service/win/chrome_launcher.h" | 5 #include "cloud_print/service/win/chrome_launcher.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 } | 272 } |
| 273 | 273 |
| 274 base::FilePath printers_file = temp_user_data.path().Append(L"printers.json"); | 274 base::FilePath printers_file = temp_user_data.path().Append(L"printers.json"); |
| 275 | 275 |
| 276 base::ListValue printer_list; | 276 base::ListValue printer_list; |
| 277 printer_list.AppendStrings(printers); | 277 printer_list.AppendStrings(printers); |
| 278 std::string printers_json; | 278 std::string printers_json; |
| 279 base::JSONWriter::Write(printer_list, &printers_json); | 279 base::JSONWriter::Write(printer_list, &printers_json); |
| 280 size_t written = base::WriteFile(printers_file, | 280 size_t written = base::WriteFile(printers_file, |
| 281 printers_json.c_str(), | 281 printers_json.c_str(), |
| 282 printers_json.size()); | 282 static_cast<int>(printers_json.size())); |
| 283 if (written != printers_json.size()) { | 283 if (written != printers_json.size()) { |
| 284 LOG(ERROR) << "Can't write file."; | 284 LOG(ERROR) << "Can't write file."; |
| 285 return std::string(); | 285 return std::string(); |
| 286 } | 286 } |
| 287 | 287 |
| 288 base::CommandLine cmd(chrome_path); | 288 base::CommandLine cmd(chrome_path); |
| 289 CopyChromeSwitchesFromCurrentProcess(&cmd); | 289 CopyChromeSwitchesFromCurrentProcess(&cmd); |
| 290 cmd.AppendSwitchPath(switches::kUserDataDir, temp_user_data.path()); | 290 cmd.AppendSwitchPath(switches::kUserDataDir, temp_user_data.path()); |
| 291 cmd.AppendSwitchPath(switches::kCloudPrintSetupProxy, printers_file); | 291 cmd.AppendSwitchPath(switches::kCloudPrintSetupProxy, printers_file); |
| 292 cmd.AppendSwitch(switches::kNoServiceAutorun); | 292 cmd.AppendSwitch(switches::kNoServiceAutorun); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 321 LOG(ERROR) << "Chrome launch failed."; | 321 LOG(ERROR) << "Chrome launch failed."; |
| 322 return std::string(); | 322 return std::string(); |
| 323 } | 323 } |
| 324 if (!json.empty()) { | 324 if (!json.empty()) { |
| 325 // Close chrome because Service State is ready. | 325 // Close chrome because Service State is ready. |
| 326 CloseChrome(chrome_process.Pass(), thread_id); | 326 CloseChrome(chrome_process.Pass(), thread_id); |
| 327 return json; | 327 return json; |
| 328 } | 328 } |
| 329 } | 329 } |
| 330 } | 330 } |
| OLD | NEW |