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 <comdef.h> | 5 #include <comdef.h> |
6 #include <iomanip> | 6 #include <iomanip> |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <winspool.h> | 8 #include <winspool.h> |
9 #include <setupapi.h> // Must be included after windows.h | 9 #include <setupapi.h> // Must be included after windows.h |
10 | 10 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 if (net_path.empty()) | 90 if (net_path.empty()) |
91 return; | 91 return; |
92 CommandLine command_line(net_path); | 92 CommandLine command_line(net_path); |
93 command_line.AppendArg(command); | 93 command_line.AppendArg(command); |
94 command_line.AppendArg("spooler"); | 94 command_line.AppendArg("spooler"); |
95 command_line.AppendArg("/y"); | 95 command_line.AppendArg("/y"); |
96 | 96 |
97 base::LaunchOptions options; | 97 base::LaunchOptions options; |
98 options.wait = true; | 98 options.wait = true; |
99 options.start_hidden = true; | 99 options.start_hidden = true; |
100 VLOG(0) << command_line.GetCommandLineString(); | 100 LOG(INFO) << command_line.GetCommandLineString(); |
101 base::LaunchProcess(command_line, options, NULL); | 101 base::LaunchProcess(command_line, options, NULL); |
102 } | 102 } |
103 | 103 |
104 HRESULT RegisterPortMonitor(bool install, const base::FilePath& install_path) { | 104 HRESULT RegisterPortMonitor(bool install, const base::FilePath& install_path) { |
105 DCHECK(install || install_path.empty()); | 105 DCHECK(install || install_path.empty()); |
106 base::FilePath target_path = GetNativeSystemPath(GetPortMonitorDllName()); | 106 base::FilePath target_path = GetNativeSystemPath(GetPortMonitorDllName()); |
107 if (target_path.empty()) { | 107 if (target_path.empty()) { |
108 LOG(ERROR) << "Unable to get port monitor target path."; | 108 LOG(ERROR) << "Unable to get port monitor target path."; |
109 return HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND); | 109 return HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND); |
110 } | 110 } |
(...skipping 22 matching lines...) Expand all Loading... |
133 command_line.AppendArg("/u"); | 133 command_line.AppendArg("/u"); |
134 } | 134 } |
135 | 135 |
136 // Use system32 path here because otherwise ::AddMonitor would fail. | 136 // Use system32 path here because otherwise ::AddMonitor would fail. |
137 command_line.AppendArgPath(GetSystemPath(GetPortMonitorDllName())); | 137 command_line.AppendArgPath(GetSystemPath(GetPortMonitorDllName())); |
138 | 138 |
139 base::LaunchOptions options; | 139 base::LaunchOptions options; |
140 options.wait = true; | 140 options.wait = true; |
141 | 141 |
142 base::win::ScopedHandle regsvr32_handle; | 142 base::win::ScopedHandle regsvr32_handle; |
143 if (!base::LaunchProcess(command_line.GetCommandLineString(), options, | 143 if (!base::LaunchProcess(command_line, options, regsvr32_handle.Receive())) { |
144 ®svr32_handle)) { | |
145 LOG(ERROR) << "Unable to launch regsvr32.exe."; | 144 LOG(ERROR) << "Unable to launch regsvr32.exe."; |
146 return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); | 145 return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); |
147 } | 146 } |
148 | 147 |
149 DWORD exit_code = S_OK; | 148 DWORD exit_code = S_OK; |
150 if (install) { | 149 if (install) { |
151 if (!GetExitCodeProcess(regsvr32_handle, &exit_code)) { | 150 if (!GetExitCodeProcess(regsvr32_handle, &exit_code)) { |
152 LOG(ERROR) << "Unable to get regsvr32.exe exit code."; | 151 LOG(ERROR) << "Unable to get regsvr32.exe exit code."; |
153 return GetLastHResult(); | 152 return GetLastHResult(); |
154 } | 153 } |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 } // namespace cloud_print | 533 } // namespace cloud_print |
535 | 534 |
536 int WINAPI WinMain(__in HINSTANCE hInstance, | 535 int WINAPI WinMain(__in HINSTANCE hInstance, |
537 __in HINSTANCE hPrevInstance, | 536 __in HINSTANCE hPrevInstance, |
538 __in LPSTR lpCmdLine, | 537 __in LPSTR lpCmdLine, |
539 __in int nCmdShow) { | 538 __in int nCmdShow) { |
540 base::AtExitManager at_exit_manager; | 539 base::AtExitManager at_exit_manager; |
541 CommandLine::Init(0, NULL); | 540 CommandLine::Init(0, NULL); |
542 HRESULT retval = cloud_print::ExecuteCommands(); | 541 HRESULT retval = cloud_print::ExecuteCommands(); |
543 | 542 |
544 VLOG(0) << _com_error(retval).ErrorMessage() << " HRESULT=0x" << | 543 LOG(INFO) << _com_error(retval).ErrorMessage() << " HRESULT=0x" << |
545 std::setbase(16) << retval; | 544 std::setbase(16) << retval; |
546 | 545 |
547 // Installer is silent by default as required by Google Update. | 546 // Installer is silent by default as required by Google Update. |
548 if (CommandLine::ForCurrentProcess()->HasSwitch("verbose")) { | 547 if (CommandLine::ForCurrentProcess()->HasSwitch("verbose")) { |
549 cloud_print::DisplayWindowsMessage(NULL, retval, | 548 cloud_print::DisplayWindowsMessage(NULL, retval, |
550 cloud_print::LoadLocalString(IDS_DRIVER_NAME)); | 549 cloud_print::LoadLocalString(IDS_DRIVER_NAME)); |
551 } | 550 } |
552 return retval; | 551 return retval; |
553 } | 552 } |
OLD | NEW |