Moved Google Update and install related code to cloud_print/common

R=gene

Review URL: https://chromiumcodereview.appspot.com/14107007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194799 0039d316-1c4b-4281-b951-d872f2087c98
parent af20e897
......@@ -105,5 +105,16 @@
},
},
},
{
'target_name': 'cloud_print_install_lib',
'type': 'static_library',
'dependencies': [
'<(DEPTH)/base/base.gyp:base',
],
'sources': [
'<(DEPTH)/cloud_print/common/win/install_utils.cc',
'<(DEPTH)/cloud_print/common/win/install_utils.h',
],
},
],
}
......@@ -6,8 +6,18 @@
#include <windows.h>
#include "base/win/registry.h"
namespace cloud_print {
namespace {
// Google Update related constants.
const wchar_t kClientStateKey[] = L"SOFTWARE\\Google\\Update\\ClientState\\";
const wchar_t* kUsageKey = L"dr";
} // namespace
HRESULT GetLastHResult() {
DWORD error_code = GetLastError();
return error_code ? HRESULT_FROM_WIN32(error_code) : E_FAIL;
......@@ -37,4 +47,15 @@ string16 GetErrorMessage(HRESULT hr) {
return result;
}
void SetGoogleUpdateUsage(const string16& product_id) {
// Set appropriate key to 1 to let Omaha record usage.
base::win::RegKey key;
if (key.Create(HKEY_CURRENT_USER,
(kClientStateKey + product_id).c_str(),
KEY_SET_VALUE) != ERROR_SUCCESS ||
key.WriteValue(kUsageKey, L"1") != ERROR_SUCCESS) {
LOG(ERROR) << "Unable to set usage key";
}
}
} // namespace cloud_print
......@@ -21,6 +21,9 @@ string16 GetErrorMessage(HRESULT hr);
// calling code.
string16 LoadLocalString(DWORD id);
// Sets registry value to notify Google Update that product was used.
void SetGoogleUpdateUsage(const string16& product_id);
} // namespace cloud_print
#endif // CLOUD_PRINT_COMMON_CLOUD_PRINT_UTILS_H_
......
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cloud_print/common/win/install_utils.h"
#include <windows.h>
#include "base/command_line.h"
#include "base/file_version_info_win.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/win/registry.h"
namespace cloud_print {
namespace {
// Google Update related constants.
const wchar_t kClientsKey[] = L"SOFTWARE\\Google\\Update\\Clients\\";
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;
const wchar_t kRegValueInstallerResult[] = L"InstallerResult";
const wchar_t kRegValueInstallerResultUIString[] = L"InstallerResultUIString";
// Uninstall related constants.
const wchar_t kUninstallKey[] =
L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\";
const wchar_t kInstallLocation[] = L"InstallLocation";
const wchar_t kDisplayVersion[] = L"DisplayVersion";
const wchar_t kDisplayName[] = L"DisplayName";
const wchar_t kPublisher[] = L"Publisher";
const wchar_t kNoModify[] = L"NoModify";
const wchar_t kNoRepair[] = L"NoRepair";
} // namespace
void SetGoogleUpdateKeys(const string16& product_id,
const string16& product_name) {
base::win::RegKey key;
if (key.Create(HKEY_LOCAL_MACHINE,
(cloud_print::kClientsKey + product_id).c_str(),
KEY_SET_VALUE) != ERROR_SUCCESS) {
LOG(ERROR) << "Unable to open key";
}
// Get the version from the resource file.
string16 version_string;
scoped_ptr<FileVersionInfo> version_info(
FileVersionInfo::CreateFileVersionInfoForCurrentModule());
if (version_info.get()) {
FileVersionInfoWin* version_info_win =
static_cast<FileVersionInfoWin*>(version_info.get());
version_string = version_info_win->product_version();
} else {
LOG(ERROR) << "Unable to get version string";
// Use a random version string so that Google Update has something to go by.
version_string = L"0.0.0.99";
}
if (key.WriteValue(kVersionKey, version_string.c_str()) != ERROR_SUCCESS ||
key.WriteValue(kNameKey, product_name.c_str()) != ERROR_SUCCESS) {
LOG(ERROR) << "Unable to set registry keys";
}
}
void SetGoogleUpdateError(const string16& product_id, const string16& message) {
LOG(ERROR) << message;
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,
kInstallerResultFailedCustomError) != ERROR_SUCCESS ||
key.WriteValue(kRegValueInstallerResultUIString,
message.c_str()) != ERROR_SUCCESS) {
LOG(ERROR) << "Unable to set registry keys";
}
}
void DeleteGoogleUpdateKeys(const string16& product_id) {
base::win::RegKey key;
if (key.Open(HKEY_LOCAL_MACHINE,
(cloud_print::kClientsKey + product_id).c_str(),
DELETE) != ERROR_SUCCESS) {
LOG(ERROR) << "Unable to open key to delete";
return;
}
if (key.DeleteKey(L"") != ERROR_SUCCESS) {
LOG(ERROR) << "Unable to delete key";
}
}
void CreateUninstallKey(const string16& uninstall_id,
const string16& product_name,
const std::string& uninstall_switch) {
// Now write the Windows Uninstall entries
// Minimal error checking here since the install can continue
// if this fails.
base::win::RegKey key;
if (key.Create(HKEY_LOCAL_MACHINE,
(cloud_print::kUninstallKey + uninstall_id).c_str(),
KEY_SET_VALUE) != ERROR_SUCCESS) {
LOG(ERROR) << "Unable to open key";
return;
}
base::FilePath unstall_binary;
CHECK(PathService::Get(base::FILE_EXE, &unstall_binary));
CommandLine uninstall_command(unstall_binary);
uninstall_command.AppendSwitch(uninstall_switch);
key.WriteValue(kUninstallKey,
uninstall_command.GetCommandLineString().c_str());
key.WriteValue(kInstallLocation,
unstall_binary.DirName().value().c_str());
// Get the version resource.
scoped_ptr<FileVersionInfo> version_info(
FileVersionInfo::CreateFileVersionInfoForCurrentModule());
if (version_info.get()) {
FileVersionInfoWin* version_info_win =
static_cast<FileVersionInfoWin*>(version_info.get());
key.WriteValue(kDisplayVersion,
version_info_win->file_version().c_str());
key.WriteValue(kPublisher, version_info_win->company_name().c_str());
} else {
LOG(ERROR) << "Unable to get version string";
}
key.WriteValue(kDisplayName, product_name.c_str());
key.WriteValue(kNoModify, 1);
key.WriteValue(kNoRepair, 1);
}
void DeleteUninstallKey(const string16& uninstall_id) {
::RegDeleteKey(HKEY_LOCAL_MACHINE,
(cloud_print::kUninstallKey + uninstall_id).c_str());
}
base::FilePath GetInstallLocation(const string16& uninstall_id) {
base::win::RegKey key;
if (key.Open(HKEY_LOCAL_MACHINE,
(cloud_print::kUninstallKey + uninstall_id).c_str(),
KEY_QUERY_VALUE) != ERROR_SUCCESS) {
// Not installed.
return base::FilePath();
}
string16 install_path_value;
key.ReadValue(kInstallLocation, &install_path_value);
return base::FilePath(install_path_value);
}
} // namespace cloud_print
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CLOUD_PRINT_COMMON_INSTALL_UTILS_H_
#define CLOUD_PRINT_COMMON_INSTALL_UTILS_H_
#include <wtypes.h>
#include <string>
#include "base/files/file_path.h"
#include "base/string16.h"
namespace cloud_print {
// Sets Google Update registry keys after install or update.
void SetGoogleUpdateKeys(const string16& product_id,
const string16& product_name);
// Sets custom error message to show by Google Update installer
void SetGoogleUpdateError(const string16& product_id, const string16& message);
// Deletes Google Update reg keys on product uninstall.
void DeleteGoogleUpdateKeys(const string16& product_id);
// Creates control panel uninstall item.
void CreateUninstallKey(const string16& uninstall_id,
const string16& product_name,
const std::string& uninstall_switch);
// Deletes control panel uninstall item.
void DeleteUninstallKey(const string16& uninstall_id);
// Returns install location retrieved from control panel uninstall key.
base::FilePath GetInstallLocation(const string16& uninstall_id);
} // namespace cloud_print
#endif // CLOUD_PRINT_COMMON_INSTALL_UTILS_H_
......@@ -23,6 +23,7 @@
#include "base/win/scoped_handle.h"
#include "base/win/windows_version.h"
#include "cloud_print/common/win/cloud_print_utils.h"
#include "cloud_print/common/win/install_utils.h"
#include "cloud_print/virtual_driver/win/virtual_driver_consts.h"
#include "cloud_print/virtual_driver/win/virtual_driver_helpers.h"
#include "grit/virtual_driver_setup_resources.h"
......@@ -30,12 +31,12 @@
#include <strsafe.h> // Must be after base headers to avoid deprecation
// warnings.
namespace cloud_print {
namespace {
const wchar_t kNameValue[] = L"GCP Virtual Driver";
const wchar_t kUninstallRegistry[] =
L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"
L"{74AA24E0-AC50-4B28-BA46-9CF05467C9B7}";
const wchar_t kUninstallId[] = L"{74AA24E0-AC50-4B28-BA46-9CF05467C9B7}";
const wchar_t kInstallerName[] = L"virtual_driver_setup.exe";
const wchar_t kGcpUrl[] = L"http://www.google.com/cloudprint";
......@@ -62,69 +63,6 @@ const char kRegisterSwitch[] = "register";
const char kUninstallSwitch[] = "uninstall";
const char kUnregisterSwitch[] = "unregister";
// Google update related constants.
const wchar_t kVersionKey[] = L"pv";
const wchar_t kNameKey[] = L"name";
const DWORD kInstallerResultFailedCustomError = 1;
const wchar_t kRegValueInstallerResult[] = L"InstallerResult";
const wchar_t kRegValueInstallerResultUIString[] = L"InstallerResultUIString";
void SetGoogleUpdateKeys() {
base::win::RegKey key;
if (key.Create(HKEY_LOCAL_MACHINE, cloud_print::kGoogleUpdateClientsKey,
KEY_SET_VALUE) != ERROR_SUCCESS) {
LOG(ERROR) << "Unable to open key";
}
// Get the version from the resource file.
string16 version_string;
scoped_ptr<FileVersionInfo> version_info(
FileVersionInfo::CreateFileVersionInfoForCurrentModule());
if (version_info.get()) {
FileVersionInfoWin* version_info_win =
static_cast<FileVersionInfoWin*>(version_info.get());
version_string = version_info_win->product_version();
} else {
LOG(ERROR) << "Unable to get version string";
// Use a random version string so that Google Update has something to go by.
version_string = L"0.0.0.99";
}
if (key.WriteValue(kVersionKey, version_string.c_str()) != ERROR_SUCCESS ||
key.WriteValue(kNameKey, kNameValue) != ERROR_SUCCESS) {
LOG(ERROR) << "Unable to set registry keys";
}
}
void SetGoogleUpdateError(const string16& message) {
LOG(ERROR) << message;
base::win::RegKey key;
if (key.Create(HKEY_LOCAL_MACHINE, cloud_print::kGoogleUpdateClientStateKey,
KEY_SET_VALUE) != ERROR_SUCCESS) {
LOG(ERROR) << "Unable to open key";
}
if (key.WriteValue(kRegValueInstallerResult,
kInstallerResultFailedCustomError) != ERROR_SUCCESS ||
key.WriteValue(kRegValueInstallerResultUIString,
message.c_str()) != ERROR_SUCCESS) {
LOG(ERROR) << "Unable to set registry keys";
}
}
void DeleteGoogleUpdateKeys() {
base::win::RegKey key;
if (key.Open(HKEY_LOCAL_MACHINE, cloud_print::kGoogleUpdateClientsKey,
DELETE) != ERROR_SUCCESS) {
LOG(ERROR) << "Unable to open key to delete";
return;
}
if (key.DeleteKey(L"") != ERROR_SUCCESS) {
LOG(ERROR) << "Unable to delete key";
}
}
base::FilePath GetSystemPath(const string16& binary) {
base::FilePath path;
if (!PathService::Get(base::DIR_SYSTEM, &path)) {
......@@ -135,7 +73,7 @@ base::FilePath GetSystemPath(const string16& binary) {
}
base::FilePath GetNativeSystemPath(const string16& binary) {
if (!cloud_print::IsSystem64Bit())
if (!IsSystem64Bit())
return GetSystemPath(binary);
base::FilePath path;
// Sysnative will bypass filesystem redirection and give us
......@@ -165,19 +103,18 @@ void SpoolerServiceCommand(const char* command) {
HRESULT RegisterPortMonitor(bool install, const base::FilePath& install_path) {
DCHECK(install || install_path.empty());
base::FilePath target_path =
GetNativeSystemPath(cloud_print::GetPortMonitorDllName());
base::FilePath target_path = GetNativeSystemPath(GetPortMonitorDllName());
if (target_path.empty()) {
LOG(ERROR) << "Unable to get port monitor target path.";
return HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND);
}
if (install) {
base::FilePath source_path =
install_path.Append(cloud_print::GetPortMonitorDllName());
install_path.Append(GetPortMonitorDllName());
if (!file_util::CopyFile(source_path, target_path)) {
LOG(ERROR) << "Unable copy port monitor dll from " <<
source_path.value() << " to " << target_path.value();
return cloud_print::GetLastHResult();
return GetLastHResult();
}
} else if (!file_util::PathExists(target_path)) {
// Already removed. Just "succeed" silently.
......@@ -197,8 +134,7 @@ HRESULT RegisterPortMonitor(bool install, const base::FilePath& install_path) {
}
// Use system32 path here because otherwise ::AddMonitor would fail.
command_line.AppendArgPath(GetSystemPath(
cloud_print::GetPortMonitorDllName()));
command_line.AppendArgPath(GetSystemPath(GetPortMonitorDllName()));
base::LaunchOptions options;
options.wait = true;
......@@ -213,7 +149,7 @@ HRESULT RegisterPortMonitor(bool install, const base::FilePath& install_path) {
if (install) {
if (!GetExitCodeProcess(regsvr32_handle, &exit_code)) {
LOG(ERROR) << "Unable to get regsvr32.exe exit code.";
return cloud_print::GetLastHResult();
return GetLastHResult();
}
if (exit_code != 0) {
LOG(ERROR) << "Regsvr32.exe failed with " << exit_code;
......@@ -334,7 +270,8 @@ HRESULT InstallDriver(const base::FilePath& install_path) {
base::FilePath ui_help_path = temp_path.path().Append(kHelpName);
if (!file_util::PathExists(xps_path)) {
SetGoogleUpdateError(cloud_print::LoadLocalString(IDS_ERROR_NO_XPS));
SetGoogleUpdateError(kGoogleUpdateProductId,
LoadLocalString(IDS_ERROR_NO_XPS));
return HRESULT_FROM_WIN32(ERROR_BAD_DRIVER);
}
......@@ -355,25 +292,25 @@ HRESULT InstallDriver(const base::FilePath& install_path) {
driver_info.pDependentFiles = &dependent_files[0];
// Set up user visible strings.
string16 manufacturer = cloud_print::LoadLocalString(IDS_GOOGLE);
string16 manufacturer = LoadLocalString(IDS_GOOGLE);
driver_info.pszMfgName = const_cast<LPWSTR>(manufacturer.c_str());
driver_info.pszProvider = const_cast<LPWSTR>(manufacturer.c_str());
driver_info.pszOEMUrl = const_cast<LPWSTR>(kGcpUrl);
driver_info.dwlDriverVersion = GetVersionNumber();
string16 driver_name = cloud_print::LoadLocalString(IDS_DRIVER_NAME);
string16 driver_name = LoadLocalString(IDS_DRIVER_NAME);
driver_info.pName = const_cast<LPWSTR>(driver_name.c_str());
if (!::AddPrinterDriverEx(NULL, 6, reinterpret_cast<BYTE*>(&driver_info),
APD_COPY_NEW_FILES | APD_COPY_FROM_DIRECTORY)) {
LOG(ERROR) << "Unable to add printer driver";
return cloud_print::GetLastHResult();
return GetLastHResult();
}
return S_OK;
}
HRESULT UninstallDriver() {
int tries = 3;
string16 driver_name = cloud_print::LoadLocalString(IDS_DRIVER_NAME);
string16 driver_name = LoadLocalString(IDS_DRIVER_NAME);
while (!DeletePrinterDriverEx(NULL,
NULL,
const_cast<LPWSTR>(driver_name.c_str()),
......@@ -390,7 +327,7 @@ HRESULT UninstallDriver() {
Sleep(2000);
}
if (tries <= 0) {
HRESULT result = cloud_print::GetLastHResult();
HRESULT result = GetLastHResult();
LOG(ERROR) << "Unable to delete printer driver.";
return result;
}
......@@ -402,18 +339,18 @@ HRESULT InstallPrinter(void) {
// None of the print API structures likes constant strings even though they
// don't modify the string. const_casting is the cleanest option.
string16 driver_name = cloud_print::LoadLocalString(IDS_DRIVER_NAME);
string16 driver_name = LoadLocalString(IDS_DRIVER_NAME);
printer_info.pDriverName = const_cast<LPWSTR>(driver_name.c_str());
printer_info.pPrinterName = const_cast<LPWSTR>(driver_name.c_str());
printer_info.pComment = const_cast<LPWSTR>(driver_name.c_str());
printer_info.pLocation = const_cast<LPWSTR>(kGcpUrl);
string16 port_name;
printer_info.pPortName = const_cast<LPWSTR>(cloud_print::kPortName);
printer_info.pPortName = const_cast<LPWSTR>(kPortName);
printer_info.Attributes = PRINTER_ATTRIBUTE_DIRECT|PRINTER_ATTRIBUTE_LOCAL;
printer_info.pPrintProcessor = L"winprint";
HANDLE handle = AddPrinter(NULL, 2, reinterpret_cast<BYTE*>(&printer_info));
if (handle == NULL) {
HRESULT result = cloud_print::GetLastHResult();
HRESULT result = GetLastHResult();
LOG(ERROR) << "Unable to add printer";
return result;
}
......@@ -425,7 +362,7 @@ HRESULT UninstallPrinter(void) {
HANDLE handle = NULL;
PRINTER_DEFAULTS printer_defaults = {0};
printer_defaults.DesiredAccess = PRINTER_ALL_ACCESS;
string16 driver_name = cloud_print::LoadLocalString(IDS_DRIVER_NAME);
string16 driver_name = LoadLocalString(IDS_DRIVER_NAME);
if (!OpenPrinter(const_cast<LPWSTR>(driver_name.c_str()),
&handle,
&printer_defaults)) {
......@@ -434,7 +371,7 @@ HRESULT UninstallPrinter(void) {
return S_OK;
}
if (!DeletePrinter(handle)) {
HRESULT result = cloud_print::GetLastHResult();
HRESULT result = GetLastHResult();
LOG(ERROR) << "Unable to delete printer";
ClosePrinter(handle);
return result;
......@@ -443,46 +380,6 @@ HRESULT UninstallPrinter(void) {
return S_OK;
}
void SetupUninstall(const base::FilePath& install_path) {
// Now write the Windows Uninstall entries
// Minimal error checking here since the install can contiunue
// if this fails.
base::win::RegKey key;
if (key.Create(HKEY_LOCAL_MACHINE, kUninstallRegistry,
KEY_SET_VALUE) != ERROR_SUCCESS) {
LOG(ERROR) << "Unable to open key";
return;
}
CommandLine uninstall_command(install_path.Append(kInstallerName));
uninstall_command.AppendArg("--uninstall");
key.WriteValue(L"UninstallString",
uninstall_command.GetCommandLineString().c_str());
key.WriteValue(L"InstallLocation", install_path.value().c_str());
// Get the version resource.
scoped_ptr<FileVersionInfo> version_info(
FileVersionInfo::CreateFileVersionInfoForCurrentModule());
if (version_info.get()) {
FileVersionInfoWin* version_info_win =
static_cast<FileVersionInfoWin*>(version_info.get());
key.WriteValue(L"DisplayVersion",
version_info_win->file_version().c_str());
key.WriteValue(L"Publisher", version_info_win->company_name().c_str());
} else {
LOG(ERROR) << "Unable to get version string";
}
key.WriteValue(L"DisplayName",
cloud_print::LoadLocalString(IDS_DRIVER_NAME).c_str());
key.WriteValue(L"NoModify", 1);
key.WriteValue(L"NoRepair", 1);
}
void CleanupUninstall() {
::RegDeleteKey(HKEY_LOCAL_MACHINE, kUninstallRegistry);
}
bool IsOSSupported() {
// We don't support XP service pack 2 or older.
base::win::Version version = base::win::GetVersion();
......@@ -521,19 +418,6 @@ HRESULT RegisterVirtualDriver(const base::FilePath& install_path) {
return S_OK;
}
void GetCurrentInstallPath(base::FilePath* install_path) {
base::win::RegKey key;
if (key.Open(HKEY_LOCAL_MACHINE, kUninstallRegistry,
KEY_QUERY_VALUE) != ERROR_SUCCESS) {
// Not installed.
*install_path = base::FilePath();
return;
}
string16 install_path_value;
key.ReadValue(L"InstallLocation", &install_path_value);
*install_path = base::FilePath(install_path_value);
}
HRESULT TryUnregisterVirtualDriver() {
HRESULT result = S_OK;
result = UninstallPrinter();
......@@ -599,11 +483,11 @@ HRESULT DeleteProgramDir(const base::FilePath& installer_source, bool wait) {
}
HRESULT DoUninstall() {
DeleteGoogleUpdateKeys();
DeleteGoogleUpdateKeys(kGoogleUpdateProductId);
HRESULT result = UnregisterVirtualDriver();
if (FAILED(result))
return result;
CleanupUninstall();
DeleteUninstallKey(kUninstallId);
base::FilePath installer_source;
if (PathService::Get(base::FILE_EXE, &installer_source))
return DeleteProgramDir(installer_source, false);
......@@ -636,18 +520,18 @@ HRESULT DoInstall(const base::FilePath& install_path) {
LOG(ERROR) << "Unable to unregister.";
return result;
}
base::FilePath old_install_path;
GetCurrentInstallPath(&old_install_path);
base::FilePath old_install_path = GetInstallLocation(kUninstallId);
if (!old_install_path.value().empty() &&
install_path != old_install_path) {
if (file_util::DirectoryExists(old_install_path))
file_util::Delete(old_install_path, true);
}
SetupUninstall(install_path);
CreateUninstallKey(kUninstallId, LoadLocalString(IDS_DRIVER_NAME),
kUninstallSwitch);
result = RegisterVirtualDriver(install_path);
if (FAILED(result))
return result;
SetGoogleUpdateKeys();
SetGoogleUpdateKeys(kGoogleUpdateProductId, kNameValue);
return result;
}
......@@ -677,13 +561,15 @@ HRESULT ExecuteCommands() {
} // namespace
} // namespace cloud_print
int WINAPI WinMain(__in HINSTANCE hInstance,
__in HINSTANCE hPrevInstance,
__in LPSTR lpCmdLine,
__in int nCmdShow) {
__in HINSTANCE hPrevInstance,
__in LPSTR lpCmdLine,
__in int nCmdShow) {
base::AtExitManager at_exit_manager;
CommandLine::Init(0, NULL);
HRESULT retval = ExecuteCommands();
HRESULT retval = cloud_print::ExecuteCommands();
LOG(INFO) << _com_error(retval).ErrorMessage() << " HRESULT=0x" <<
std::setbase(16) << retval;
......
......@@ -22,6 +22,7 @@
'dependencies': [
'../virtual_driver.gyp:virtual_driver_lib',
'<(DEPTH)/base/base.gyp:base',
'<(DEPTH)/cloud_print/cloud_print.gyp:cloud_print_install_lib',
'<(DEPTH)/cloud_print/cloud_print.gyp:cloud_print_version_resources',
'virtual_driver_setup_resources',
],
......
......@@ -25,6 +25,7 @@
#include "base/win/windows_version.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/installer/launcher_support/chrome_launcher_support.h"
#include "cloud_print/common/win/cloud_print_utils.h"
#include "cloud_print/virtual_driver/win/port_monitor/spooler_win.h"
#include "cloud_print/virtual_driver/win/virtual_driver_consts.h"
#include "cloud_print/virtual_driver/win/virtual_driver_helpers.h"
......@@ -405,14 +406,7 @@ BOOL WINAPI Monitor2StartDocPort(HANDLE port_handle,
DWORD job_id,
DWORD,
BYTE*) {
const wchar_t* kUsageKey = L"dr";
// Set appropriate key to 1 to let Omaha record usage.
base::win::RegKey key;
if (key.Create(HKEY_CURRENT_USER, kGoogleUpdateClientStateKey,
KEY_SET_VALUE) != ERROR_SUCCESS ||
key.WriteValue(kUsageKey, L"1") != ERROR_SUCCESS) {
LOG(ERROR) << "Unable to set usage key";
}
SetGoogleUpdateUsage(kGoogleUpdateProductId);
if (port_handle == NULL) {
LOG(ERROR) << "port_handle should not be NULL.";
SetLastError(ERROR_INVALID_PARAMETER);
......
......@@ -10,10 +10,8 @@ namespace cloud_print {
const wchar_t kPortName[] = L"GCP:";
const size_t kPortNameSize = sizeof(kPortName);
const wchar_t kGoogleUpdateClientsKey[] = L"SOFTWARE\\Google\\Update\\"
L"Clients\\{9B13FA92-1F73-4761-AB78-2C6ADAC3660D}";
const wchar_t kGoogleUpdateClientStateKey[] = L"SOFTWARE\\Google\\Update\\"
L"ClientState\\{9B13FA92-1F73-4761-AB78-2C6ADAC3660D}";
const wchar_t kGoogleUpdateProductId[] =
L"{9B13FA92-1F73-4761-AB78-2C6ADAC3660D}";
} // namespace cloud_print
......@@ -9,8 +9,7 @@ namespace cloud_print {
extern const wchar_t kPortName[];
extern const size_t kPortNameSize;
extern const wchar_t kGoogleUpdateClientsKey[];
extern const wchar_t kGoogleUpdateClientStateKey[];
extern const wchar_t kGoogleUpdateProductId[];
} // namespace cloud_print
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment