1 // Copyright 2017 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef BASE_WIN_CORE_WINRT_UTIL_H_ 6 #define BASE_WIN_CORE_WINRT_UTIL_H_ 7 8 #include <hstring.h> 9 #include <inspectable.h> 10 #include <roapi.h> 11 #include <windef.h> 12 13 #include "base/base_export.h" 14 #include "base/win/scoped_hstring.h" 15 16 namespace base::win { 17 18 // The following stubs are provided for when component build is enabled, in 19 // order to avoid the propagation of delay-loading CoreWinRT to other modules. 20 21 BASE_EXPORT HRESULT RoGetActivationFactory(HSTRING class_id, 22 const IID& iid, 23 void** out_factory); 24 25 BASE_EXPORT HRESULT RoActivateInstance(HSTRING class_id, 26 IInspectable** instance); 27 28 // Retrieves an activation factory for the type specified. 29 template <typename InterfaceType, wchar_t const* runtime_class_id> GetActivationFactory(InterfaceType ** factory)30HRESULT GetActivationFactory(InterfaceType** factory) { 31 ScopedHString class_id_hstring = ScopedHString::Create(runtime_class_id); 32 if (!class_id_hstring.is_valid()) 33 return E_FAIL; 34 35 return base::win::RoGetActivationFactory(class_id_hstring.get(), 36 IID_PPV_ARGS(factory)); 37 } 38 39 } // namespace base::win 40 41 #endif // BASE_WIN_CORE_WINRT_UTIL_H_ 42