From d546c48d90f0eaa592794f59e6a970b7b027db86 Mon Sep 17 00:00:00 2001 From: "brettw@chromium.org" Date: Wed, 29 Dec 2010 21:54:42 +0000 Subject: Move rgs_helper out of base to ceee since it's not used anywhere else. TEST=it compiles BUG=none Review URL: http://codereview.chromium.org/6041007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70280 0039d316-1c4b-4281-b951-d872f2087c98 --- ceee/ie/broker/broker.h | 2 +- ceee/ie/common/rgs_helper.h | 89 ++++++++++++++++++++++++++++++ ceee/ie/ie.gyp | 1 + ceee/ie/plugin/bho/browser_helper_object.h | 2 +- ceee/ie/plugin/bho/executor.h | 2 +- ceee/ie/plugin/toolband/tool_band.h | 2 +- 6 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 ceee/ie/common/rgs_helper.h (limited to 'ceee') diff --git a/ceee/ie/broker/broker.h b/ceee/ie/broker/broker.h index 617fc8f..f8a07d1 100644 --- a/ceee/ie/broker/broker.h +++ b/ceee/ie/broker/broker.h @@ -11,8 +11,8 @@ #include #include -#include "base/win/rgs_helper.h" #include "ceee/ie/broker/resource.h" +#include "ceee/ie/common/rgs_helper.h" #include "broker_lib.h" // NOLINT diff --git a/ceee/ie/common/rgs_helper.h b/ceee/ie/common/rgs_helper.h new file mode 100644 index 0000000..1f1d235 --- /dev/null +++ b/ceee/ie/common/rgs_helper.h @@ -0,0 +1,89 @@ +// Copyright (c) 2010 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. +// +// Defines a map for adding variables to rgs files. This allows COM object +// classes to declare the values of these variables so that we don't need to +// copy/paste them and manually keep them in sync. +// To use this, declare the registry ID of your RGS file using +// the DECLARE_REGISTRY_RESOURCEID_EX macro, instead of the +// DECLARE_REGISTRY_RESOURCEID, then add a registry map to your class +// using the registry map macros: +// BEGIN_REGISTRY_MAP(MyClassName) +// REGMAP_ENTRY("NAME", "MyClassName Class") +// REGMAP_ENTRY_UUID("CLSID", CLSID_MyClassName) +// END_REGISTRY_MAP() +// +// You can then refer to the names above in your RGS file as +// variables %NAME% and %CLSID%, respectively. +#ifndef CEEE_IE_COMMON_RGS_HELPER_H_ +#define CEEE_IE_COMMON_RGS_HELPER_H_ + +#include "base/string_util.h" + +struct ATLRegmapEntryHelper : public _ATL_REGMAP_ENTRY { + ATLRegmapEntryHelper() { + szKey = NULL; + szData = NULL; + } + ATLRegmapEntryHelper(LPCOLESTR key, LPCOLESTR data) { + szKey = key; + size_t size = lstrlen(data) + 1; + szData = new wchar_t[size]; + base::wcslcpy(const_cast(szData), data, size); + } + + ATLRegmapEntryHelper(LPCOLESTR key, UINT resid) { + wchar_t data[256] = {0}; + szKey = key; + if (::LoadString(_pModule->m_hInstResource, resid, data, + arraysize(data) - 1) == 0) { + *data = L'\0'; + } + + size_t size = lstrlen(data) + 1; + + szData = new wchar_t[size]; + base::wcslcpy(const_cast(szData), data, size); + } + + ATLRegmapEntryHelper(LPCOLESTR key, REFGUID guid) { + szKey = key; + static const size_t kGuidStringSize = 40; + szData = new wchar_t[kGuidStringSize]; + if (szData) { + if (::StringFromGUID2(guid, const_cast(szData), + kGuidStringSize) == 0) { + *const_cast(szData) = L'\0'; + } + } + } + ~ATLRegmapEntryHelper() { + delete [] szData; + } +}; + +#define BEGIN_REGISTRY_MAP(x)\ + static struct _ATL_REGMAP_ENTRY *_GetRegistryMap() {\ + static const ATLRegmapEntryHelper map[] = { +#define REGMAP_ENTRY(x, y) ATLRegmapEntryHelper(OLESTR(##x), OLESTR(##y)), + +#define REGMAP_UUID(x, clsid) ATLRegmapEntryHelper(OLESTR(##x), clsid), + +// This allows usage of a Resource string. +#define REGMAP_RESOURCE(x, resid) ATLRegmapEntryHelper(OLESTR(##x), resid), + +// This allows usage of a static function to be called to provide the string. +#define REGMAP_FUNCTION(x, f) ATLRegmapEntryHelper(OLESTR(##x), ##f()), + +#define END_REGISTRY_MAP() ATLRegmapEntryHelper() };\ + return (_ATL_REGMAP_ENTRY*)map;\ + } + +#define DECLARE_REGISTRY_RESOURCEID_EX(x)\ + static HRESULT WINAPI UpdateRegistry(BOOL bRegister) {\ + return ATL::_pAtlModule->UpdateRegistryFromResource((UINT)x, bRegister, \ + _GetRegistryMap());\ + } + +#endif // CEEE_IE_COMMON_RGS_HELPER_H_ diff --git a/ceee/ie/ie.gyp b/ceee/ie/ie.gyp index 2ee286c..ef6bed3 100644 --- a/ceee/ie/ie.gyp +++ b/ceee/ie/ie.gyp @@ -54,6 +54,7 @@ 'common/extension_manifest_unittest.cc', 'common/ie_util_unittest.cc', 'common/metrics_util_unittest.cc', + 'common/rgs_helper.h', 'plugin/bho/browser_helper_object_unittest.cc', 'plugin/bho/cookie_accountant_unittest.cc', 'plugin/bho/cookie_events_funnel_unittest.cc', diff --git a/ceee/ie/plugin/bho/browser_helper_object.h b/ceee/ie/plugin/bho/browser_helper_object.h index 8a699c3..7ff1688 100644 --- a/ceee/ie/plugin/bho/browser_helper_object.h +++ b/ceee/ie/plugin/bho/browser_helper_object.h @@ -22,10 +22,10 @@ #include "base/win/scoped_bstr.h" #include "base/win/scoped_comptr.h" #include "base/task.h" -#include "base/win/rgs_helper.h" #include "ceee/ie/broker/broker_rpc_client.h" #include "ceee/ie/plugin/bho/tab_events_funnel.h" #include "ceee/ie/common/chrome_frame_host.h" +#include "ceee/ie/common/rgs_helper.h" #include "ceee/ie/plugin/bho/frame_event_handler.h" #include "ceee/ie/plugin/bho/extension_port_manager.h" #include "ceee/ie/plugin/bho/tool_band_visibility.h" diff --git a/ceee/ie/plugin/bho/executor.h b/ceee/ie/plugin/bho/executor.h index 63ec87a..414d76b 100644 --- a/ceee/ie/plugin/bho/executor.h +++ b/ceee/ie/plugin/bho/executor.h @@ -15,7 +15,7 @@ #include "base/scoped_ptr.h" #include "base/task.h" -#include "base/win/rgs_helper.h" +#include "ceee/ie/common/rgs_helper.h" #include "ceee/ie/plugin/bho/infobar_manager.h" #include "ceee/ie/plugin/toolband/resource.h" diff --git a/ceee/ie/plugin/toolband/tool_band.h b/ceee/ie/plugin/toolband/tool_band.h index da183ef..543a2ea 100644 --- a/ceee/ie/plugin/toolband/tool_band.h +++ b/ceee/ie/plugin/toolband/tool_band.h @@ -21,7 +21,7 @@ #include "base/basictypes.h" #include "base/scoped_ptr.h" #include "base/win/scoped_comptr.h" -#include "base/win/rgs_helper.h" +#include "ceee/ie/common/rgs_helper.h" #include "ceee/ie/plugin/toolband/resource.h" #include "chrome_tab.h" // NOLINT -- cgit v1.1