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/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 | 285 |
286 // Optional. | 286 // Optional. |
287 cmd.AppendSwitch(switches::kDisableBackgroundMode); | 287 cmd.AppendSwitch(switches::kDisableBackgroundMode); |
288 cmd.AppendSwitch(switches::kDisableDefaultApps); | 288 cmd.AppendSwitch(switches::kDisableDefaultApps); |
289 cmd.AppendSwitch(switches::kDisableExtensions); | 289 cmd.AppendSwitch(switches::kDisableExtensions); |
290 cmd.AppendSwitch(switches::kDisableSync); | 290 cmd.AppendSwitch(switches::kDisableSync); |
291 cmd.AppendSwitch(switches::kNoDefaultBrowserCheck); | 291 cmd.AppendSwitch(switches::kNoDefaultBrowserCheck); |
292 cmd.AppendSwitch(switches::kNoFirstRun); | 292 cmd.AppendSwitch(switches::kNoFirstRun); |
293 | 293 |
294 cmd.AppendArg( | 294 cmd.AppendArg( |
295 cloud_devices::GetCloudPrintEnableURLWithSignin(proxy_id).spec()); | 295 cloud_devices::GetCloudPrintEnableWithSigninURL(proxy_id).spec()); |
296 | 296 |
297 base::win::ScopedHandle chrome_handle; | 297 base::win::ScopedHandle chrome_handle; |
298 DWORD thread_id = 0; | 298 DWORD thread_id = 0; |
299 if (!LaunchProcess(cmd, &chrome_handle, &thread_id)) { | 299 if (!LaunchProcess(cmd, &chrome_handle, &thread_id)) { |
300 LOG(ERROR) << "Unable to launch Chrome."; | 300 LOG(ERROR) << "Unable to launch Chrome."; |
301 return std::string(); | 301 return std::string(); |
302 } | 302 } |
303 | 303 |
304 for (;;) { | 304 for (;;) { |
305 DWORD wait_result = ::WaitForSingleObject(chrome_handle, 500); | 305 DWORD wait_result = ::WaitForSingleObject(chrome_handle, 500); |
306 std::string json = ReadAndUpdateServiceState(temp_user_data.path(), | 306 std::string json = ReadAndUpdateServiceState(temp_user_data.path(), |
307 proxy_id); | 307 proxy_id); |
308 if (wait_result == WAIT_OBJECT_0) { | 308 if (wait_result == WAIT_OBJECT_0) { |
309 // Return what we have because browser is closed. | 309 // Return what we have because browser is closed. |
310 return json; | 310 return json; |
311 } | 311 } |
312 if (wait_result != WAIT_TIMEOUT) { | 312 if (wait_result != WAIT_TIMEOUT) { |
313 LOG(ERROR) << "Chrome launch failed."; | 313 LOG(ERROR) << "Chrome launch failed."; |
314 return std::string(); | 314 return std::string(); |
315 } | 315 } |
316 if (!json.empty()) { | 316 if (!json.empty()) { |
317 // Close chrome because Service State is ready. | 317 // Close chrome because Service State is ready. |
318 CloseChrome(chrome_handle, thread_id); | 318 CloseChrome(chrome_handle, thread_id); |
319 return json; | 319 return json; |
320 } | 320 } |
321 } | 321 } |
322 } | 322 } |
323 | 323 |
OLD | NEW |