summaryrefslogtreecommitdiffstats
path: root/cloud_print
diff options
context:
space:
mode:
authorvitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-02 23:02:44 +0000
committervitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-02 23:02:44 +0000
commit67d279ffb58fd4739a6e946c72c62422c6c17492 (patch)
tree4999ccec00df7c84e7af0cf5b3cf47316bf0003f /cloud_print
parent0cbb85c6a7ecf0e6c406e3d7762e8d16eb336e42 (diff)
downloadchromium_src-67d279ffb58fd4739a6e946c72c62422c6c17492.zip
chromium_src-67d279ffb58fd4739a6e946c72c62422c6c17492.tar.gz
chromium_src-67d279ffb58fd4739a6e946c72c62422c6c17492.tar.bz2
Set system error code for Google Update.
TBR=noamsml NOTRY=true Review URL: https://codereview.chromium.org/183803007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254422 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cloud_print')
-rw-r--r--cloud_print/common/win/install_utils.cc27
-rw-r--r--cloud_print/common/win/install_utils.h3
-rw-r--r--cloud_print/virtual_driver/win/install/setup.cc22
3 files changed, 42 insertions, 10 deletions
diff --git a/cloud_print/common/win/install_utils.cc b/cloud_print/common/win/install_utils.cc
index 38113ac..dd3d28b 100644
--- a/cloud_print/common/win/install_utils.cc
+++ b/cloud_print/common/win/install_utils.cc
@@ -13,6 +13,7 @@
#include "base/path_service.h"
#include "base/process/launch.h"
#include "base/win/registry.h"
+#include "cloud_print/common/win/cloud_print_utils.h"
namespace cloud_print {
@@ -24,9 +25,15 @@ const wchar_t kClientStateKey[] = L"SOFTWARE\\Google\\Update\\ClientState\\";
const wchar_t* kUsageKey = L"dr";
const wchar_t kVersionKey[] = L"pv";
const wchar_t kNameKey[] = L"name";
-const DWORD kInstallerResultFailedCustomError = 1;
+
+enum InstallerResult {
+ INSTALLER_RESULT_FAILED_CUSTOM_ERROR = 1,
+ INSTALLER_RESULT_FAILED_SYSTEM_ERROR = 3,
+};
+
const wchar_t kRegValueInstallerResult[] = L"InstallerResult";
const wchar_t kRegValueInstallerResultUIString[] = L"InstallerResultUIString";
+const wchar_t kRegValueInstallerError[] = L"InstallerError";
// Uninstall related constants.
const wchar_t kUninstallKey[] =
@@ -84,13 +91,29 @@ void SetGoogleUpdateError(const base::string16& product_id,
}
if (key.WriteValue(kRegValueInstallerResult,
- kInstallerResultFailedCustomError) != ERROR_SUCCESS ||
+ INSTALLER_RESULT_FAILED_CUSTOM_ERROR) != ERROR_SUCCESS ||
key.WriteValue(kRegValueInstallerResultUIString,
message.c_str()) != ERROR_SUCCESS) {
LOG(ERROR) << "Unable to set registry keys";
}
}
+void SetGoogleUpdateError(const base::string16& product_id, HRESULT hr) {
+ LOG(ERROR) << cloud_print::GetErrorMessage(hr);
+ base::win::RegKey key;
+ if (key.Create(HKEY_LOCAL_MACHINE,
+ (cloud_print::kClientStateKey + product_id).c_str(),
+ KEY_SET_VALUE) != ERROR_SUCCESS) {
+ LOG(ERROR) << "Unable to open key";
+ }
+
+ if (key.WriteValue(kRegValueInstallerResult,
+ INSTALLER_RESULT_FAILED_SYSTEM_ERROR) != ERROR_SUCCESS ||
+ key.WriteValue(kRegValueInstallerError, hr) != ERROR_SUCCESS) {
+ LOG(ERROR) << "Unable to set registry keys";
+ }
+}
+
void DeleteGoogleUpdateKeys(const base::string16& product_id) {
base::win::RegKey key;
if (key.Open(HKEY_LOCAL_MACHINE,
diff --git a/cloud_print/common/win/install_utils.h b/cloud_print/common/win/install_utils.h
index 541b4d9..5fa7951 100644
--- a/cloud_print/common/win/install_utils.h
+++ b/cloud_print/common/win/install_utils.h
@@ -21,6 +21,9 @@ void SetGoogleUpdateKeys(const base::string16& product_id,
void SetGoogleUpdateError(const base::string16& product_id,
const base::string16& message);
+// Sets custom system error code to show by Google Update installer
+void SetGoogleUpdateError(const base::string16& product_id, HRESULT hr);
+
// Deletes Google Update reg keys on product uninstall.
void DeleteGoogleUpdateKeys(const base::string16& product_id);
diff --git a/cloud_print/virtual_driver/win/install/setup.cc b/cloud_print/virtual_driver/win/install/setup.cc
index 2ac07ed..8613f3a 100644
--- a/cloud_print/virtual_driver/win/install/setup.cc
+++ b/cloud_print/virtual_driver/win/install/setup.cc
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <comdef.h>
#include <iomanip>
#include <windows.h>
#include <winspool.h>
@@ -271,8 +270,6 @@ HRESULT InstallDriver(const base::FilePath& install_path) {
base::FilePath ui_help_path = temp_path.path().Append(kHelpName);
if (!base::PathExists(xps_path)) {
- SetGoogleUpdateError(kGoogleUpdateProductId,
- LoadLocalString(IDS_ERROR_NO_XPS));
return HRESULT_FROM_WIN32(ERROR_BAD_DRIVER);
}
@@ -537,17 +534,26 @@ int WINAPI WinMain(__in HINSTANCE hInstance,
__in HINSTANCE hPrevInstance,
__in LPSTR lpCmdLine,
__in int nCmdShow) {
+ using namespace cloud_print;
+
base::AtExitManager at_exit_manager;
CommandLine::Init(0, NULL);
- HRESULT retval = cloud_print::ExecuteCommands();
- VLOG(0) << _com_error(retval).ErrorMessage() << " HRESULT=0x" <<
- std::setbase(16) << retval;
+ HRESULT retval = ExecuteCommands();
+
+ if (retval == HRESULT_FROM_WIN32(ERROR_BAD_DRIVER)) {
+ SetGoogleUpdateError(kGoogleUpdateProductId,
+ LoadLocalString(IDS_ERROR_NO_XPS));
+ } else if (FAILED(retval)) {
+ SetGoogleUpdateError(kGoogleUpdateProductId, retval);
+ }
+
+ VLOG(0) << GetErrorMessage(retval)
+ << " HRESULT=0x" << std::setbase(16) << retval;
// Installer is silent by default as required by Google Update.
if (CommandLine::ForCurrentProcess()->HasSwitch("verbose")) {
- cloud_print::DisplayWindowsMessage(NULL, retval,
- cloud_print::LoadLocalString(IDS_DRIVER_NAME));
+ DisplayWindowsMessage(NULL, retval, LoadLocalString(IDS_DRIVER_NAME));
}
return retval;
}