Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "win8/test/metro_registration_helper.h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "base/file_path.h" | |
| 9 #include "base/file_util.h" | |
| 10 #include "base/logging.h" | |
| 11 #include "base/path_service.h" | |
| 12 #include "base/process.h" | |
| 13 #include "base/process_util.h" | |
| 14 #include "base/win/scoped_handle.h" | |
| 15 #include "win8/test/test_registrar_constants.h" | |
| 16 | |
| 17 namespace { | |
| 18 | |
| 19 const int kRegistrationTimeoutMs = 30000; | |
| 20 | |
| 21 // Copied from util_constants.cc to avoid taking a dependency on installer_util. | |
| 22 const wchar_t kChromeExe[] = L"chrome.exe"; | |
| 23 const wchar_t kRegistrar[] = L"test_registrar.exe"; | |
| 24 | |
| 25 } | |
| 26 | |
| 27 namespace win8 { | |
| 28 | |
| 29 bool RegisterTestDefaultBrowser(const string16& app_user_model_id, | |
| 30 const string16& viewer_process_name) { | |
| 31 FilePath dir; | |
| 32 if (!PathService::Get(base::DIR_EXE, &dir)) | |
| 33 return false; | |
| 34 | |
| 35 FilePath chrome_exe(dir.Append(kChromeExe)); | |
| 36 FilePath registrar(dir.Append(kRegistrar)); | |
| 37 | |
| 38 if (!file_util::PathExists(chrome_exe) || !file_util::PathExists(registrar)) { | |
| 39 LOG(ERROR) << "Could not locate " << kChromeExe << " or " << kRegistrar; | |
| 40 return false; | |
| 41 } | |
| 42 | |
| 43 // Perform the registration by invoking test_registrar.exe with the | |
| 44 // necessary flags: | |
| 45 // test_registrar.exe /RegServer --appid=<appid> --exe-name=<name> | |
| 46 CommandLine register_command(registrar); | |
| 47 register_command.AppendArg("/RegServer"); | |
| 48 register_command.AppendSwitchNative(win8::test::kTestAppUserModelId, | |
| 49 app_user_model_id); | |
| 50 register_command.AppendSwitchNative(win8::test::kTestExeName, | |
|
grt (UTC plus 2)
2013/02/12 18:17:27
i like this change.
robertshield
2013/02/12 18:35:34
thank you.
| |
| 51 viewer_process_name); | |
| 52 | |
| 53 base::win::ScopedHandle register_handle; | |
| 54 if (base::LaunchProcess(register_command, base::LaunchOptions(), | |
| 55 register_handle.Receive())) { | |
| 56 int ret = 0; | |
| 57 if (base::WaitForExitCodeWithTimeout( | |
| 58 register_handle, &ret, | |
| 59 base::TimeDelta::FromMilliseconds(kRegistrationTimeoutMs))) { | |
|
grt (UTC plus 2)
2013/02/12 18:17:27
how about using seconds rather than milliseconds?
robertshield
2013/02/12 18:35:34
Done.
| |
| 60 return ret == 0; | |
| 61 } | |
| 62 } | |
| 63 | |
| 64 LOG(ERROR) << "Win8 registration using " << kRegistrar << " timed out."; | |
|
grt (UTC plus 2)
2013/02/12 18:17:27
consider logging register_command.GetCommandLineSt
robertshield
2013/02/12 18:35:34
Done.
| |
| 65 return false; | |
| 66 } | |
| 67 | |
| 68 } // namespace win8 | |
| OLD | NEW |