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

Side by Side Diff: chrome_frame/protocol_sink_wrap.cc

Issue 12178023: Merge 179932 - Ensure that ChromeFrame does not interfere with non ChromeFrame requests initiated b… (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1364/src/
Patch Set: Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome_frame/protocol_sink_wrap.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 <htiframe.h> 5 #include <htiframe.h>
6 #include <mshtml.h> 6 #include <mshtml.h>
7 7
8 #include "chrome_frame/protocol_sink_wrap.h" 8 #include "chrome_frame/protocol_sink_wrap.h"
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 20 matching lines...) Expand all
31 bool ProtocolSinkWrap::ignore_xua_ = false; 31 bool ProtocolSinkWrap::ignore_xua_ = false;
32 32
33 static const char kTextHtmlMimeType[] = "text/html"; 33 static const char kTextHtmlMimeType[] = "text/html";
34 const wchar_t kUrlMonDllName[] = L"urlmon.dll"; 34 const wchar_t kUrlMonDllName[] = L"urlmon.dll";
35 35
36 static const int kInternetProtocolStartIndex = 3; 36 static const int kInternetProtocolStartIndex = 3;
37 static const int kInternetProtocolReadIndex = 9; 37 static const int kInternetProtocolReadIndex = 9;
38 static const int kInternetProtocolStartExIndex = 13; 38 static const int kInternetProtocolStartExIndex = 13;
39 static const int kInternetProtocolLockRequestIndex = 11; 39 static const int kInternetProtocolLockRequestIndex = 11;
40 static const int kInternetProtocolUnlockRequestIndex = 12; 40 static const int kInternetProtocolUnlockRequestIndex = 12;
41 static const int kInternetProtocolAbortIndex = 5;
42 static const int kInternetProtocolTerminateIndex = 6;
41 43
42 44
43 // IInternetProtocol/Ex patches. 45 // IInternetProtocol/Ex patches.
44 STDMETHODIMP Hook_Start(InternetProtocol_Start_Fn orig_start, 46 STDMETHODIMP Hook_Start(InternetProtocol_Start_Fn orig_start,
45 IInternetProtocol* protocol, 47 IInternetProtocol* protocol,
46 LPCWSTR url, 48 LPCWSTR url,
47 IInternetProtocolSink* prot_sink, 49 IInternetProtocolSink* prot_sink,
48 IInternetBindInfo* bind_info, 50 IInternetBindInfo* bind_info,
49 DWORD flags, 51 DWORD flags,
50 HANDLE_PTR reserved); 52 HANDLE_PTR reserved);
51 53
52 STDMETHODIMP Hook_StartEx(InternetProtocol_StartEx_Fn orig_start_ex, 54 STDMETHODIMP Hook_StartEx(InternetProtocol_StartEx_Fn orig_start_ex,
53 IInternetProtocolEx* protocol, 55 IInternetProtocolEx* protocol,
54 IUri* uri, 56 IUri* uri,
55 IInternetProtocolSink* prot_sink, 57 IInternetProtocolSink* prot_sink,
56 IInternetBindInfo* bind_info, 58 IInternetBindInfo* bind_info,
57 DWORD flags, 59 DWORD flags,
58 HANDLE_PTR reserved); 60 HANDLE_PTR reserved);
59 61
60 STDMETHODIMP Hook_Read(InternetProtocol_Read_Fn orig_read, 62 STDMETHODIMP Hook_Read(InternetProtocol_Read_Fn orig_read,
61 IInternetProtocol* protocol, 63 IInternetProtocol* protocol,
62 void* buffer, 64 void* buffer,
63 ULONG size, 65 ULONG size,
64 ULONG* size_read); 66 ULONG* size_read);
65 67
66 STDMETHODIMP Hook_LockRequest(InternetProtocol_LockRequest_Fn orig_req, 68 STDMETHODIMP Hook_LockRequest(InternetProtocol_LockRequest_Fn orig_req,
67 IInternetProtocol* protocol, DWORD dwOptions); 69 IInternetProtocol* protocol,
70 DWORD options);
68 71
69 STDMETHODIMP Hook_UnlockRequest(InternetProtocol_UnlockRequest_Fn orig_req, 72 STDMETHODIMP Hook_UnlockRequest(InternetProtocol_UnlockRequest_Fn orig_req,
70 IInternetProtocol* protocol); 73 IInternetProtocol* protocol);
71 74
75 STDMETHODIMP Hook_Abort(InternetProtocol_Abort_Fn orig_req,
76 IInternetProtocol* protocol,
77 HRESULT hr,
78 DWORD options);
79
80 STDMETHODIMP Hook_Terminate(InternetProtocol_Terminate_Fn orig_req,
81 IInternetProtocol* protocol,
82 DWORD options);
83
72 ///////////////////////////////////////////////////////////////////////////// 84 /////////////////////////////////////////////////////////////////////////////
73 BEGIN_VTABLE_PATCHES(CTransaction) 85 BEGIN_VTABLE_PATCHES(CTransaction)
74 VTABLE_PATCH_ENTRY(kInternetProtocolStartIndex, Hook_Start) 86 VTABLE_PATCH_ENTRY(kInternetProtocolStartIndex, Hook_Start)
75 VTABLE_PATCH_ENTRY(kInternetProtocolReadIndex, Hook_Read) 87 VTABLE_PATCH_ENTRY(kInternetProtocolReadIndex, Hook_Read)
76 VTABLE_PATCH_ENTRY(kInternetProtocolLockRequestIndex, Hook_LockRequest) 88 VTABLE_PATCH_ENTRY(kInternetProtocolLockRequestIndex, Hook_LockRequest)
77 VTABLE_PATCH_ENTRY(kInternetProtocolUnlockRequestIndex, Hook_UnlockRequest) 89 VTABLE_PATCH_ENTRY(kInternetProtocolUnlockRequestIndex, Hook_UnlockRequest)
90 VTABLE_PATCH_ENTRY(kInternetProtocolAbortIndex, Hook_Abort)
91 VTABLE_PATCH_ENTRY(kInternetProtocolTerminateIndex, Hook_Terminate)
78 END_VTABLE_PATCHES() 92 END_VTABLE_PATCHES()
79 93
80 BEGIN_VTABLE_PATCHES(CTransaction2) 94 BEGIN_VTABLE_PATCHES(CTransaction2)
81 VTABLE_PATCH_ENTRY(kInternetProtocolStartExIndex, Hook_StartEx) 95 VTABLE_PATCH_ENTRY(kInternetProtocolStartExIndex, Hook_StartEx)
82 END_VTABLE_PATCHES() 96 END_VTABLE_PATCHES()
83 97
84 // 98 //
85 // ProtocolSinkWrap implementation 99 // ProtocolSinkWrap implementation
86 100
87 // Static map initialization 101 // Static map initialization
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 if (size_read) 814 if (size_read)
801 *size_read = 0; 815 *size_read = 0;
802 return S_FALSE; 816 return S_FALSE;
803 } 817 }
804 818
805 hr = prot_data->Read(buffer, size, size_read); 819 hr = prot_data->Read(buffer, size, size_read);
806 return hr; 820 return hr;
807 } 821 }
808 822
809 STDMETHODIMP Hook_LockRequest(InternetProtocol_LockRequest_Fn orig_req, 823 STDMETHODIMP Hook_LockRequest(InternetProtocol_LockRequest_Fn orig_req,
810 IInternetProtocol* protocol, DWORD options) { 824 IInternetProtocol* protocol,
825 DWORD options) {
811 DCHECK(orig_req); 826 DCHECK(orig_req);
812 827
813 scoped_refptr<ProtData> prot_data = ProtData::DataFromProtocol(protocol); 828 scoped_refptr<ProtData> prot_data = ProtData::DataFromProtocol(protocol);
814 if (prot_data && prot_data->is_attach_external_tab_request()) { 829 if (prot_data && prot_data->is_attach_external_tab_request()) {
815 prot_data->AddRef(); 830 prot_data->AddRef();
816 return S_OK; 831 return S_OK;
817 } 832 }
818 833
819 // We are just pass through at this point, avoid false positive crash 834 // We are just pass through at this point, avoid false positive crash
820 // reports. 835 // reports.
(...skipping 10 matching lines...) Expand all
831 prot_data->Release(); 846 prot_data->Release();
832 return S_OK; 847 return S_OK;
833 } 848 }
834 849
835 // We are just pass through at this point, avoid false positive crash 850 // We are just pass through at this point, avoid false positive crash
836 // reports. 851 // reports.
837 ExceptionBarrierReportOnlyModule barrier; 852 ExceptionBarrierReportOnlyModule barrier;
838 return orig_req(protocol); 853 return orig_req(protocol);
839 } 854 }
840 855
856 STDMETHODIMP Hook_Abort(InternetProtocol_Abort_Fn orig_req,
857 IInternetProtocol* protocol,
858 HRESULT hr,
859 DWORD options) {
860 scoped_refptr<ProtData> prot_data = ProtData::DataFromProtocol(protocol);
861 if (prot_data)
862 prot_data->Invalidate();
863
864 // We are just pass through at this point, avoid false positive crash
865 // reports.
866 ExceptionBarrierReportOnlyModule barrier;
867 return orig_req(protocol, hr, options);
868 }
869
870 STDMETHODIMP Hook_Terminate(InternetProtocol_Terminate_Fn orig_req,
871 IInternetProtocol* protocol,
872 DWORD options) {
873 scoped_refptr<ProtData> prot_data = ProtData::DataFromProtocol(protocol);
874 if (prot_data)
875 prot_data->Invalidate();
876
877 // We are just pass through at this point, avoid false positive crash
878 // reports.
879 ExceptionBarrierReportOnlyModule barrier;
880 return orig_req(protocol, options);
881 }
882
841 // Patching / Hooking code. 883 // Patching / Hooking code.
842 class FakeProtocol : public CComObjectRootEx<CComSingleThreadModel>, 884 class FakeProtocol : public CComObjectRootEx<CComSingleThreadModel>,
843 public IInternetProtocol { 885 public IInternetProtocol {
844 public: 886 public:
845 BEGIN_COM_MAP(FakeProtocol) 887 BEGIN_COM_MAP(FakeProtocol)
846 COM_INTERFACE_ENTRY(IInternetProtocol) 888 COM_INTERFACE_ENTRY(IInternetProtocol)
847 COM_INTERFACE_ENTRY(IInternetProtocolRoot) 889 COM_INTERFACE_ENTRY(IInternetProtocolRoot)
848 END_COM_MAP() 890 END_COM_MAP()
849 891
850 STDMETHOD(Start)(LPCWSTR url, IInternetProtocolSink *protocol_sink, 892 STDMETHOD(Start)(LPCWSTR url, IInternetProtocolSink *protocol_sink,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 // Explicit release, otherwise ~CComObjectStackEx will complain about 982 // Explicit release, otherwise ~CComObjectStackEx will complain about
941 // outstanding reference to us, because it runs before ~FakeProtocol 983 // outstanding reference to us, because it runs before ~FakeProtocol
942 prot.transaction_.Release(); 984 prot.transaction_.Release();
943 } 985 }
944 } 986 }
945 987
946 void TransactionHooks::RevertHooks() { 988 void TransactionHooks::RevertHooks() {
947 vtable_patch::UnpatchInterfaceMethods(CTransaction_PatchInfo); 989 vtable_patch::UnpatchInterfaceMethods(CTransaction_PatchInfo);
948 vtable_patch::UnpatchInterfaceMethods(CTransaction2_PatchInfo); 990 vtable_patch::UnpatchInterfaceMethods(CTransaction2_PatchInfo);
949 } 991 }
OLDNEW
« no previous file with comments | « chrome_frame/protocol_sink_wrap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698