summaryrefslogtreecommitdiffstats
path: root/cloud_print
diff options
context:
space:
mode:
authorabodenha@chromium.org <abodenha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-22 18:24:04 +0000
committerabodenha@chromium.org <abodenha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-22 18:24:04 +0000
commitdb32d9068a099b55910d2d22707f20c5ae1958c8 (patch)
treeeb168f84e18d181ff49893386efcb80c4bf8a235 /cloud_print
parenta5a98a339cb43244f1ca9f7b22efdc9d9d876a5c (diff)
downloadchromium_src-db32d9068a099b55910d2d22707f20c5ae1958c8.zip
chromium_src-db32d9068a099b55910d2d22707f20c5ae1958c8.tar.gz
chromium_src-db32d9068a099b55910d2d22707f20c5ae1958c8.tar.bz2
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
Diffstat (limited to 'cloud_print')
-rw-r--r--cloud_print/virtual_driver/win/install/setup.cc86
-rw-r--r--cloud_print/virtual_driver/win/install/virtual_driver_install.gyp5
2 files changed, 67 insertions, 24 deletions
diff --git a/cloud_print/virtual_driver/win/install/setup.cc b/cloud_print/virtual_driver/win/install/setup.cc
index d64ea9a..021afee 100644
--- a/cloud_print/virtual_driver/win/install/setup.cc
+++ b/cloud_print/virtual_driver/win/install/setup.cc
@@ -1,4 +1,4 @@
-// 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
// found in the LICENSE file.
@@ -16,6 +16,7 @@
#include "base/string16.h"
#include "base/win/registry.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_helpers.h"
#include "grit/virtual_driver_setup_resources.h"
@@ -70,6 +71,7 @@ void DeleteOmahaKeys() {
if (key.Open(HKEY_LOCAL_MACHINE, cloud_print::kKeyLocation,
DELETE) != ERROR_SUCCESS) {
LOG(ERROR) << "Unable to open key to delete";
+ return;
}
if (key.DeleteKey(L"") != ERROR_SUCCESS) {
LOG(ERROR) << "Unable to delete key";
@@ -198,7 +200,10 @@ UINT CALLBACK CabinetCallback(PVOID data,
FILE_IN_CABINET_INFO* info =
reinterpret_cast<FILE_IN_CABINET_INFO*>(param1);
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,
temp_path->Append(kDependencyList[i]).value().c_str());
return FILEOP_DOIT;
@@ -211,26 +216,47 @@ UINT CALLBACK CabinetCallback(PVOID data,
}
void ReadyPpdDependencies(const FilePath& install_path) {
- CORE_PRINTER_DRIVER driver;
- GetCorePrinterDrivers(NULL,
- NULL,
- L"{D20EA372-DD35-4950-9ED8-A6335AFE79F0}",
- 1,
- &driver);
- DWORD size = MAX_PATH;
- wchar_t package_path[MAX_PATH];
- GetPrinterDriverPackagePath(NULL,
- NULL,
- NULL,
- driver.szPackageID,
- package_path,
- MAX_PATH,
- &size);
-
- SetupIterateCabinet(package_path,
- 0,
- CabinetCallback,
- const_cast<FilePath*>(&install_path));
+ base::win::Version version = base::win::GetVersion();
+ if (version >= base::win::VERSION_VISTA) {
+ // GetCorePrinterDrivers and GetPrinterDriverPackagePath only exist on
+ // Vista and later. Winspool.drv must be delayloaded so these calls don't
+ // create problems on XP.
+ DWORD size = MAX_PATH;
+ wchar_t package_path[MAX_PATH] = {0};
+ CORE_PRINTER_DRIVER driver;
+ GetCorePrinterDrivers(NULL,
+ NULL,
+ L"{D20EA372-DD35-4950-9ED8-A6335AFE79F0}",
+ 1,
+ &driver);
+ GetPrinterDriverPackagePath(NULL,
+ NULL,
+ NULL,
+ driver.szPackageID,
+ package_path,
+ MAX_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) {
@@ -383,10 +409,24 @@ void CleanupUninstall() {
::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 result = S_OK;
+
+ if (!IsOSSupported()) {
+ LOG(ERROR) << "Requires XP SP3 or later.";
+ return ERROR_OLD_WIN_VERSION;
+ }
+
if (!file_util::CreateDirectory(install_path)) {
- LOG(ERROR) << "Can't create install directory";
+ LOG(ERROR) << "Can't create install directory.";
return ERROR_ACCESS_DENIED;
}
SetupUninstall(install_path);
diff --git a/cloud_print/virtual_driver/win/install/virtual_driver_install.gyp b/cloud_print/virtual_driver/win/install/virtual_driver_install.gyp
index 696a4c6..7122639 100644
--- a/cloud_print/virtual_driver/win/install/virtual_driver_install.gyp
+++ b/cloud_print/virtual_driver/win/install/virtual_driver_install.gyp
@@ -1,4 +1,4 @@
-# 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
# found in the LICENSE file.
@@ -35,6 +35,9 @@
'AdditionalDependencies': [
'setupapi.lib',
],
+ 'DelayLoadDLLs': [
+ 'winspool.drv',
+ ],
},
},
},