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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 return HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND); | 109 return HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND); |
110 } | 110 } |
111 if (install) { | 111 if (install) { |
112 base::FilePath source_path = | 112 base::FilePath source_path = |
113 install_path.Append(GetPortMonitorDllName()); | 113 install_path.Append(GetPortMonitorDllName()); |
114 if (!base::CopyFile(source_path, target_path)) { | 114 if (!base::CopyFile(source_path, target_path)) { |
115 LOG(ERROR) << "Unable copy port monitor dll from " << | 115 LOG(ERROR) << "Unable copy port monitor dll from " << |
116 source_path.value() << " to " << target_path.value(); | 116 source_path.value() << " to " << target_path.value(); |
117 return GetLastHResult(); | 117 return GetLastHResult(); |
118 } | 118 } |
119 } else if (!file_util::PathExists(target_path)) { | 119 } else if (!base::PathExists(target_path)) { |
120 // Already removed. Just "succeed" silently. | 120 // Already removed. Just "succeed" silently. |
121 return S_OK; | 121 return S_OK; |
122 } | 122 } |
123 | 123 |
124 base::FilePath regsvr32_path = GetNativeSystemPath(L"regsvr32.exe"); | 124 base::FilePath regsvr32_path = GetNativeSystemPath(L"regsvr32.exe"); |
125 if (regsvr32_path.empty()) { | 125 if (regsvr32_path.empty()) { |
126 LOG(ERROR) << "Can't find regsvr32.exe."; | 126 LOG(ERROR) << "Can't find regsvr32.exe."; |
127 return HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND); | 127 return HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND); |
128 } | 128 } |
129 | 129 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 &base::FilePath(destination)); |
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 (!file_util::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 (!file_util::PathExists(src_path)) | 242 if (!base::PathExists(src_path)) |
243 src_path = GetSystemPath(kDependencyList[i]); | 243 src_path = GetSystemPath(kDependencyList[i]); |
244 base::CopyFile(src_path, dst_path); | 244 base::CopyFile(src_path, dst_path); |
245 } | 245 } |
246 } | 246 } |
247 } | 247 } |
248 } | 248 } |
249 | 249 |
250 HRESULT InstallDriver(const base::FilePath& install_path) { | 250 HRESULT InstallDriver(const base::FilePath& install_path) { |
251 base::ScopedTempDir temp_path; | 251 base::ScopedTempDir temp_path; |
252 if (!temp_path.CreateUniqueTempDir()) | 252 if (!temp_path.CreateUniqueTempDir()) |
253 return HRESULT_FROM_WIN32(ERROR_CANNOT_MAKE); | 253 return HRESULT_FROM_WIN32(ERROR_CANNOT_MAKE); |
254 ReadyDriverDependencies(temp_path.path()); | 254 ReadyDriverDependencies(temp_path.path()); |
255 | 255 |
256 std::vector<string16> dependent_array; | 256 std::vector<string16> dependent_array; |
257 // Add all files. AddPrinterDriverEx will removes unnecessary. | 257 // Add all files. AddPrinterDriverEx will removes unnecessary. |
258 for (size_t i = 0; i < arraysize(kDependencyList); ++i) { | 258 for (size_t i = 0; i < arraysize(kDependencyList); ++i) { |
259 base::FilePath file_path = temp_path.path().Append(kDependencyList[i]); | 259 base::FilePath file_path = temp_path.path().Append(kDependencyList[i]); |
260 if (file_util::PathExists(file_path)) | 260 if (base::PathExists(file_path)) |
261 dependent_array.push_back(file_path.value()); | 261 dependent_array.push_back(file_path.value()); |
262 else | 262 else |
263 LOG(WARNING) << "File is missing: " << file_path.BaseName().value(); | 263 LOG(WARNING) << "File is missing: " << file_path.BaseName().value(); |
264 } | 264 } |
265 | 265 |
266 // Set up paths for the files we depend on. | 266 // Set up paths for the files we depend on. |
267 base::FilePath data_file = install_path.Append(kDataFileName); | 267 base::FilePath data_file = install_path.Append(kDataFileName); |
268 base::FilePath xps_path = temp_path.path().Append(kDriverName); | 268 base::FilePath xps_path = temp_path.path().Append(kDriverName); |
269 base::FilePath ui_path = temp_path.path().Append(kUiDriverName); | 269 base::FilePath ui_path = temp_path.path().Append(kUiDriverName); |
270 base::FilePath ui_help_path = temp_path.path().Append(kHelpName); | 270 base::FilePath ui_help_path = temp_path.path().Append(kHelpName); |
271 | 271 |
272 if (!file_util::PathExists(xps_path)) { | 272 if (!base::PathExists(xps_path)) { |
273 SetGoogleUpdateError(kGoogleUpdateProductId, | 273 SetGoogleUpdateError(kGoogleUpdateProductId, |
274 LoadLocalString(IDS_ERROR_NO_XPS)); | 274 LoadLocalString(IDS_ERROR_NO_XPS)); |
275 return HRESULT_FROM_WIN32(ERROR_BAD_DRIVER); | 275 return HRESULT_FROM_WIN32(ERROR_BAD_DRIVER); |
276 } | 276 } |
277 | 277 |
278 DRIVER_INFO_6 driver_info = {0}; | 278 DRIVER_INFO_6 driver_info = {0}; |
279 // Set up supported print system version. Must be 3. | 279 // Set up supported print system version. Must be 3. |
280 driver_info.cVersion = 3; | 280 driver_info.cVersion = 3; |
281 | 281 |
282 // None of the print API structures likes constant strings even though they | 282 // None of the print API structures likes constant strings even though they |
(...skipping 260 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 |