Chromium Code Reviews| 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 "build/intsafe_workaround.h" | 5 #include "build/intsafe_workaround.h" |
| 6 | 6 |
| 7 #include <atlbase.h> | 7 #include <atlbase.h> |
| 8 #include <atlcom.h> | 8 #include <atlcom.h> |
| 9 #include <atlctl.h> | 9 #include <atlctl.h> |
| 10 #include <initguid.h> | 10 #include <initguid.h> |
| 11 #include <shellapi.h> | 11 #include <shellapi.h> |
| 12 | 12 |
| 13 #include "base/at_exit.h" | 13 #include "base/at_exit.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/process/kill.h" | 17 #include "base/process/kill.h" |
| 18 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
| 19 #include "base/win/scoped_com_initializer.h" | 19 #include "base/win/scoped_com_initializer.h" |
| 20 #include "base/win/scoped_handle.h" | 20 #include "base/win/scoped_handle.h" |
| 21 #include "breakpad/src/client/windows/handler/exception_handler.h" | 21 #include "breakpad/src/client/windows/handler/exception_handler.h" |
| 22 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 23 #include "chrome/installer/util/install_util.h" | |
| 23 #include "win8/delegate_execute/command_execute_impl.h" | 24 #include "win8/delegate_execute/command_execute_impl.h" |
| 24 #include "win8/delegate_execute/crash_server_init.h" | 25 #include "win8/delegate_execute/crash_server_init.h" |
| 25 #include "win8/delegate_execute/delegate_execute_operation.h" | 26 #include "win8/delegate_execute/delegate_execute_operation.h" |
| 26 #include "win8/delegate_execute/resource.h" | 27 #include "win8/delegate_execute/resource.h" |
| 27 | 28 |
| 29 namespace { | |
| 30 // {5C65F4B0-3651-4514-B207-D10CB699B14B} | |
| 31 DEFINE_GUID(chrome_command_execute_impl_clsid, 0x5C65F4B0, 0x3651, 0x4514, | |
| 32 0xB2, 0x07, 0xD1, 0x0C, 0xB6, 0x99, 0xB1, 0x4B); | |
| 33 | |
| 34 // {1BEAC3E3-B852-44F4-B468-8906C062422E} | |
| 35 DEFINE_GUID(sxs_command_execute_impl_clsid, 0x1BEAC3E3, 0xB852, 0x44F4, | |
| 36 0xB4, 0x68, 0x89, 0x06, 0xC0, 0x62, 0x42, 0x2E); | |
| 37 | |
| 38 // {A2DF06F9-A21A-44A8-8A99-8B9C84F29160} | |
| 39 DEFINE_GUID(default_command_execute_impl_clsid, 0xA2DF06F9, 0xA21A, 0x44A8, | |
|
grt (UTC plus 2)
2013/08/30 03:28:18
suggestion: rename "default" to "chromium" and "ch
grt (UTC plus 2)
2013/09/04 03:33:36
ping?
zturner
2013/09/05 01:35:29
All of these are gone now.
| |
| 40 0x8A, 0x99, 0x8B, 0x9C, 0x84, 0xF2, 0x91, 0x60); | |
| 41 } | |
| 42 | |
| 28 using namespace ATL; | 43 using namespace ATL; |
| 29 | 44 |
| 30 class DelegateExecuteModule | 45 class DelegateExecuteModule |
| 31 : public ATL::CAtlExeModuleT< DelegateExecuteModule > { | 46 : public ATL::CAtlExeModuleT< DelegateExecuteModule > { |
| 32 public : | 47 public : |
| 33 typedef ATL::CAtlExeModuleT<DelegateExecuteModule> ParentClass; | 48 typedef ATL::CAtlExeModuleT<DelegateExecuteModule> ParentClass; |
| 49 typedef CComObject<CommandExecuteImpl> ImplType; | |
| 34 | 50 |
| 35 HRESULT RegisterServer(BOOL reg_type_lib) { | 51 DelegateExecuteModule() |
| 36 return ParentClass::RegisterServer(FALSE); | 52 : impl_(NULL), |
| 53 registration_token_(0), | |
| 54 clsid_(CLSID_NULL) { | |
| 37 } | 55 } |
| 38 | 56 |
| 39 virtual HRESULT AddCommonRGSReplacements(IRegistrarBase* registrar) throw() { | 57 HRESULT PreMessageLoop(int nShowCmd) { |
| 40 AtlTrace(L"In %hs\n", __FUNCTION__); | 58 HRESULT hr = S_OK; |
| 41 HRESULT hr = ParentClass::AddCommonRGSReplacements(registrar); | 59 #if defined(GOOGLE_CHROME_BUILD) |
| 60 if (InstallUtil::IsChromeSxSProcess()) | |
| 61 clsid_ = sxs_command_execute_impl_clsid; | |
| 62 else | |
| 63 clsid_ = chrome_command_execute_impl_clsid; | |
| 64 #else | |
| 65 clsid_ = default_command_execute_impl_clsid; | |
| 66 #endif | |
| 67 | |
| 68 // We use the same class creation logic as ATL itself. See | |
| 69 // _ATL_OBJMAP_ENTRY::RegisterClassObject() in atlbase.h | |
| 70 hr = ImplType::_ClassFactoryCreatorClass::CreateInstance( | |
| 71 ImplType::_CreatorClass::CreateInstance, IID_IUnknown, | |
| 72 (LPVOID*)&impl_); | |
| 73 if (FAILED(hr)) | |
| 74 return hr; | |
| 75 hr = ::CoRegisterClassObject(clsid_, impl_, CLSCTX_LOCAL_SERVER, | |
| 76 REGCLS_MULTIPLEUSE | REGCLS_SUSPENDED, ®istration_token_); | |
| 42 if (FAILED(hr)) | 77 if (FAILED(hr)) |
| 43 return hr; | 78 return hr; |
| 44 | 79 |
| 45 wchar_t delegate_execute_clsid[MAX_PATH] = {0}; | 80 return ParentClass::PreMessageLoop(nShowCmd); |
| 46 if (!StringFromGUID2(__uuidof(CommandExecuteImpl), delegate_execute_clsid, | 81 } |
| 47 ARRAYSIZE(delegate_execute_clsid))) { | 82 |
| 48 ATLASSERT(false); | 83 HRESULT PostMessageLoop() { |
| 49 return E_FAIL; | 84 if (registration_token_ != 0) { |
| 85 ::CoRevokeClassObject(registration_token_); | |
| 86 registration_token_ = 0; | |
| 87 } | |
| 88 if (impl_ != NULL) { | |
| 89 impl_->Release(); | |
| 90 impl_ = NULL; | |
| 50 } | 91 } |
| 51 | 92 |
| 52 hr = registrar->AddReplacement(L"DELEGATE_EXECUTE_CLSID", | 93 return ParentClass::PostMessageLoop(); |
| 53 delegate_execute_clsid); | |
| 54 ATLASSERT(SUCCEEDED(hr)); | |
| 55 return hr; | |
| 56 } | 94 } |
| 95 | |
| 96 private: | |
| 97 IUnknown* impl_; | |
|
grt (UTC plus 2)
2013/08/30 03:28:18
consider base::win::ScopedHandle impl_;
impl_.Rece
grt (UTC plus 2)
2013/09/04 03:33:36
ping?
zturner
2013/09/05 01:35:29
Used base::win::ScopedComPtr
| |
| 98 DWORD registration_token_; | |
| 99 GUID clsid_; | |
|
grt (UTC plus 2)
2013/08/30 03:28:18
does this need to be an instance variable, or can
grt (UTC plus 2)
2013/09/04 03:33:36
ping?
zturner
2013/09/05 01:35:29
Done.
| |
| 57 }; | 100 }; |
| 58 | 101 |
| 59 DelegateExecuteModule _AtlModule; | 102 DelegateExecuteModule _AtlModule; |
| 60 | 103 |
| 61 using delegate_execute::DelegateExecuteOperation; | 104 using delegate_execute::DelegateExecuteOperation; |
| 62 using base::win::ScopedHandle; | 105 using base::win::ScopedHandle; |
| 63 | 106 |
| 64 int RelaunchChrome(const DelegateExecuteOperation& operation) { | 107 int RelaunchChrome(const DelegateExecuteOperation& operation) { |
| 65 AtlTrace("Relaunching [%ls] with flags [%s]\n", | 108 AtlTrace("Relaunching [%ls] with flags [%s]\n", |
| 66 operation.mutex().c_str(), operation.relaunch_flags()); | 109 operation.mutex().c_str(), operation.relaunch_flags()); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 case DelegateExecuteOperation::RELAUNCH_CHROME: | 168 case DelegateExecuteOperation::RELAUNCH_CHROME: |
| 126 ret_code = RelaunchChrome(operation); | 169 ret_code = RelaunchChrome(operation); |
| 127 break; | 170 break; |
| 128 default: | 171 default: |
| 129 NOTREACHED(); | 172 NOTREACHED(); |
| 130 } | 173 } |
| 131 } | 174 } |
| 132 AtlTrace("delegate_execute exit, code = %d\n", ret_code); | 175 AtlTrace("delegate_execute exit, code = %d\n", ret_code); |
| 133 return ret_code; | 176 return ret_code; |
| 134 } | 177 } |
| OLD | NEW |