diff options
author | abeera@google.com <abeera@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-19 05:46:06 +0000 |
---|---|---|
committer | abeera@google.com <abeera@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-19 05:46:06 +0000 |
commit | e1600c3e418ce7c4ab13a35394b0093717808da1 (patch) | |
tree | d05bd90aef99ffa49d1698368b83e3a1f8a533c0 /cloud_print | |
parent | a3057bdf8dd0d30c9fedb6457ca8adc0c12104cd (diff) | |
download | chromium_src-e1600c3e418ce7c4ab13a35394b0093717808da1.zip chromium_src-e1600c3e418ce7c4ab13a35394b0093717808da1.tar.gz chromium_src-e1600c3e418ce7c4ab13a35394b0093717808da1.tar.bz2 |
Changes to write various registry keys as required by Omaha for Windows Cloud Print Virtual Driver.
BUG=
TEST=
Review URL: http://codereview.chromium.org/7532031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97434 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cloud_print')
4 files changed, 64 insertions, 1 deletions
diff --git a/cloud_print/virtual_driver/win/install/setup.cc b/cloud_print/virtual_driver/win/install/setup.cc index 3497481..1b83cbb 100644 --- a/cloud_print/virtual_driver/win/install/setup.cc +++ b/cloud_print/virtual_driver/win/install/setup.cc @@ -13,12 +13,58 @@ #include "base/path_service.h" #include "base/process_util.h" #include "base/string16.h" +#include "base/win/registry.h" #include "base/win/scoped_handle.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" namespace { +const wchar_t kVersionKey[] = L"pv"; +const wchar_t kNameKey[] = L"name"; +const wchar_t kLangKey[] = L"lang"; +const wchar_t kNameValue[] = L"GCP Virtual Driver"; +const wchar_t kLangValue[] = L"rn"; + +void SetRegistryKeys() { + base::win::RegKey key; + if (key.Create(HKEY_LOCAL_MACHINE, cloud_print::kKeyLocation, + KEY_SET_VALUE) != ERROR_SUCCESS) { + LOG(ERROR) << "Unable to open key"; + } + + // Get the version from the resource file. + std::wstring 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 Omaha 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 || + key.WriteValue(kLangKey, kLangValue) != ERROR_SUCCESS) { + LOG(ERROR) << "Unable to set registry keys"; + } +} + +void DeleteRegistryKeys() { + base::win::RegKey key; + if (key.Open(HKEY_LOCAL_MACHINE, cloud_print::kKeyLocation, + DELETE) != ERROR_SUCCESS) { + LOG(ERROR) << "Unable to open key to delete"; + } + if (key.DeleteKey(L"") != ERROR_SUCCESS) { + LOG(ERROR) << "Unable to delete key"; + } +} HRESULT GetPpdPath(FilePath* path) { if (!PathService::Get(base::DIR_EXE, path)) { @@ -280,6 +326,7 @@ HRESULT InstallVirtualDriver(void) { LOG(ERROR) << "Unable to install printer."; return result; } + SetRegistryKeys(); return S_OK; } @@ -300,6 +347,7 @@ HRESULT UninstallVirtualDriver(void) { LOG(ERROR) << "Unable to remove port monitor."; return result; } + DeleteRegistryKeys(); return S_OK; } @@ -317,7 +365,8 @@ int WINAPI WinMain(__in HINSTANCE hInstance, } else { retval = InstallVirtualDriver(); } - if (!CommandLine::ForCurrentProcess()->HasSwitch("silent")) { + // Installer is silent by default as required by Omaha. + if (CommandLine::ForCurrentProcess()->HasSwitch("verbose")) { cloud_print::DisplayWindowsMessage(NULL, retval, cloud_print::LoadLocalString(IDS_DRIVER_NAME)); } diff --git a/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc b/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc index fe3398f..3e02e36 100644 --- a/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc +++ b/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc @@ -357,6 +357,16 @@ BOOL WINAPI Monitor2StartDocPort(HANDLE port_handle, DWORD, BYTE*) { LOG(INFO) << "Monitor2StartDocPort"; + 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, kKeyLocation, + KEY_SET_VALUE) != ERROR_SUCCESS) { + LOG(ERROR) << "Unable to open key to log usage"; + } + if (key.WriteValue(kUsageKey, L"1") != ERROR_SUCCESS) { + LOG(ERROR) << "Unable to set usage key"; + } if (port_handle == NULL) { LOG(ERROR) << "port_handle should not be NULL."; SetLastError(ERROR_INVALID_PARAMETER); diff --git a/cloud_print/virtual_driver/win/virtual_driver_consts.cc b/cloud_print/virtual_driver/win/virtual_driver_consts.cc index 820ee53..7d13eeb 100644 --- a/cloud_print/virtual_driver/win/virtual_driver_consts.cc +++ b/cloud_print/virtual_driver/win/virtual_driver_consts.cc @@ -9,5 +9,7 @@ namespace cloud_print { const wchar_t kPortName[] = L"GCP:"; const size_t kPortNameSize = sizeof(kPortName); +const wchar_t kKeyLocation[] = + L"SOFTWARE\\Google\\Update\\Clients\\{9B13FA92-1F73-4761-AB78-2C6ADAC3660D}"; } diff --git a/cloud_print/virtual_driver/win/virtual_driver_consts.h b/cloud_print/virtual_driver/win/virtual_driver_consts.h index 78aab9c..7f75f6e 100644 --- a/cloud_print/virtual_driver/win/virtual_driver_consts.h +++ b/cloud_print/virtual_driver/win/virtual_driver_consts.h @@ -9,7 +9,9 @@ namespace cloud_print { extern const wchar_t kPortName[]; extern const size_t kPortNameSize; +extern const wchar_t kKeyLocation[]; } // namespace cloud_print + #endif // CLOUD_PRINT_VIRTUAL_DRIVER_WIN_VIRTUAL_DRIVER_CONSTS_H_ |