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

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

Issue 735053002: Prefix CommandLine usage with base namespace (Part 7: cloud_print/) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
OLDNEW
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 <windows.h> 5 #include <windows.h>
6 #include <setupapi.h> // Must be included after windows.h 6 #include <setupapi.h> // Must be included after windows.h
7 #include <winspool.h> 7 #include <winspool.h>
8 #include <iomanip> 8 #include <iomanip>
9 9
10 #include "base/at_exit.h" 10 #include "base/at_exit.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 LOG(ERROR) << "Unable to get windows path."; 81 LOG(ERROR) << "Unable to get windows path.";
82 return path; 82 return path;
83 } 83 }
84 return path.Append(L"sysnative").Append(binary); 84 return path.Append(L"sysnative").Append(binary);
85 } 85 }
86 86
87 void SpoolerServiceCommand(const char* command) { 87 void SpoolerServiceCommand(const char* command) {
88 base::FilePath net_path = GetNativeSystemPath(L"net"); 88 base::FilePath net_path = GetNativeSystemPath(L"net");
89 if (net_path.empty()) 89 if (net_path.empty())
90 return; 90 return;
91 CommandLine command_line(net_path); 91 base::CommandLine command_line(net_path);
92 command_line.AppendArg(command); 92 command_line.AppendArg(command);
93 command_line.AppendArg("spooler"); 93 command_line.AppendArg("spooler");
94 command_line.AppendArg("/y"); 94 command_line.AppendArg("/y");
95 95
96 base::LaunchOptions options; 96 base::LaunchOptions options;
97 options.wait = true; 97 options.wait = true;
98 options.start_hidden = true; 98 options.start_hidden = true;
99 VLOG(0) << command_line.GetCommandLineString(); 99 VLOG(0) << command_line.GetCommandLineString();
100 base::LaunchProcess(command_line, options, NULL); 100 base::LaunchProcess(command_line, options, NULL);
101 } 101 }
(...skipping 17 matching lines...) Expand all
119 // Already removed. Just "succeed" silently. 119 // Already removed. Just "succeed" silently.
120 return S_OK; 120 return S_OK;
121 } 121 }
122 122
123 base::FilePath regsvr32_path = GetNativeSystemPath(L"regsvr32.exe"); 123 base::FilePath regsvr32_path = GetNativeSystemPath(L"regsvr32.exe");
124 if (regsvr32_path.empty()) { 124 if (regsvr32_path.empty()) {
125 LOG(ERROR) << "Can't find regsvr32.exe."; 125 LOG(ERROR) << "Can't find regsvr32.exe.";
126 return HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND); 126 return HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND);
127 } 127 }
128 128
129 CommandLine command_line(regsvr32_path); 129 base::CommandLine command_line(regsvr32_path);
130 command_line.AppendArg("/s"); 130 command_line.AppendArg("/s");
131 if (!install) { 131 if (!install) {
132 command_line.AppendArg("/u"); 132 command_line.AppendArg("/u");
133 } 133 }
134 134
135 // Use system32 path here because otherwise ::AddMonitor would fail. 135 // Use system32 path here because otherwise ::AddMonitor would fail.
136 command_line.AppendArgPath(GetSystemPath(GetPortMonitorDllName())); 136 command_line.AppendArgPath(GetSystemPath(GetPortMonitorDllName()));
137 137
138 base::LaunchOptions options; 138 base::LaunchOptions options;
139 options.wait = true; 139 options.wait = true;
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 CreateUninstallKey(kUninstallId, LoadLocalString(IDS_DRIVER_NAME), 496 CreateUninstallKey(kUninstallId, LoadLocalString(IDS_DRIVER_NAME),
497 kUninstallSwitch); 497 kUninstallSwitch);
498 result = RegisterVirtualDriver(install_path); 498 result = RegisterVirtualDriver(install_path);
499 if (FAILED(result)) 499 if (FAILED(result))
500 return result; 500 return result;
501 SetGoogleUpdateKeys(kGoogleUpdateProductId, kNameValue); 501 SetGoogleUpdateKeys(kGoogleUpdateProductId, kNameValue);
502 return result; 502 return result;
503 } 503 }
504 504
505 HRESULT ExecuteCommands() { 505 HRESULT ExecuteCommands() {
506 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 506 const base::CommandLine& command_line =
507 *base::CommandLine::ForCurrentProcess();
507 508
508 base::FilePath exe_path; 509 base::FilePath exe_path;
509 if (FAILED(PathService::Get(base::DIR_EXE, &exe_path)) || 510 if (FAILED(PathService::Get(base::DIR_EXE, &exe_path)) ||
510 !base::DirectoryExists(exe_path)) { 511 !base::DirectoryExists(exe_path)) {
511 return HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND); 512 return HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND);
512 } 513 }
513 514
514 if (command_line.HasSwitch(kDelete)) { 515 if (command_line.HasSwitch(kDelete)) {
515 return DoDelete(command_line.GetSwitchValuePath(kDelete)); 516 return DoDelete(command_line.GetSwitchValuePath(kDelete));
516 } else if (command_line.HasSwitch(kUninstallSwitch)) { 517 } else if (command_line.HasSwitch(kUninstallSwitch)) {
(...skipping 13 matching lines...) Expand all
530 531
531 } // namespace cloud_print 532 } // namespace cloud_print
532 533
533 int WINAPI WinMain(__in HINSTANCE hInstance, 534 int WINAPI WinMain(__in HINSTANCE hInstance,
534 __in HINSTANCE hPrevInstance, 535 __in HINSTANCE hPrevInstance,
535 __in LPSTR lpCmdLine, 536 __in LPSTR lpCmdLine,
536 __in int nCmdShow) { 537 __in int nCmdShow) {
537 using namespace cloud_print; 538 using namespace cloud_print;
538 539
539 base::AtExitManager at_exit_manager; 540 base::AtExitManager at_exit_manager;
540 CommandLine::Init(0, NULL); 541 base::CommandLine::Init(0, NULL);
541 542
542 HRESULT retval = ExecuteCommands(); 543 HRESULT retval = ExecuteCommands();
543 544
544 if (retval == HRESULT_FROM_WIN32(ERROR_BAD_DRIVER)) { 545 if (retval == HRESULT_FROM_WIN32(ERROR_BAD_DRIVER)) {
545 SetGoogleUpdateError(kGoogleUpdateProductId, 546 SetGoogleUpdateError(kGoogleUpdateProductId,
546 LoadLocalString(IDS_ERROR_NO_XPS)); 547 LoadLocalString(IDS_ERROR_NO_XPS));
547 } else if (FAILED(retval)) { 548 } else if (FAILED(retval)) {
548 SetGoogleUpdateError(kGoogleUpdateProductId, retval); 549 SetGoogleUpdateError(kGoogleUpdateProductId, retval);
549 } 550 }
550 551
551 VLOG(0) << GetErrorMessage(retval) 552 VLOG(0) << GetErrorMessage(retval)
552 << " HRESULT=0x" << std::setbase(16) << retval; 553 << " HRESULT=0x" << std::setbase(16) << retval;
553 554
554 // Installer is silent by default as required by Google Update. 555 // Installer is silent by default as required by Google Update.
555 if (CommandLine::ForCurrentProcess()->HasSwitch("verbose")) { 556 if (base::CommandLine::ForCurrentProcess()->HasSwitch("verbose")) {
556 DisplayWindowsMessage(NULL, retval, LoadLocalString(IDS_DRIVER_NAME)); 557 DisplayWindowsMessage(NULL, retval, LoadLocalString(IDS_DRIVER_NAME));
557 } 558 }
558 return retval; 559 return retval;
559 } 560 }
OLDNEW
« no previous file with comments | « cloud_print/service/win/service_utils.cc ('k') | cloud_print/virtual_driver/win/port_monitor/port_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698