| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cloud_print/service/win/cloud_print_service.h" | 5 #include "cloud_print/service/win/cloud_print_service.h" |
| 6 | 6 |
| 7 #include <atlsecurity.h> | 7 #include <atlsecurity.h> |
| 8 #include <iomanip> | 8 #include <iomanip> |
| 9 #include <iostream> | 9 #include <iostream> |
| 10 | 10 |
| 11 #include "base/at_exit.h" | 11 #include "base/at_exit.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "base/file_util.h" | 14 #include "base/file_util.h" |
| 15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/win/scoped_handle.h" | 17 #include "base/win/scoped_handle.h" |
| 18 #include "chrome/installer/launcher_support/chrome_launcher_support.h" |
| 18 #include "cloud_print/service/service_state.h" | 19 #include "cloud_print/service/service_state.h" |
| 19 #include "cloud_print/service/service_switches.h" | 20 #include "cloud_print/service/service_switches.h" |
| 20 #include "cloud_print/service/win/chrome_launcher.h" | 21 #include "cloud_print/service/win/chrome_launcher.h" |
| 21 #include "cloud_print/service/win/resource.h" | 22 #include "cloud_print/service/win/resource.h" |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 const wchar_t kServiceStateFileName[] = L"Service State"; | 26 const wchar_t kServiceStateFileName[] = L"Service State"; |
| 26 | 27 |
| 27 const wchar_t kUserToRunService[] = L"NT AUTHORITY\\LocalService"; | 28 const wchar_t kUserToRunService[] = L"NT AUTHORITY\\LocalService"; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 DECLARE_REGISTRY_APPID_RESOURCEID(IDR_CLOUDPRINTSERVICE, | 176 DECLARE_REGISTRY_APPID_RESOURCEID(IDR_CLOUDPRINTSERVICE, |
| 176 "{8013FB7C-2E3E-4992-B8BD-05C0C4AB0627}") | 177 "{8013FB7C-2E3E-4992-B8BD-05C0C4AB0627}") |
| 177 | 178 |
| 178 HRESULT InitializeSecurity() { | 179 HRESULT InitializeSecurity() { |
| 179 // TODO(gene): Check if we need to call CoInitializeSecurity and provide | 180 // TODO(gene): Check if we need to call CoInitializeSecurity and provide |
| 180 // the appropriate security settings for service. | 181 // the appropriate security settings for service. |
| 181 return S_OK; | 182 return S_OK; |
| 182 } | 183 } |
| 183 | 184 |
| 184 HRESULT InstallService() { | 185 HRESULT InstallService() { |
| 186 using namespace chrome_launcher_support; |
| 187 |
| 185 // TODO(vitalybuka): consider "lite" version if we don't want unregister | 188 // TODO(vitalybuka): consider "lite" version if we don't want unregister |
| 186 // printers here. | 189 // printers here. |
| 187 HRESULT hr = UninstallService(); | 190 HRESULT hr = UninstallService(); |
| 188 if (FAILED(hr)) | 191 if (FAILED(hr)) |
| 189 return hr; | 192 return hr; |
| 190 | 193 |
| 191 if (ChromeLauncher::GetChromePath(HKEY_LOCAL_MACHINE).empty()) { | 194 if (GetChromePathForInstallationLevel(SYSTEM_LEVEL_INSTALLATION).empty()) { |
| 192 LOG(ERROR) << "Found no Chrome installed for all users."; | 195 LOG(ERROR) << "Found no Chrome installed for all users."; |
| 193 return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); | 196 return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); |
| 194 } | 197 } |
| 195 | 198 |
| 196 hr = UpdateRegistryAppId(true); | 199 hr = UpdateRegistryAppId(true); |
| 197 if (FAILED(hr)) | 200 if (FAILED(hr)) |
| 198 return hr; | 201 return hr; |
| 199 | 202 |
| 200 FilePath service_path; | 203 FilePath service_path; |
| 201 CHECK(PathService::Get(base::FILE_EXE, &service_path)); | 204 CHECK(PathService::Get(base::FILE_EXE, &service_path)); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 | 459 |
| 457 BOOL CloudPrintServiceModule::ConsoleCtrlHandler(DWORD type) { | 460 BOOL CloudPrintServiceModule::ConsoleCtrlHandler(DWORD type) { |
| 458 PostThreadMessage(_AtlModule.m_dwThreadID, WM_QUIT, 0, 0); | 461 PostThreadMessage(_AtlModule.m_dwThreadID, WM_QUIT, 0, 0); |
| 459 return TRUE; | 462 return TRUE; |
| 460 } | 463 } |
| 461 | 464 |
| 462 int main() { | 465 int main() { |
| 463 base::AtExitManager at_exit; | 466 base::AtExitManager at_exit; |
| 464 return _AtlModule.WinMain(0); | 467 return _AtlModule.WinMain(0); |
| 465 } | 468 } |
| OLD | NEW |