| 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 <iomanip> | 5 #include <iomanip> |
| 6 #include <windows.h> | 6 #include <windows.h> |
| 7 #include <winspool.h> | 7 #include <winspool.h> |
| 8 #include <setupapi.h> // Must be included after windows.h | 8 #include <setupapi.h> // Must be included after windows.h |
| 9 | 9 |
| 10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 temp_path->Append(kDependencyList[i]).value().c_str()); | 203 temp_path->Append(kDependencyList[i]).value().c_str()); |
| 204 return FILEOP_DOIT; | 204 return FILEOP_DOIT; |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 return FILEOP_SKIP; | 207 return FILEOP_SKIP; |
| 208 } | 208 } |
| 209 return NO_ERROR; | 209 return NO_ERROR; |
| 210 } | 210 } |
| 211 | 211 |
| 212 void ReadyDriverDependencies(const base::FilePath& destination) { | 212 void ReadyDriverDependencies(const base::FilePath& destination) { |
| 213 base::FilePath destination_copy(destination); |
| 213 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { | 214 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { |
| 214 // GetCorePrinterDrivers and GetPrinterDriverPackagePath only exist on | 215 // GetCorePrinterDrivers and GetPrinterDriverPackagePath only exist on |
| 215 // Vista and later. Winspool.drv must be delayloaded so these calls don't | 216 // Vista and later. Winspool.drv must be delayloaded so these calls don't |
| 216 // create problems on XP. | 217 // create problems on XP. |
| 217 DWORD size = MAX_PATH; | 218 DWORD size = MAX_PATH; |
| 218 wchar_t package_path[MAX_PATH] = {0}; | 219 wchar_t package_path[MAX_PATH] = {0}; |
| 219 CORE_PRINTER_DRIVER driver; | 220 CORE_PRINTER_DRIVER driver; |
| 220 GetCorePrinterDrivers(NULL, NULL, L"{D20EA372-DD35-4950-9ED8-A6335AFE79F5}", | 221 GetCorePrinterDrivers(NULL, NULL, L"{D20EA372-DD35-4950-9ED8-A6335AFE79F5}", |
| 221 1, &driver); | 222 1, &driver); |
| 222 GetPrinterDriverPackagePath(NULL, NULL, NULL, driver.szPackageID, | 223 GetPrinterDriverPackagePath(NULL, NULL, NULL, driver.szPackageID, |
| 223 package_path, MAX_PATH, &size); | 224 package_path, MAX_PATH, &size); |
| 224 SetupIterateCabinet(package_path, 0, &CabinetCallback, | 225 SetupIterateCabinet(package_path, 0, &CabinetCallback, &destination_copy); |
| 225 &base::FilePath(destination)); | |
| 226 } else { | 226 } else { |
| 227 // Driver files are in the sp3 cab. | 227 // Driver files are in the sp3 cab. |
| 228 base::FilePath package_path; | 228 base::FilePath package_path; |
| 229 PathService::Get(base::DIR_WINDOWS, &package_path); | 229 PathService::Get(base::DIR_WINDOWS, &package_path); |
| 230 package_path = package_path.Append(L"Driver Cache\\i386\\sp3.cab"); | 230 package_path = package_path.Append(L"Driver Cache\\i386\\sp3.cab"); |
| 231 SetupIterateCabinet(package_path.value().c_str(), 0, &CabinetCallback, | 231 SetupIterateCabinet(package_path.value().c_str(), 0, &CabinetCallback, |
| 232 &base::FilePath(destination)); | 232 &destination_copy); |
| 233 | 233 |
| 234 // Copy the rest from the driver cache or system dir. | 234 // Copy the rest from the driver cache or system dir. |
| 235 base::FilePath driver_cache_path; | 235 base::FilePath driver_cache_path; |
| 236 PathService::Get(base::DIR_WINDOWS, &driver_cache_path); | 236 PathService::Get(base::DIR_WINDOWS, &driver_cache_path); |
| 237 driver_cache_path = driver_cache_path.Append(L"Driver Cache\\i386"); | 237 driver_cache_path = driver_cache_path.Append(L"Driver Cache\\i386"); |
| 238 for (size_t i = 0; i < arraysize(kDependencyList); ++i) { | 238 for (size_t i = 0; i < arraysize(kDependencyList); ++i) { |
| 239 base::FilePath dst_path = destination.Append(kDependencyList[i]); | 239 base::FilePath dst_path = destination.Append(kDependencyList[i]); |
| 240 if (!base::PathExists(dst_path)) { | 240 if (!base::PathExists(dst_path)) { |
| 241 base::FilePath src_path = driver_cache_path.Append(kDependencyList[i]); | 241 base::FilePath src_path = driver_cache_path.Append(kDependencyList[i]); |
| 242 if (!base::PathExists(src_path)) | 242 if (!base::PathExists(src_path)) |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 | 550 |
| 551 VLOG(0) << GetErrorMessage(retval) | 551 VLOG(0) << GetErrorMessage(retval) |
| 552 << " HRESULT=0x" << std::setbase(16) << retval; | 552 << " HRESULT=0x" << std::setbase(16) << retval; |
| 553 | 553 |
| 554 // Installer is silent by default as required by Google Update. | 554 // Installer is silent by default as required by Google Update. |
| 555 if (CommandLine::ForCurrentProcess()->HasSwitch("verbose")) { | 555 if (CommandLine::ForCurrentProcess()->HasSwitch("verbose")) { |
| 556 DisplayWindowsMessage(NULL, retval, LoadLocalString(IDS_DRIVER_NAME)); | 556 DisplayWindowsMessage(NULL, retval, LoadLocalString(IDS_DRIVER_NAME)); |
| 557 } | 557 } |
| 558 return retval; | 558 return retval; |
| 559 } | 559 } |
| OLD | NEW |