| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 if (install) { | 149 if (install) { |
| 150 if (!GetExitCodeProcess(regsvr32_handle, &exit_code)) { | 150 if (!GetExitCodeProcess(regsvr32_handle, &exit_code)) { |
| 151 LOG(ERROR) << "Unable to get regsvr32.exe exit code."; | 151 LOG(ERROR) << "Unable to get regsvr32.exe exit code."; |
| 152 return GetLastHResult(); | 152 return GetLastHResult(); |
| 153 } | 153 } |
| 154 if (exit_code != 0) { | 154 if (exit_code != 0) { |
| 155 LOG(ERROR) << "Regsvr32.exe failed with " << exit_code; | 155 LOG(ERROR) << "Regsvr32.exe failed with " << exit_code; |
| 156 return HRESULT_FROM_WIN32(exit_code); | 156 return HRESULT_FROM_WIN32(exit_code); |
| 157 } | 157 } |
| 158 } else { | 158 } else { |
| 159 if (!base::Delete(target_path, false)) { | 159 if (!base::DeleteFile(target_path, false)) { |
| 160 SpoolerServiceCommand("stop"); | 160 SpoolerServiceCommand("stop"); |
| 161 bool deleted = base::Delete(target_path, false); | 161 bool deleted = base::DeleteFile(target_path, false); |
| 162 SpoolerServiceCommand("start"); | 162 SpoolerServiceCommand("start"); |
| 163 | 163 |
| 164 if(!deleted) { | 164 if(!deleted) { |
| 165 LOG(ERROR) << "Unable to delete " << target_path.value(); | 165 LOG(ERROR) << "Unable to delete " << target_path.value(); |
| 166 return HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED); | 166 return HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED); |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 return S_OK; | 170 return S_OK; |
| 171 } | 171 } |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 return result; | 473 return result; |
| 474 return RegisterVirtualDriver(install_path); | 474 return RegisterVirtualDriver(install_path); |
| 475 } | 475 } |
| 476 | 476 |
| 477 HRESULT DoDelete(const base::FilePath& install_path) { | 477 HRESULT DoDelete(const base::FilePath& install_path) { |
| 478 if (install_path.value().empty()) | 478 if (install_path.value().empty()) |
| 479 return E_INVALIDARG; | 479 return E_INVALIDARG; |
| 480 if (!base::DirectoryExists(install_path)) | 480 if (!base::DirectoryExists(install_path)) |
| 481 return S_FALSE; | 481 return S_FALSE; |
| 482 Sleep(5000); // Give parent some time to exit. | 482 Sleep(5000); // Give parent some time to exit. |
| 483 return base::Delete(install_path, true) ? S_OK : E_FAIL; | 483 return base::DeleteFile(install_path, true) ? S_OK : E_FAIL; |
| 484 } | 484 } |
| 485 | 485 |
| 486 HRESULT DoInstall(const base::FilePath& install_path) { | 486 HRESULT DoInstall(const base::FilePath& install_path) { |
| 487 HRESULT result = UnregisterVirtualDriver(); | 487 HRESULT result = UnregisterVirtualDriver(); |
| 488 if (FAILED(result)) { | 488 if (FAILED(result)) { |
| 489 LOG(ERROR) << "Unable to unregister."; | 489 LOG(ERROR) << "Unable to unregister."; |
| 490 return result; | 490 return result; |
| 491 } | 491 } |
| 492 base::FilePath old_install_path = GetInstallLocation(kUninstallId); | 492 base::FilePath old_install_path = GetInstallLocation(kUninstallId); |
| 493 if (!old_install_path.value().empty() && | 493 if (!old_install_path.value().empty() && |
| 494 install_path != old_install_path) { | 494 install_path != old_install_path) { |
| 495 if (base::DirectoryExists(old_install_path)) | 495 if (base::DirectoryExists(old_install_path)) |
| 496 base::Delete(old_install_path, true); | 496 base::DeleteFile(old_install_path, true); |
| 497 } | 497 } |
| 498 CreateUninstallKey(kUninstallId, LoadLocalString(IDS_DRIVER_NAME), | 498 CreateUninstallKey(kUninstallId, LoadLocalString(IDS_DRIVER_NAME), |
| 499 kUninstallSwitch); | 499 kUninstallSwitch); |
| 500 result = RegisterVirtualDriver(install_path); | 500 result = RegisterVirtualDriver(install_path); |
| 501 if (FAILED(result)) | 501 if (FAILED(result)) |
| 502 return result; | 502 return result; |
| 503 SetGoogleUpdateKeys(kGoogleUpdateProductId, kNameValue); | 503 SetGoogleUpdateKeys(kGoogleUpdateProductId, kNameValue); |
| 504 return result; | 504 return result; |
| 505 } | 505 } |
| 506 | 506 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 LOG(INFO) << _com_error(retval).ErrorMessage() << " HRESULT=0x" << | 543 LOG(INFO) << _com_error(retval).ErrorMessage() << " HRESULT=0x" << |
| 544 std::setbase(16) << retval; | 544 std::setbase(16) << retval; |
| 545 | 545 |
| 546 // Installer is silent by default as required by Google Update. | 546 // Installer is silent by default as required by Google Update. |
| 547 if (CommandLine::ForCurrentProcess()->HasSwitch("verbose")) { | 547 if (CommandLine::ForCurrentProcess()->HasSwitch("verbose")) { |
| 548 cloud_print::DisplayWindowsMessage(NULL, retval, | 548 cloud_print::DisplayWindowsMessage(NULL, retval, |
| 549 cloud_print::LoadLocalString(IDS_DRIVER_NAME)); | 549 cloud_print::LoadLocalString(IDS_DRIVER_NAME)); |
| 550 } | 550 } |
| 551 return retval; | 551 return retval; |
| 552 } | 552 } |
| OLD | NEW |