Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8805)

Unified Diff: cloud_print/virtual_driver/win/install/setup.cc

Issue 9812030: Add support for XP SP3 in the Virtual Print Driver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | cloud_print/virtual_driver/win/install/virtual_driver_install.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cloud_print/virtual_driver/win/install/setup.cc
diff --git a/cloud_print/virtual_driver/win/install/setup.cc b/cloud_print/virtual_driver/win/install/setup.cc
index d64ea9aebfee918a12cde377a4dfd241e1c2a60e..262a3f74efbc281f9137feb2720dddbbb1053d96 100644
--- a/cloud_print/virtual_driver/win/install/setup.cc
+++ b/cloud_print/virtual_driver/win/install/setup.cc
@@ -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);
« no previous file with comments | « no previous file | cloud_print/virtual_driver/win/install/virtual_driver_install.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698