summaryrefslogtreecommitdiffstats
path: root/cloud_print
diff options
context:
space:
mode:
authorvitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-29 21:45:17 +0000
committervitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-29 21:45:17 +0000
commitd46d027a8085949c66a2471f8c267343e33e75ac (patch)
tree6a8dd0966f19cbdbbabc3a7d5ab20dac588e4831 /cloud_print
parentb0e7dd359795fbb3085f832831e9557affd4e478 (diff)
downloadchromium_src-d46d027a8085949c66a2471f8c267343e33e75ac.zip
chromium_src-d46d027a8085949c66a2471f8c267343e33e75ac.tar.gz
chromium_src-d46d027a8085949c66a2471f8c267343e33e75ac.tar.bz2
Fixed AppID registration.
Removed user confirmation on missing state file. BUG=None TEST=None Review URL: https://chromiumcodereview.appspot.com/10459005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139381 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cloud_print')
-rw-r--r--cloud_print/service/win/cloud_print_service.cc55
-rw-r--r--cloud_print/service/win/cloud_print_service.rgs13
2 files changed, 44 insertions, 24 deletions
diff --git a/cloud_print/service/win/cloud_print_service.cc b/cloud_print/service/win/cloud_print_service.cc
index 2eeac75..366ea2d 100644
--- a/cloud_print/service/win/cloud_print_service.cc
+++ b/cloud_print/service/win/cloud_print_service.cc
@@ -118,7 +118,7 @@ std::string GetOption(const std::string& name, const std::string& default,
DWORD saved_mode = 0;
// Don't close.
HANDLE stdin_handle = ::GetStdHandle(STD_INPUT_HANDLE);
- ::GetConsoleMode(stdin_handle, &saved_mode);
+ ::GetConsoleMode(stdin_handle, &saved_mode);
::SetConsoleMode(stdin_handle, saved_mode & ~ENABLE_ECHO_INPUT);
std::getline(std::cin, tmp);
::SetConsoleMode(stdin_handle, saved_mode);
@@ -148,11 +148,16 @@ class CloudPrintServiceModule
return S_OK;
}
- HRESULT Install(const FilePath& user_data_dir) {
+ HRESULT InstallService(const FilePath& user_data_dir) {
// TODO(vitalybuka): consider "lite" version if we don't want unregister
// printers here.
- if (!Uninstall())
- return E_FAIL;
+ HRESULT hr = UninstallService();
+ if (FAILED(hr))
+ return hr;
+
+ hr = UpdateRegistryAppId(true);
+ if (FAILED(hr))
+ return hr;
FilePath service_path;
CHECK(PathService::Get(base::FILE_EXE, &service_path));
@@ -161,14 +166,14 @@ class CloudPrintServiceModule
command_line.AppendSwitchPath(kUserDataDirSwitch, user_data_dir);
ServiceHandle scm;
- HRESULT hr = OpenServiceManager(&scm);
+ hr = OpenServiceManager(&scm);
if (FAILED(hr))
return hr;
- ServiceHandle service(
- ::CreateService(
- scm, m_szServiceName, m_szServiceName, SERVICE_ALL_ACCESS,
- SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL,
+ ServiceHandle service(
+ ::CreateService(
+ scm, m_szServiceName, m_szServiceName, SERVICE_ALL_ACCESS,
+ SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL,
command_line.GetCommandLineString().c_str(), NULL, NULL, NULL,
L"NT AUTHORITY\\LocalService", NULL));
@@ -178,6 +183,12 @@ class CloudPrintServiceModule
return S_OK;
}
+ HRESULT UninstallService() {
+ if (!Uninstall())
+ return E_FAIL;
+ return UpdateRegistryAppId(false);
+ }
+
bool ParseCommandLine(LPCTSTR lpCmdLine, HRESULT* pnRetCode) {
CHECK(pnRetCode);
CommandLine command_line(CommandLine::NO_PROGRAM);
@@ -220,7 +231,7 @@ class CloudPrintServiceModule
return StopService();
if (command_line.HasSwitch(kUninstallSwitch))
- return Uninstall() ? S_OK : E_FAIL;
+ return UninstallService();
if (command_line.HasSwitch(kInstallSwitch)) {
if (!command_line.HasSwitch(kUserDataDirSwitch)) {
@@ -233,7 +244,7 @@ class CloudPrintServiceModule
command_line.HasSwitch(kQuietSwitch));
if (FAILED(hr))
return hr;
- hr = Install(data_dir);
+ hr = InstallService(data_dir);
if (SUCCEEDED(hr) && command_line.HasSwitch(kStartSwitch))
return StartService();
@@ -274,16 +285,18 @@ class CloudPrintServiceModule
if (quiet)
return is_valid ? S_OK : HRESULT_FROM_WIN32(ERROR_FILE_INVALID);
- std::cout << "Do you want to use this file [y/n]:";
- for (;;) {
- std::string input;
- std::getline(std::cin, input);
- StringToLowerASCII(&input);
- if (input == "y") {
- return S_OK;
- } else if (input == "n") {
- is_valid = false;
- break;
+ if (!contents.empty()) {
+ std::cout << "Do you want to use this file [y/n]:";
+ for (;;) {
+ std::string input;
+ std::getline(std::cin, input);
+ StringToLowerASCII(&input);
+ if (input == "y") {
+ return S_OK;
+ } else if (input == "n") {
+ is_valid = false;
+ break;
+ }
}
}
diff --git a/cloud_print/service/win/cloud_print_service.rgs b/cloud_print/service/win/cloud_print_service.rgs
index 8219d93..9ebaebe 100644
--- a/cloud_print/service/win/cloud_print_service.rgs
+++ b/cloud_print/service/win/cloud_print_service.rgs
@@ -1,3 +1,10 @@
-HKCR
-{
-}
+HKCR
+{
+ NoRemove AppID
+ {
+ ForceRemove '%APPID%'
+ {
+ val LocalService = s 'CloudPrintService'
+ }
+ }
+}