| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 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 CHROME_FRAME_BIND_STATUS_CALLBACK_IMPL_H_ | |
| 6 #define CHROME_FRAME_BIND_STATUS_CALLBACK_IMPL_H_ | |
| 7 | |
| 8 #include <atlbase.h> | |
| 9 #include <atlcom.h> | |
| 10 #include <string> | |
| 11 #include <urlmon.h> | |
| 12 | |
| 13 #include "base/win/scoped_comptr.h" | |
| 14 #include "chrome_frame/utils.h" | |
| 15 | |
| 16 // A generic base class for IBindStatus callback implementation. | |
| 17 // If initialized with delegate, it will hand over all the calls | |
| 18 // to the delegate. This can also be used as a base class to | |
| 19 // provide the base implementation by not providing any delegate. | |
| 20 class BSCBImpl | |
| 21 : public CComObjectRootEx<CComMultiThreadModel>, | |
| 22 public IBindStatusCallbackEx, | |
| 23 public IHttpNegotiate3, | |
| 24 public IServiceProvider { | |
| 25 public: | |
| 26 BSCBImpl(); | |
| 27 ~BSCBImpl(); | |
| 28 | |
| 29 BEGIN_COM_MAP(BSCBImpl) | |
| 30 COM_INTERFACE_ENTRY(IBindStatusCallback) | |
| 31 COM_INTERFACE_ENTRY(IHttpNegotiate) | |
| 32 COM_INTERFACE_ENTRY_IF_DELEGATE_SUPPORTS(IBindStatusCallbackEx) | |
| 33 COM_INTERFACE_ENTRY_IF_DELEGATE_SUPPORTS(IHttpNegotiate2) | |
| 34 COM_INTERFACE_ENTRY_IF_DELEGATE_SUPPORTS(IHttpNegotiate3) | |
| 35 COM_INTERFACE_ENTRY_IF_DELEGATE_SUPPORTS(IServiceProvider) | |
| 36 COM_INTERFACE_ENTRY_FUNC_BLIND(0, DelegateQI) | |
| 37 END_COM_MAP() | |
| 38 | |
| 39 static STDMETHODIMP DelegateQI(void* obj, REFIID iid, void** ret, | |
| 40 DWORD cookie); | |
| 41 | |
| 42 void Initialize(IBindStatusCallback* original); | |
| 43 HRESULT AttachToBind(IBindCtx* original); | |
| 44 HRESULT ReleaseBind(); | |
| 45 | |
| 46 // For the COM_INTERFACE_ENTRY_IF_DELEGATE_SUPPORTS macro. | |
| 47 IBindStatusCallback* delegate() const { | |
| 48 return delegate_; | |
| 49 } | |
| 50 | |
| 51 IBindCtx* bind_ctx() const { | |
| 52 return bind_ctx_; | |
| 53 } | |
| 54 | |
| 55 // IServiceProvider | |
| 56 STDMETHOD(QueryService)(REFGUID service, REFIID iid, void** object); | |
| 57 | |
| 58 // IBindStatusCallback | |
| 59 STDMETHOD(OnStartBinding)(DWORD reserved, IBinding* binding); | |
| 60 STDMETHOD(GetPriority)(LONG* priority); | |
| 61 STDMETHOD(OnLowResource)(DWORD reserved); | |
| 62 STDMETHOD(OnProgress)(ULONG progress, ULONG progress_max, ULONG status_code, | |
| 63 LPCWSTR status_text); | |
| 64 STDMETHOD(OnStopBinding)(HRESULT hresult, LPCWSTR error); | |
| 65 STDMETHOD(GetBindInfo)(DWORD* bindf, BINDINFO* bind_info); | |
| 66 STDMETHOD(OnDataAvailable)(DWORD bscf, DWORD size, FORMATETC* format_etc, | |
| 67 STGMEDIUM* stgmed); | |
| 68 STDMETHOD(OnObjectAvailable)(REFIID iid, IUnknown* unk); | |
| 69 | |
| 70 // IBindStatusCallbackEx | |
| 71 STDMETHOD(GetBindInfoEx)(DWORD* bindf, BINDINFO* bind_info, DWORD* bindf2, | |
| 72 DWORD* reserved); | |
| 73 | |
| 74 // IHttpNegotiate | |
| 75 STDMETHOD(BeginningTransaction)(LPCWSTR url, LPCWSTR headers, DWORD reserved, | |
| 76 LPWSTR* additional_headers); | |
| 77 STDMETHOD(OnResponse)(DWORD response_code, LPCWSTR response_headers, | |
| 78 LPCWSTR request_headers, LPWSTR* additional_headers); | |
| 79 | |
| 80 // IHttpNegotiate2 | |
| 81 STDMETHOD(GetRootSecurityId)(BYTE* security_id, DWORD* security_id_size, | |
| 82 DWORD_PTR reserved); | |
| 83 | |
| 84 // IHttpNegotiate3 | |
| 85 STDMETHOD(GetSerializedClientCertContext)(BYTE** cert, DWORD* cert_size); | |
| 86 | |
| 87 protected: | |
| 88 // used for logging. | |
| 89 std::string me(); | |
| 90 | |
| 91 base::win::ScopedComPtr<IBindStatusCallback> delegate_; | |
| 92 base::win::ScopedComPtr<IBindCtx> bind_ctx_; | |
| 93 | |
| 94 private: | |
| 95 DISALLOW_COPY_AND_ASSIGN(BSCBImpl); | |
| 96 }; | |
| 97 | |
| 98 #endif // CHROME_FRAME_BIND_STATUS_CALLBACK_IMPL_H_ | |
| OLD | NEW |