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

Unified Diff: win8/delegate_execute/delegate_execute.cc

Issue 23258005: Give SxS distribution its own registration GUIDs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add linker dependency from metro_driver to installer_util Created 7 years, 3 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: win8/delegate_execute/delegate_execute.cc
diff --git a/win8/delegate_execute/delegate_execute.cc b/win8/delegate_execute/delegate_execute.cc
index 549716ac60d32cbfa62f1d0a66591267759ba3c7..d5934fe806172b518938b84504036b8e7d3fef5a 100644
--- a/win8/delegate_execute/delegate_execute.cc
+++ b/win8/delegate_execute/delegate_execute.cc
@@ -20,40 +20,83 @@
#include "base/win/scoped_handle.h"
#include "breakpad/src/client/windows/handler/exception_handler.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/installer/util/install_util.h"
gab 2013/09/03 21:05:19 What is this include for?
zturner 2013/09/05 01:35:29 It was originally for InstallUtil::IsChromeSxSProc
#include "win8/delegate_execute/command_execute_impl.h"
#include "win8/delegate_execute/crash_server_init.h"
#include "win8/delegate_execute/delegate_execute_operation.h"
#include "win8/delegate_execute/resource.h"
+namespace {
+ // {5C65F4B0-3651-4514-B207-D10CB699B14B}
+ DEFINE_GUID(chrome_command_execute_impl_clsid, 0x5C65F4B0, 0x3651, 0x4514,
+ 0xB2, 0x07, 0xD1, 0x0C, 0xB6, 0x99, 0xB1, 0x4B);
+
+ // {1BEAC3E3-B852-44F4-B468-8906C062422E}
+ DEFINE_GUID(sxs_command_execute_impl_clsid, 0x1BEAC3E3, 0xB852, 0x44F4,
+ 0xB4, 0x68, 0x89, 0x06, 0xC0, 0x62, 0x42, 0x2E);
+
+ // {A2DF06F9-A21A-44A8-8A99-8B9C84F29160}
+ DEFINE_GUID(default_command_execute_impl_clsid, 0xA2DF06F9, 0xA21A, 0x44A8,
+ 0x8A, 0x99, 0x8B, 0x9C, 0x84, 0xF2, 0x91, 0x60);
+}
+
using namespace ATL;
class DelegateExecuteModule
: public ATL::CAtlExeModuleT< DelegateExecuteModule > {
public :
typedef ATL::CAtlExeModuleT<DelegateExecuteModule> ParentClass;
+ typedef CComObject<CommandExecuteImpl> ImplType;
- HRESULT RegisterServer(BOOL reg_type_lib) {
- return ParentClass::RegisterServer(FALSE);
+ DelegateExecuteModule()
+ : impl_(NULL),
+ registration_token_(0),
+ clsid_(CLSID_NULL) {
}
- virtual HRESULT AddCommonRGSReplacements(IRegistrarBase* registrar) throw() {
- AtlTrace(L"In %hs\n", __FUNCTION__);
- HRESULT hr = ParentClass::AddCommonRGSReplacements(registrar);
+ HRESULT PreMessageLoop(int nShowCmd) {
+ HRESULT hr = S_OK;
+#if defined(GOOGLE_CHROME_BUILD)
+ if (InstallUtil::IsChromeSxSProcess())
+ clsid_ = sxs_command_execute_impl_clsid;
gab 2013/09/03 21:05:19 Use BrowserDistribution's GetCommandExecuteImplCls
zturner 2013/09/05 01:35:29 Done.
+ else
+ clsid_ = chrome_command_execute_impl_clsid;
+#else
+ clsid_ = default_command_execute_impl_clsid;
+#endif
+
+ // We use the same class creation logic as ATL itself. See
+ // _ATL_OBJMAP_ENTRY::RegisterClassObject() in atlbase.h
+ hr = ImplType::_ClassFactoryCreatorClass::CreateInstance(
+ ImplType::_CreatorClass::CreateInstance, IID_IUnknown,
+ (LPVOID*)&impl_);
+ if (FAILED(hr))
+ return hr;
+ hr = ::CoRegisterClassObject(clsid_, impl_, CLSCTX_LOCAL_SERVER,
+ REGCLS_MULTIPLEUSE | REGCLS_SUSPENDED, &registration_token_);
if (FAILED(hr))
return hr;
- wchar_t delegate_execute_clsid[MAX_PATH] = {0};
- if (!StringFromGUID2(__uuidof(CommandExecuteImpl), delegate_execute_clsid,
- ARRAYSIZE(delegate_execute_clsid))) {
- ATLASSERT(false);
- return E_FAIL;
+ return ParentClass::PreMessageLoop(nShowCmd);
+ }
+
+ HRESULT PostMessageLoop() {
+ if (registration_token_ != 0) {
+ ::CoRevokeClassObject(registration_token_);
+ registration_token_ = 0;
+ }
+ if (impl_ != NULL) {
+ impl_->Release();
+ impl_ = NULL;
}
- hr = registrar->AddReplacement(L"DELEGATE_EXECUTE_CLSID",
- delegate_execute_clsid);
- ATLASSERT(SUCCEEDED(hr));
- return hr;
+ return ParentClass::PostMessageLoop();
}
+
+private:
grt (UTC plus 2) 2013/09/04 03:33:36 nit: indent one space
zturner 2013/09/05 01:35:29 Done.
+ IUnknown* impl_;
+ DWORD registration_token_;
+ GUID clsid_;
};
DelegateExecuteModule _AtlModule;

Powered by Google App Engine
This is Rietveld 408576698