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

Side by Side Diff: chrome_frame/protocol_sink_wrap.h

Issue 244002: This fixes a crash in IE8 with ChromeFrame when a new tab was created. ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome_frame/bho.cc ('k') | chrome_frame/protocol_sink_wrap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #ifndef CHROME_FRAME_PROTOCOL_SINK_WRAP_H_ 5 #ifndef CHROME_FRAME_PROTOCOL_SINK_WRAP_H_
6 #define CHROME_FRAME_PROTOCOL_SINK_WRAP_H_ 6 #define CHROME_FRAME_PROTOCOL_SINK_WRAP_H_
7 7
8 #include <exdisp.h> 8 #include <exdisp.h>
9 #include <urlmon.h> 9 #include <urlmon.h>
10 #include <atlbase.h> 10 #include <atlbase.h>
11 #include <atlcom.h> 11 #include <atlcom.h>
12 #include <map> 12 #include <map>
13 #include <string> 13 #include <string>
14 14
15 #include "base/basictypes.h" 15 #include "base/basictypes.h"
16 #include "base/ref_counted.h" 16 #include "base/ref_counted.h"
17 #include "base/scoped_comptr_win.h" 17 #include "base/scoped_comptr_win.h"
18 #include "googleurl/src/gurl.h" 18 #include "googleurl/src/gurl.h"
19 #include "chrome_frame/ie8_types.h" 19 #include "chrome_frame/ie8_types.h"
20 #include "chrome_frame/vtable_patch_manager.h"
20 21
21 // Typedefs for IInternetProtocol and related methods that we patch. 22 // Typedefs for IInternetProtocol and related methods that we patch.
22 typedef HRESULT (STDMETHODCALLTYPE* InternetProtocol_Start_Fn)( 23 typedef HRESULT (STDMETHODCALLTYPE* InternetProtocol_Start_Fn)(
23 IInternetProtocol* this_object, LPCWSTR url, 24 IInternetProtocol* this_object, LPCWSTR url,
24 IInternetProtocolSink* prot_sink, IInternetBindInfo* bind_info, 25 IInternetProtocolSink* prot_sink, IInternetBindInfo* bind_info,
25 DWORD flags, HANDLE_PTR reserved); 26 DWORD flags, HANDLE_PTR reserved);
26 typedef HRESULT (STDMETHODCALLTYPE* InternetProtocol_Read_Fn)( 27 typedef HRESULT (STDMETHODCALLTYPE* InternetProtocol_Read_Fn)(
27 IInternetProtocol* this_object, void* buffer, ULONG size, 28 IInternetProtocol* this_object, void* buffer, ULONG size,
28 ULONG* size_read); 29 ULONG* size_read);
29 typedef HRESULT (STDMETHODCALLTYPE* InternetProtocol_StartEx_Fn)( 30 typedef HRESULT (STDMETHODCALLTYPE* InternetProtocol_StartEx_Fn)(
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 COM_INTERFACE_ENTRY_IF_DELEGATE_SUPPORTS(IUriContainer) 79 COM_INTERFACE_ENTRY_IF_DELEGATE_SUPPORTS(IUriContainer)
79 COM_INTERFACE_ENTRY_FUNC_BLIND(0, CheckOutgoingInterface) 80 COM_INTERFACE_ENTRY_FUNC_BLIND(0, CheckOutgoingInterface)
80 END_COM_MAP() 81 END_COM_MAP()
81 82
82 ProtocolSinkWrap(); 83 ProtocolSinkWrap();
83 virtual ~ProtocolSinkWrap(); 84 virtual ~ProtocolSinkWrap();
84 85
85 bool Initialize(IInternetProtocol* protocol, 86 bool Initialize(IInternetProtocol* protocol,
86 IInternetProtocolSink* original_sink, const wchar_t* url); 87 IInternetProtocolSink* original_sink, const wchar_t* url);
87 88
88 static bool PatchProtocolHandler(const wchar_t* dll, 89 // VTable patches the IInternetProtocol and IIntenetProtocolEx interface.
89 const CLSID& handler_clsid); 90 // Returns true on success.
91 static bool PatchProtocolHandlers();
92
93 // Unpatches the IInternetProtocol and IInternetProtocolEx interfaces.
94 static void UnpatchProtocolHandlers();
90 95
91 // IInternetProtocol/Ex patches. 96 // IInternetProtocol/Ex patches.
92 static HRESULT STDMETHODCALLTYPE OnStart(InternetProtocol_Start_Fn orig_start, 97 static HRESULT STDMETHODCALLTYPE OnStart(InternetProtocol_Start_Fn orig_start,
93 IInternetProtocol* protocol, LPCWSTR url, 98 IInternetProtocol* protocol, LPCWSTR url,
94 IInternetProtocolSink* prot_sink, IInternetBindInfo* bind_info, 99 IInternetProtocolSink* prot_sink, IInternetBindInfo* bind_info,
95 DWORD flags, HANDLE_PTR reserved); 100 DWORD flags, HANDLE_PTR reserved);
96 101
97 static HRESULT STDMETHODCALLTYPE OnStartEx( 102 static HRESULT STDMETHODCALLTYPE OnStartEx(
98 InternetProtocol_StartEx_Fn orig_start_ex, IInternetProtocolEx* protocol, 103 InternetProtocol_StartEx_Fn orig_start_ex, IInternetProtocolEx* protocol,
99 IUri* uri, IInternetProtocolSink* prot_sink, 104 IUri* uri, IInternetProtocolSink* prot_sink,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 HRESULT OnReadImpl(void* buffer, ULONG size, ULONG* size_read, 181 HRESULT OnReadImpl(void* buffer, ULONG size, ULONG* size_read,
177 InternetProtocol_Read_Fn orig_read); 182 InternetProtocol_Read_Fn orig_read);
178 183
179 bool is_undetermined() const { 184 bool is_undetermined() const {
180 return (UNDETERMINED == renderer_type_); 185 return (UNDETERMINED == renderer_type_);
181 } 186 }
182 RendererType renderer_type() const { 187 RendererType renderer_type() const {
183 return renderer_type_; 188 return renderer_type_;
184 } 189 }
185 190
191 // Creates an instance of the specified protocol handler and returns the
192 // IInternetProtocol interface pointer.
193 // Returns S_OK on success.
194 static HRESULT CreateProtocolHandlerInstance(const CLSID& clsid,
195 IInternetProtocol** protocol);
196
197 // Helper function for patching the VTable of the IInternetProtocol
198 // interface. It instantiates the object identified by the protocol_clsid
199 // parameter and patches its VTable.
200 // Returns S_OK on success.
201 static HRESULT PatchProtocolMethods(
202 const CLSID& protocol_clsid,
203 vtable_patch::MethodPatchInfo* protocol_patch_info,
204 vtable_patch::MethodPatchInfo* protocol_ex_patch_info);
205
186 // WARNING: Don't use GURL variables here. Please see 206 // WARNING: Don't use GURL variables here. Please see
187 // http://b/issue?id=2102171 for details. 207 // http://b/issue?id=2102171 for details.
188 208
189 // Remember original sink 209 // Remember original sink
190 CComPtr<IInternetProtocolSink> delegate_; 210 CComPtr<IInternetProtocolSink> delegate_;
191 // Cannot take a reference on the protocol. 211 // Cannot take a reference on the protocol.
192 IInternetProtocol* protocol_; 212 IInternetProtocol* protocol_;
193 RendererType renderer_type_; 213 RendererType renderer_type_;
194 214
195 // Buffer for accumulated data including 1 extra for NULL-terminator 215 // Buffer for accumulated data including 1 extra for NULL-terminator
196 char buffer_[kMaxContentSniffLength + 1]; 216 char buffer_[kMaxContentSniffLength + 1];
197 unsigned long buffer_size_; 217 unsigned long buffer_size_;
198 unsigned long buffer_pos_; 218 unsigned long buffer_pos_;
199 219
200 // Accumulated result 220 // Accumulated result
201 bool is_saved_result_; 221 bool is_saved_result_;
202 HRESULT result_code_; 222 HRESULT result_code_;
203 DWORD result_error_; 223 DWORD result_error_;
204 std::wstring result_text_; 224 std::wstring result_text_;
205 // For tracking re-entrency and preventing duplicate Read()s from 225 // For tracking re-entrency and preventing duplicate Read()s from
206 // distorting the outcome of ReportData. 226 // distorting the outcome of ReportData.
207 int report_data_recursiveness_; 227 int report_data_recursiveness_;
208 228
209 static ProtocolSinkMap sink_map_; 229 static ProtocolSinkMap sink_map_;
210 // TODO(joshia): Replace with Lock 230 // TODO(joshia): Replace with Lock
211 static CComAutoCriticalSection sink_map_lock_; 231 static CComAutoCriticalSection sink_map_lock_;
212 232
213 std::wstring url_; 233 std::wstring url_;
214 234
215 private: 235 private:
216 DISALLOW_COPY_AND_ASSIGN(ProtocolSinkWrap); 236 DISALLOW_COPY_AND_ASSIGN(ProtocolSinkWrap);
217 }; 237 };
218 238
219 239
220 #endif // CHROME_FRAME_PROTOCOL_SINK_WRAP_H_ 240 #endif // CHROME_FRAME_PROTOCOL_SINK_WRAP_H_
221 241
OLDNEW
« no previous file with comments | « chrome_frame/bho.cc ('k') | chrome_frame/protocol_sink_wrap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698