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

Side by Side Diff: cloud_print/virtual_driver/win/install/setup.cc

Issue 7465016: Installer for Windows cloud print driver changed to use PPD, PPd file added (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Code review nit fixed. Created 9 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cloud_print/virtual_driver/GCP-driver.ppd ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <windows.h> 5 #include <windows.h>
6 #include <winspool.h> 6 #include <winspool.h>
7 7
8 #include "base/at_exit.h" 8 #include "base/at_exit.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/file_version_info_win.h" 11 #include "base/file_version_info_win.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/process_util.h" 14 #include "base/process_util.h"
15 #include "base/string16.h" 15 #include "base/string16.h"
16 #include "base/win/scoped_handle.h" 16 #include "base/win/scoped_handle.h"
17 #include "cloud_print/virtual_driver/win/virtual_driver_consts.h" 17 #include "cloud_print/virtual_driver/win/virtual_driver_consts.h"
18 #include "cloud_print/virtual_driver/win/virtual_driver_helpers.h" 18 #include "cloud_print/virtual_driver/win/virtual_driver_helpers.h"
19 #include "grit/virtual_driver_setup_resources.h" 19 #include "grit/virtual_driver_setup_resources.h"
20 20
21 namespace { 21 namespace {
22 22
23 HRESULT GetGpdPath(FilePath* path) { 23 HRESULT GetPpdPath(FilePath* path) {
24 if (!PathService::Get(base::DIR_EXE, path)) { 24 if (!PathService::Get(base::DIR_EXE, path)) {
25 LOG(ERROR) << "Unable to get install path."; 25 LOG(ERROR) << "Unable to get install path.";
26 return ERROR_PATH_NOT_FOUND; 26 return ERROR_PATH_NOT_FOUND;
27 } 27 }
28 *path = path->Append(L"gcp.gpd"); 28 *path = path->Append(L"GCP-driver.ppd");
29 return S_OK; 29 return S_OK;
30 } 30 }
31 31
32 HRESULT GetPortMonitorDllPath(FilePath* path) { 32 HRESULT GetPortMonitorDllPath(FilePath* path) {
33 if (!PathService::Get(base::DIR_EXE, path)) { 33 if (!PathService::Get(base::DIR_EXE, path)) {
34 LOG(ERROR) << "Unable to get install path."; 34 LOG(ERROR) << "Unable to get install path.";
35 return ERROR_PATH_NOT_FOUND; 35 return ERROR_PATH_NOT_FOUND;
36 } 36 }
37 *path = path->Append(cloud_print::GetPortMonitorDllName()); 37 *path = path->Append(cloud_print::GetPortMonitorDllName());
38 return S_OK; 38 return S_OK;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 FileVersionInfoWin* version_info_win = 134 FileVersionInfoWin* version_info_win =
135 static_cast<FileVersionInfoWin*>(version_info.get()); 135 static_cast<FileVersionInfoWin*>(version_info.get());
136 VS_FIXEDFILEINFO* fixed_file_info = version_info_win->fixed_file_info(); 136 VS_FIXEDFILEINFO* fixed_file_info = version_info_win->fixed_file_info();
137 retval = fixed_file_info->dwFileVersionMS; 137 retval = fixed_file_info->dwFileVersionMS;
138 retval <<= 32; 138 retval <<= 32;
139 retval |= fixed_file_info->dwFileVersionMS; 139 retval |= fixed_file_info->dwFileVersionMS;
140 } 140 }
141 return retval; 141 return retval;
142 } 142 }
143 143
144 HRESULT InstallGpd() { 144 HRESULT InstallPpd() {
145 DRIVER_INFO_6 driver_info = {0}; 145 DRIVER_INFO_6 driver_info = {0};
146 HRESULT result = S_OK; 146 HRESULT result = S_OK;
147 147
148 // Set up paths for the files we depend on. 148 // Set up paths for the files we depend on.
149 FilePath source_path; 149 FilePath source_path;
150 FilePath driver_dir; 150 FilePath driver_dir;
151 cloud_print::GetPrinterDriverDir(&driver_dir); 151 cloud_print::GetPrinterDriverDir(&driver_dir);
152 FilePath xps_path = driver_dir.Append(L"mxdwdrv.dll"); 152 FilePath xps_path = driver_dir.Append(L"mxdwdrv.dll");
153 FilePath ui_path = driver_dir.Append(L"unidrvui.dll"); 153 FilePath ui_path = driver_dir.Append(L"ps5ui.dll");
154 FilePath ui_help_path = driver_dir.Append(L"unidrv.hlp"); 154 FilePath ui_help_path = driver_dir.Append(L"unidrv.hlp");
155 result = GetGpdPath(&source_path); 155 result = GetPpdPath(&source_path);
156 if (!SUCCEEDED(result)) { 156 if (!SUCCEEDED(result)) {
157 return result; 157 return result;
158 } 158 }
159 // None of the print API structures likes constant strings even though they 159 // None of the print API structures likes constant strings even though they
160 // don't modify the string. const_casting is the cleanest option. 160 // don't modify the string. const_casting is the cleanest option.
161 driver_info.pDataFile = const_cast<LPWSTR>(source_path.value().c_str()); 161 driver_info.pDataFile = const_cast<LPWSTR>(source_path.value().c_str());
162 driver_info.pHelpFile = const_cast<LPWSTR>(ui_help_path.value().c_str()); 162 driver_info.pHelpFile = const_cast<LPWSTR>(ui_help_path.value().c_str());
163 driver_info.pDriverPath = const_cast<LPWSTR>(xps_path.value().c_str()); 163 driver_info.pDriverPath = const_cast<LPWSTR>(xps_path.value().c_str());
164 driver_info.pConfigFile = const_cast<LPWSTR>(ui_path.value().c_str()); 164 driver_info.pConfigFile = const_cast<LPWSTR>(ui_path.value().c_str());
165 165
(...skipping 17 matching lines...) Expand all
183 6, 183 6,
184 reinterpret_cast<BYTE*>(&driver_info), 184 reinterpret_cast<BYTE*>(&driver_info),
185 APD_COPY_NEW_FILES|APD_COPY_FROM_DIRECTORY)) { 185 APD_COPY_NEW_FILES|APD_COPY_FROM_DIRECTORY)) {
186 result = cloud_print::GetLastHResult(); 186 result = cloud_print::GetLastHResult();
187 LOG(ERROR) << "Unable to add printer driver"; 187 LOG(ERROR) << "Unable to add printer driver";
188 return result; 188 return result;
189 } 189 }
190 return S_OK; 190 return S_OK;
191 } 191 }
192 192
193 HRESULT UninstallGpd() { 193 HRESULT UninstallPpd() {
194 int tries = 10; 194 int tries = 10;
195 string16 driver_name = cloud_print::LoadLocalString(IDS_DRIVER_NAME); 195 string16 driver_name = cloud_print::LoadLocalString(IDS_DRIVER_NAME);
196 while (!DeletePrinterDriverEx(NULL, 196 while (!DeletePrinterDriverEx(NULL,
197 NULL, 197 NULL,
198 const_cast<LPWSTR>(driver_name.c_str()), 198 const_cast<LPWSTR>(driver_name.c_str()),
199 DPD_DELETE_UNUSED_FILES, 199 DPD_DELETE_UNUSED_FILES,
200 0) && tries > 0) { 200 0) && tries > 0) {
201 if (GetLastError() == ERROR_UNKNOWN_PRINTER_DRIVER) { 201 if (GetLastError() == ERROR_UNKNOWN_PRINTER_DRIVER) {
202 LOG(WARNING) << "Print driver is already uninstalled."; 202 LOG(WARNING) << "Print driver is already uninstalled.";
203 return S_OK; 203 return S_OK;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 return S_OK; 261 return S_OK;
262 } 262 }
263 263
264 HRESULT InstallVirtualDriver(void) { 264 HRESULT InstallVirtualDriver(void) {
265 HRESULT result = S_OK; 265 HRESULT result = S_OK;
266 result = RegisterPortMonitor(true); 266 result = RegisterPortMonitor(true);
267 if (!SUCCEEDED(result)) { 267 if (!SUCCEEDED(result)) {
268 LOG(ERROR) << "Unable to register port monitor."; 268 LOG(ERROR) << "Unable to register port monitor.";
269 return result; 269 return result;
270 } 270 }
271 result = InstallGpd(); 271 result = InstallPpd();
272 if (!SUCCEEDED(result)) { 272 if (!SUCCEEDED(result)) {
273 LOG(ERROR) << "Unable to install gpd."; 273 LOG(ERROR) << "Unable to install Ppd.";
274 return result; 274 return result;
275 } 275 }
276 result = InstallPrinter(); 276 result = InstallPrinter();
277 if (!SUCCEEDED(result)) { 277 if (!SUCCEEDED(result)) {
278 LOG(ERROR) << "Unable to install printer."; 278 LOG(ERROR) << "Unable to install printer.";
279 return result; 279 return result;
280 } 280 }
281 return S_OK; 281 return S_OK;
282 } 282 }
283 283
284 HRESULT UninstallVirtualDriver(void) { 284 HRESULT UninstallVirtualDriver(void) {
285 HRESULT result = S_OK; 285 HRESULT result = S_OK;
286 result = UninstallPrinter(); 286 result = UninstallPrinter();
287 if (!SUCCEEDED(result)) { 287 if (!SUCCEEDED(result)) {
288 LOG(ERROR) << "Unable to uninstall gpd."; 288 LOG(ERROR) << "Unable to uninstall Ppd.";
289 return result; 289 return result;
290 } 290 }
291 result = UninstallGpd(); 291 result = UninstallPpd();
292 if (!SUCCEEDED(result)) { 292 if (!SUCCEEDED(result)) {
293 LOG(ERROR) << "Unable to remove gpd."; 293 LOG(ERROR) << "Unable to remove Ppd.";
294 return result; 294 return result;
295 } 295 }
296 result = RegisterPortMonitor(false); 296 result = RegisterPortMonitor(false);
297 if (!SUCCEEDED(result)) { 297 if (!SUCCEEDED(result)) {
298 LOG(ERROR) << "Unable to remove port monitor."; 298 LOG(ERROR) << "Unable to remove port monitor.";
299 return result; 299 return result;
300 } 300 }
301 return S_OK; 301 return S_OK;
302 } 302 }
303 303
(...skipping 11 matching lines...) Expand all
315 } else { 315 } else {
316 retval = InstallVirtualDriver(); 316 retval = InstallVirtualDriver();
317 } 317 }
318 if (!CommandLine::ForCurrentProcess()->HasSwitch("silent")) { 318 if (!CommandLine::ForCurrentProcess()->HasSwitch("silent")) {
319 cloud_print::DisplayWindowsMessage(NULL, retval, 319 cloud_print::DisplayWindowsMessage(NULL, retval,
320 cloud_print::LoadLocalString(IDS_DRIVER_NAME)); 320 cloud_print::LoadLocalString(IDS_DRIVER_NAME));
321 } 321 }
322 return retval; 322 return retval;
323 } 323 }
324 324
OLDNEW
« no previous file with comments | « cloud_print/virtual_driver/GCP-driver.ppd ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698