OLD | NEW |
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 // See the corresponding header file for description of the functions in this | 5 // See the corresponding header file for description of the functions in this |
6 // file. | 6 // file. |
7 | 7 |
8 #include "chrome/installer/util/install_util.h" | 8 #include "chrome/installer/util/install_util.h" |
9 | 9 |
10 #include <shellapi.h> | 10 #include <shellapi.h> |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 case installer::INSTALL_REPAIRED: | 349 case installer::INSTALL_REPAIRED: |
350 case installer::NEW_VERSION_UPDATED: | 350 case installer::NEW_VERSION_UPDATED: |
351 case installer::IN_USE_UPDATED: | 351 case installer::IN_USE_UPDATED: |
352 return 0; | 352 return 0; |
353 default: | 353 default: |
354 return status; | 354 return status; |
355 } | 355 } |
356 } | 356 } |
357 | 357 |
358 // static | 358 // static |
359 void InstallUtil::MakeUninstallCommand(const std::wstring& exe_path, | 359 void InstallUtil::MakeUninstallCommand(const std::wstring& program, |
360 const std::wstring& arguments, | 360 const std::wstring& arguments, |
361 CommandLine* command_line) { | 361 CommandLine* command_line) { |
362 const bool no_program = exe_path.empty(); | 362 *command_line = CommandLine::FromString(L"\"" + program + L"\" " + arguments); |
363 | |
364 // Return a bunch of nothingness. | |
365 if (no_program && arguments.empty()) { | |
366 *command_line = CommandLine(CommandLine::NO_PROGRAM); | |
367 } else { | |
368 // Form a full command line string. | |
369 std::wstring command; | |
370 command.append(1, L'"') | |
371 .append(no_program ? L"" : exe_path) | |
372 .append(L"\" ") | |
373 .append(arguments); | |
374 | |
375 // If we have a program name, return this complete command line. | |
376 *command_line = CommandLine::FromString(command); | |
377 } | |
378 } | 363 } |
379 | 364 |
380 std::wstring InstallUtil::GetCurrentDate() { | 365 std::wstring InstallUtil::GetCurrentDate() { |
381 static const wchar_t kDateFormat[] = L"yyyyMMdd"; | 366 static const wchar_t kDateFormat[] = L"yyyyMMdd"; |
382 wchar_t date_str[arraysize(kDateFormat)] = {0}; | 367 wchar_t date_str[arraysize(kDateFormat)] = {0}; |
383 int len = GetDateFormatW(LOCALE_INVARIANT, 0, NULL, kDateFormat, | 368 int len = GetDateFormatW(LOCALE_INVARIANT, 0, NULL, kDateFormat, |
384 date_str, arraysize(date_str)); | 369 date_str, arraysize(date_str)); |
385 if (len) { | 370 if (len) { |
386 --len; // Subtract terminating \0. | 371 --len; // Subtract terminating \0. |
387 } else { | 372 } else { |
388 PLOG(DFATAL) << "GetDateFormat"; | 373 PLOG(DFATAL) << "GetDateFormat"; |
389 } | 374 } |
390 | 375 |
391 return std::wstring(date_str, len); | 376 return std::wstring(date_str, len); |
392 } | 377 } |
OLD | NEW |