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

Unified Diff: cloud_print/virtual_driver/win/install/setup.cc

Issue 7532031: Changes to write various registry keys as required by Omaha for Windows Cloud Print Virtual Driver. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Make installer silent by default. Created 9 years, 5 months 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 side-by-side diff with in-line comments
Download patch
Index: cloud_print/virtual_driver/win/install/setup.cc
diff --git a/cloud_print/virtual_driver/win/install/setup.cc b/cloud_print/virtual_driver/win/install/setup.cc
index 6ee31096b7ef1338e3c5ccb0e44d16dd6548e1e6..d8e6428d8b802574a9b3ce8d9f5801cff773abf4 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";
+
+void SetRegistryKeys() {
+ base::win::RegKey key;
+ if(key.Create(HKEY_LOCAL_MACHINE,cloud_print::kKeyLocation,
+ KEY_ALL_ACCESS) != 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"1.9.8.3";
Albert Bodenhamer 2011/07/29 21:43:48 Use 0.0.0.99 or something like it. 1.9.8.3 might
abeera 2011/07/29 21:53:41 Done.
+ }
+
+ if(key.WriteValue(kVersionKey,version_string.c_str()) != ERROR_SUCCESS ||
+ key.WriteValue(kNameKey,L"GCP Virtual Driver") != ERROR_SUCCESS ||
+ key.WriteValue(kLangKey,L"en") != ERROR_SUCCESS) {
+ LOG(ERROR) << "Unable to set registry keys";
+ }
+}
+
+void DeleteRegistryKeys() {
+ base::win::RegKey key;
+ if(key.Create(HKEY_LOCAL_MACHINE, cloud_print::kKeyLocation,
+ KEY_ALL_ACCESS) != ERROR_SUCCESS) {
+ LOG(ERROR) << "Unable to open key to delete";
+ }
+ if(key.DeleteKey(L"") != ERROR_SUCCESS ) {
+ LOG(ERROR) << "Unable to delete key";
+ }
+
+}
HRESULT GetGpdPath(FilePath* path) {
if (!PathService::Get(base::DIR_EXE, path)) {
@@ -278,6 +324,7 @@ HRESULT InstallVirtualDriver(void) {
LOG(ERROR) << "Unable to install printer.";
return result;
}
+ SetRegistryKeys();
return S_OK;
}
@@ -298,6 +345,7 @@ HRESULT UninstallVirtualDriver(void) {
LOG(ERROR) << "Unable to remove port monitor.";
return result;
}
+ DeleteRegistryKeys();
return S_OK;
}
@@ -315,7 +363,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));
}

Powered by Google App Engine
This is Rietveld 408576698