diff options
author | gene@chromium.org <gene@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-27 17:55:06 +0000 |
---|---|---|
committer | gene@chromium.org <gene@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-27 17:55:06 +0000 |
commit | bd1d4ff79a9653acf5e8c4d73c9061f62a3fe9fd (patch) | |
tree | d8d725f2eaf3d91b639da7b18fa529e679dd2721 /cloud_print/service | |
parent | 5bcfaef580566eb21aa09faf01120afd982203e8 (diff) | |
download | chromium_src-bd1d4ff79a9653acf5e8c4d73c9061f62a3fe9fd.zip chromium_src-bd1d4ff79a9653acf5e8c4d73c9061f62a3fe9fd.tar.gz chromium_src-bd1d4ff79a9653acf5e8c4d73c9061f62a3fe9fd.tar.bz2 |
Adding Windows service template for Cloud Print connector.
Current Service can register and unrerister itself as a Windows Service.
This service is not part of the Chrome browser, but belongs to the
place as virtual print driver for cloud print.
BUG=125026
TEST=Build and verify service gets registered with "/Service" command. And unregistered with "/UninstallService" command.
Review URL: https://chromiumcodereview.appspot.com/10222011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134298 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cloud_print/service')
-rw-r--r-- | cloud_print/service/win/cloud_print_service.cc | 41 | ||||
-rw-r--r-- | cloud_print/service/win/cloud_print_service.h | 27 | ||||
-rw-r--r-- | cloud_print/service/win/cloud_print_service.rc | 104 | ||||
-rw-r--r-- | cloud_print/service/win/cloud_print_service.rgs | 3 | ||||
-rw-r--r-- | cloud_print/service/win/resource.h | 21 | ||||
-rw-r--r-- | cloud_print/service/win/service.gyp | 30 |
6 files changed, 226 insertions, 0 deletions
diff --git a/cloud_print/service/win/cloud_print_service.cc b/cloud_print/service/win/cloud_print_service.cc new file mode 100644 index 0000000..6c6ae19 --- /dev/null +++ b/cloud_print/service/win/cloud_print_service.cc @@ -0,0 +1,41 @@ +// Copyright (c) 2012 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/service/win/cloud_print_service.h" + +#include "cloud_print/service/win/resource.h" + +class CloudPrintServiceModule + : public ATL::CAtlServiceModuleT<CloudPrintServiceModule, IDS_SERVICENAME> { + public: + DECLARE_REGISTRY_APPID_RESOURCEID(IDR_CLOUDPRINTSERVICE, + "{8013FB7C-2E3E-4992-B8BD-05C0C4AB0627}") + HRESULT InitializeSecurity() throw() { + // TODO(gene): Check if we need to call CoInitializeSecurity and provide + // the appropriate security settings for service. + return S_OK; + } +}; + +CloudPrintServiceModule _AtlModule; + +int WINAPI WinMain(__in HINSTANCE hInstance, + __in HINSTANCE hPrevInstance, + __in LPSTR lpCmdLine, + __in int nCmdShow) { + // Handle service unstall case manually. + // Service install is handled through ATL, command line flag "/Service" + // http://msdn.microsoft.com/en-US/library/z8868y94(v=vs.80).aspx + if (StrStrA(lpCmdLine, "/UninstallService") != NULL) { + _AtlModule.Uninstall(); + return 0; + } + + // TODO(gene): When running this program with "/Service" flag it fails + // silently if command prompt is not elevated. + // Consider adding manifest to require elevated prompt, or at least + // print warning in this case. + return _AtlModule.WinMain(nCmdShow); +} + diff --git a/cloud_print/service/win/cloud_print_service.h b/cloud_print/service/win/cloud_print_service.h new file mode 100644 index 0000000..770a72e --- /dev/null +++ b/cloud_print/service/win/cloud_print_service.h @@ -0,0 +1,27 @@ +// Copyright (c) 2012 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_SERVICE_CLOUD_PRINT_SERVICE_H_ +#define CLOUD_PRINT_SERVICE_CLOUD_PRINT_SERVICE_H_ +#pragma once + +#ifndef STRICT +#define STRICT +#endif + +#define _ATL_FREE_THREADED + +#define _ATL_NO_AUTOMATIC_NAMESPACE + +// some CString constructors will be explicit +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS + +#define ATL_NO_ASSERT_ON_DESTROY_NONEXISTENT_WINDOW + +#include <atlbase.h> +#include <atlcom.h> +#include <atlctl.h> + +#endif // CLOUD_PRINT_SERVICE_CLOUD_PRINT_SERVICE_H_ + diff --git a/cloud_print/service/win/cloud_print_service.rc b/cloud_print/service/win/cloud_print_service.rc new file mode 100644 index 0000000..ea5c57d9 --- /dev/null +++ b/cloud_print/service/win/cloud_print_service.rc @@ -0,0 +1,104 @@ +// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "winres.h"
+#include "verrsrc.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (United States) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#ifndef APSTUDIO_INVOKED\r\n"
+ "#include ""targetver.h""\r\n"
+ "#endif\r\n"
+ "#include ""winres.h""\r\n"
+ "#include ""verrsrc.h""\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,0,0,1
+ PRODUCTVERSION 1,0,0,1
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "CompanyName", "Google"
+ VALUE "FileDescription", "CloudPrint Service"
+ VALUE "FileVersion", "1.0.0.1"
+ VALUE "InternalName", "CloudPrintService.exe"
+ VALUE "LegalCopyright", "(c) Google. All rights reserved."
+ VALUE "OriginalFilename", "CloudPrintService.exe"
+ VALUE "ProductName", "Google Cloud Print Service"
+ VALUE "ProductVersion", "1.0.0.1"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// REGISTRY
+//
+
+IDR_CLOUDPRINTSERVICE REGISTRY "cloud_print_service.rgs"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE
+BEGIN
+ IDS_SERVICENAME "CloudPrintService"
+END
+
+#endif // English (United States) resources
+/////////////////////////////////////////////////////////////////////////////
+
diff --git a/cloud_print/service/win/cloud_print_service.rgs b/cloud_print/service/win/cloud_print_service.rgs new file mode 100644 index 0000000..8219d93 --- /dev/null +++ b/cloud_print/service/win/cloud_print_service.rgs @@ -0,0 +1,3 @@ +HKCR
+{
+}
diff --git a/cloud_print/service/win/resource.h b/cloud_print/service/win/resource.h new file mode 100644 index 0000000..f7621b4 --- /dev/null +++ b/cloud_print/service/win/resource.h @@ -0,0 +1,21 @@ +// Copyright (c) 2012 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. + +// {{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by cloud_print service.rc + +#define IDS_SERVICENAME 100 +#define IDR_CLOUDPRINTSERVICE 101 + +// Next default values for new objects +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 201 +#define _APS_NEXT_COMMAND_VALUE 32768 +#define _APS_NEXT_CONTROL_VALUE 201 +#define _APS_NEXT_SYMED_VALUE 106 +#endif +#endif + diff --git a/cloud_print/service/win/service.gyp b/cloud_print/service/win/service.gyp new file mode 100644 index 0000000..cd58acb --- /dev/null +++ b/cloud_print/service/win/service.gyp @@ -0,0 +1,30 @@ +# Copyright (c) 2012 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. +{ + 'target_defaults': { + 'variables': { + 'chromium_code': 1, + }, + 'include_dirs': [ + '../../..', + ], + }, + 'targets': [ + { + 'target_name': 'cloud_print_service', + 'type': 'executable', + 'sources': [ + 'cloud_print_service.cc', + 'cloud_print_service.h', + 'cloud_print_service.rc', + 'resource.h', + ], + 'msvs_settings': { + 'VCLinkerTool': { + 'SubSystem': '2', # Set /SUBSYSTEM:WINDOWS + }, + }, + }, + ], +} |