| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // Remove everything except kCloudPrintRoot. | 126 // Remove everything except kCloudPrintRoot. |
| 127 scoped_ptr<base::Value> cloud_print_root; | 127 scoped_ptr<base::Value> cloud_print_root; |
| 128 dictionary->Remove(prefs::kCloudPrintRoot, &cloud_print_root); | 128 dictionary->Remove(prefs::kCloudPrintRoot, &cloud_print_root); |
| 129 dictionary->Clear(); | 129 dictionary->Clear(); |
| 130 dictionary->Set(prefs::kCloudPrintRoot, cloud_print_root.release()); | 130 dictionary->Set(prefs::kCloudPrintRoot, cloud_print_root.release()); |
| 131 | 131 |
| 132 dictionary->SetBoolean(prefs::kCloudPrintXmppPingEnabled, true); | 132 dictionary->SetBoolean(prefs::kCloudPrintXmppPingEnabled, true); |
| 133 if (!proxy_id.empty()) // Reuse proxy id if we already had one. | 133 if (!proxy_id.empty()) // Reuse proxy id if we already had one. |
| 134 dictionary->SetString(prefs::kCloudPrintProxyId, proxy_id); | 134 dictionary->SetString(prefs::kCloudPrintProxyId, proxy_id); |
| 135 std::string result; | 135 std::string result; |
| 136 base::JSONWriter::WriteWithOptions(dictionary, | 136 base::JSONWriter::WriteWithOptions(*dictionary, |
| 137 base::JSONWriter::OPTIONS_PRETTY_PRINT, | 137 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
| 138 &result); | 138 &result); |
| 139 return result; | 139 return result; |
| 140 } | 140 } |
| 141 | 141 |
| 142 void DeleteAutorunKeys(const base::FilePath& user_data_dir) { | 142 void DeleteAutorunKeys(const base::FilePath& user_data_dir) { |
| 143 base::win::RegKey key(HKEY_CURRENT_USER, kAutoRunKeyPath, KEY_SET_VALUE); | 143 base::win::RegKey key(HKEY_CURRENT_USER, kAutoRunKeyPath, KEY_SET_VALUE); |
| 144 if (!key.Valid()) | 144 if (!key.Valid()) |
| 145 return; | 145 return; |
| 146 std::vector<base::string16> to_delete; | 146 std::vector<base::string16> to_delete; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 if (chrome_path.empty()) { | 269 if (chrome_path.empty()) { |
| 270 LOG(ERROR) << "Can't find Chrome."; | 270 LOG(ERROR) << "Can't find Chrome."; |
| 271 return std::string(); | 271 return std::string(); |
| 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 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); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |