Commit db32d906 authored by abodenha@chromium.org's avatar abodenha@chromium.org

Add support for XP SP3 in the Virtual Print Driver.

Delayload winspool.drv and pull the files we need from fixed locations on XP instead of relying on core drivers.
On Vista and later the install flow is unchanged GetCorePrinterDrivers and GetPrinterDriverPackagePath are delayloaded so they don't crash on XP.
Needed to modify the CabinetCallback to handle the variable structure of the cabs on the different platforms.
Added an OS version check on startup.


BUG=112035
TEST=Install on XP SP3


Review URL: http://codereview.chromium.org/9812030

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128253 0039d316-1c4b-4281-b951-d872f2087c98
parent a5a98a33
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "base/string16.h" #include "base/string16.h"
#include "base/win/registry.h" #include "base/win/registry.h"
#include "base/win/scoped_handle.h" #include "base/win/scoped_handle.h"
#include "base/win/windows_version.h"
#include "cloud_print/virtual_driver/win/virtual_driver_consts.h" #include "cloud_print/virtual_driver/win/virtual_driver_consts.h"
#include "cloud_print/virtual_driver/win/virtual_driver_helpers.h" #include "cloud_print/virtual_driver/win/virtual_driver_helpers.h"
#include "grit/virtual_driver_setup_resources.h" #include "grit/virtual_driver_setup_resources.h"
...@@ -70,6 +71,7 @@ void DeleteOmahaKeys() { ...@@ -70,6 +71,7 @@ void DeleteOmahaKeys() {
if (key.Open(HKEY_LOCAL_MACHINE, cloud_print::kKeyLocation, if (key.Open(HKEY_LOCAL_MACHINE, cloud_print::kKeyLocation,
DELETE) != ERROR_SUCCESS) { DELETE) != ERROR_SUCCESS) {
LOG(ERROR) << "Unable to open key to delete"; LOG(ERROR) << "Unable to open key to delete";
return;
} }
if (key.DeleteKey(L"") != ERROR_SUCCESS) { if (key.DeleteKey(L"") != ERROR_SUCCESS) {
LOG(ERROR) << "Unable to delete key"; LOG(ERROR) << "Unable to delete key";
...@@ -198,7 +200,10 @@ UINT CALLBACK CabinetCallback(PVOID data, ...@@ -198,7 +200,10 @@ UINT CALLBACK CabinetCallback(PVOID data,
FILE_IN_CABINET_INFO* info = FILE_IN_CABINET_INFO* info =
reinterpret_cast<FILE_IN_CABINET_INFO*>(param1); reinterpret_cast<FILE_IN_CABINET_INFO*>(param1);
for (int i = 0; i < arraysize(kDependencyList); i++) { for (int i = 0; i < arraysize(kDependencyList); i++) {
if (wcsstr(info->NameInCabinet, kDependencyList[i])) { FilePath base_name(info->NameInCabinet);
base_name = base_name.BaseName();
if (FilePath::CompareEqualIgnoreCase(base_name.value().c_str(),
kDependencyList[i])) {
StringCchCopy(info->FullTargetName, MAX_PATH, StringCchCopy(info->FullTargetName, MAX_PATH,
temp_path->Append(kDependencyList[i]).value().c_str()); temp_path->Append(kDependencyList[i]).value().c_str());
return FILEOP_DOIT; return FILEOP_DOIT;
...@@ -211,26 +216,47 @@ UINT CALLBACK CabinetCallback(PVOID data, ...@@ -211,26 +216,47 @@ UINT CALLBACK CabinetCallback(PVOID data,
} }
void ReadyPpdDependencies(const FilePath& install_path) { void ReadyPpdDependencies(const FilePath& install_path) {
CORE_PRINTER_DRIVER driver; base::win::Version version = base::win::GetVersion();
GetCorePrinterDrivers(NULL, if (version >= base::win::VERSION_VISTA) {
NULL, // GetCorePrinterDrivers and GetPrinterDriverPackagePath only exist on
L"{D20EA372-DD35-4950-9ED8-A6335AFE79F0}", // Vista and later. Winspool.drv must be delayloaded so these calls don't
1, // create problems on XP.
&driver); DWORD size = MAX_PATH;
DWORD size = MAX_PATH; wchar_t package_path[MAX_PATH] = {0};
wchar_t package_path[MAX_PATH]; CORE_PRINTER_DRIVER driver;
GetPrinterDriverPackagePath(NULL, GetCorePrinterDrivers(NULL,
NULL, NULL,
NULL, L"{D20EA372-DD35-4950-9ED8-A6335AFE79F0}",
driver.szPackageID, 1,
package_path, &driver);
MAX_PATH, GetPrinterDriverPackagePath(NULL,
&size); NULL,
NULL,
SetupIterateCabinet(package_path, driver.szPackageID,
0, package_path,
CabinetCallback, MAX_PATH,
const_cast<FilePath*>(&install_path)); &size);
SetupIterateCabinet(package_path,
0,
CabinetCallback,
const_cast<FilePath*>(&install_path));
} else {
// PS driver files are in the sp3 cab.
FilePath package_path;
PathService::Get(base::DIR_WINDOWS, &package_path);
package_path = package_path.Append(L"Driver Cache\\i386\\sp3.cab");
SetupIterateCabinet(package_path.value().c_str(),
0,
CabinetCallback,
const_cast<FilePath*>(&install_path));
// The XPS driver files are just sitting uncompressed in the driver cache.
FilePath xps_path;
PathService::Get(base::DIR_WINDOWS, &xps_path);
xps_path = xps_path.Append(L"Driver Cache\\i386");
xps_path = xps_path.Append(kDriverName);
file_util::CopyFile(xps_path, install_path.Append(kDriverName));
}
} }
HRESULT InstallPpd(const FilePath& install_path) { HRESULT InstallPpd(const FilePath& install_path) {
...@@ -383,10 +409,24 @@ void CleanupUninstall() { ...@@ -383,10 +409,24 @@ void CleanupUninstall() {
::RegDeleteKey(HKEY_LOCAL_MACHINE, kUninstallRegistry); ::RegDeleteKey(HKEY_LOCAL_MACHINE, kUninstallRegistry);
} }
bool IsOSSupported() {
// We don't support XP service pack 2 or older.
base::win::Version version = base::win::GetVersion();
return (version > base::win::VERSION_XP) ||
((version == base::win::VERSION_XP) &&
(base::win::OSInfo::GetInstance()->service_pack().major >= 3));
}
HRESULT InstallVirtualDriver(const FilePath& install_path) { HRESULT InstallVirtualDriver(const FilePath& install_path) {
HRESULT result = S_OK; HRESULT result = S_OK;
if (!IsOSSupported()) {
LOG(ERROR) << "Requires XP SP3 or later.";
return ERROR_OLD_WIN_VERSION;
}
if (!file_util::CreateDirectory(install_path)) { if (!file_util::CreateDirectory(install_path)) {
LOG(ERROR) << "Can't create install directory"; LOG(ERROR) << "Can't create install directory.";
return ERROR_ACCESS_DENIED; return ERROR_ACCESS_DENIED;
} }
SetupUninstall(install_path); SetupUninstall(install_path);
......
# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
...@@ -35,6 +35,9 @@ ...@@ -35,6 +35,9 @@
'AdditionalDependencies': [ 'AdditionalDependencies': [
'setupapi.lib', 'setupapi.lib',
], ],
'DelayLoadDLLs': [
'winspool.drv',
],
}, },
}, },
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment