| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome_frame/urlmon_moniker.h" | 5 #include "chrome_frame/urlmon_moniker.h" |
| 6 | 6 |
| 7 #include <shlguid.h> | 7 #include <shlguid.h> |
| 8 | 8 |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "chrome_frame/bho.h" | 10 #include "chrome_frame/bho.h" |
| 11 #include "chrome_frame/bind_context_info.h" | 11 #include "chrome_frame/bind_context_info.h" |
| 12 #include "chrome_frame/exception_barrier.h" |
| 12 #include "chrome_frame/chrome_active_document.h" | 13 #include "chrome_frame/chrome_active_document.h" |
| 13 #include "chrome_frame/urlmon_bind_status_callback.h" | 14 #include "chrome_frame/urlmon_bind_status_callback.h" |
| 14 #include "chrome_frame/utils.h" | 15 #include "chrome_frame/utils.h" |
| 15 #include "chrome_frame/vtable_patch_manager.h" | 16 #include "chrome_frame/vtable_patch_manager.h" |
| 16 #include "net/http/http_util.h" | 17 #include "net/http/http_util.h" |
| 17 | 18 |
| 18 static const int kMonikerBindToObject = 8; | 19 static const int kMonikerBindToObject = 8; |
| 19 static const int kMonikerBindToStorage = kMonikerBindToObject + 1; | 20 static const int kMonikerBindToStorage = kMonikerBindToObject + 1; |
| 20 | 21 |
| 21 base::LazyInstance<base::ThreadLocalPointer<NavigationManager> > | 22 base::LazyInstance<base::ThreadLocalPointer<NavigationManager> > |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 return should_wrap; | 155 return should_wrap; |
| 155 } | 156 } |
| 156 | 157 |
| 157 // static | 158 // static |
| 158 HRESULT MonikerPatch::BindToObject(IMoniker_BindToObject_Fn original, | 159 HRESULT MonikerPatch::BindToObject(IMoniker_BindToObject_Fn original, |
| 159 IMoniker* me, IBindCtx* bind_ctx, | 160 IMoniker* me, IBindCtx* bind_ctx, |
| 160 IMoniker* to_left, REFIID iid, void** obj) { | 161 IMoniker* to_left, REFIID iid, void** obj) { |
| 161 DLOG(INFO) << __FUNCTION__; | 162 DLOG(INFO) << __FUNCTION__; |
| 162 DCHECK(to_left == NULL); | 163 DCHECK(to_left == NULL); |
| 163 | 164 |
| 165 ExceptionBarrier barrier; |
| 166 |
| 164 HRESULT hr = S_OK; | 167 HRESULT hr = S_OK; |
| 165 // Bind context is marked for switch when we sniff data in BSCBStorageBind | 168 // Bind context is marked for switch when we sniff data in BSCBStorageBind |
| 166 // and determine that the renderer to be used is Chrome. | 169 // and determine that the renderer to be used is Chrome. |
| 167 scoped_refptr<BindContextInfo> info = | 170 scoped_refptr<BindContextInfo> info = |
| 168 BindContextInfo::FromBindContext(bind_ctx); | 171 BindContextInfo::FromBindContext(bind_ctx); |
| 169 DCHECK(info); | 172 DCHECK(info); |
| 170 if (info) { | 173 if (info) { |
| 171 if (info->is_switching()) { | 174 if (info->is_switching()) { |
| 172 // We could implement the BindToObject ourselves here but instead we | 175 // We could implement the BindToObject ourselves here but instead we |
| 173 // simply register Chrome Frame ActiveDoc as a handler for 'text/html' | 176 // simply register Chrome Frame ActiveDoc as a handler for 'text/html' |
| (...skipping 20 matching lines...) Expand all Loading... |
| 194 IMoniker* to_left, REFIID iid, void** obj) { | 197 IMoniker* to_left, REFIID iid, void** obj) { |
| 195 DCHECK(to_left == NULL); | 198 DCHECK(to_left == NULL); |
| 196 | 199 |
| 197 HRESULT hr = S_OK; | 200 HRESULT hr = S_OK; |
| 198 CComObject<BSCBStorageBind>* callback = NULL; | 201 CComObject<BSCBStorageBind>* callback = NULL; |
| 199 if (ShouldWrapCallback(me, iid, bind_ctx)) { | 202 if (ShouldWrapCallback(me, iid, bind_ctx)) { |
| 200 hr = CComObject<BSCBStorageBind>::CreateInstance(&callback); | 203 hr = CComObject<BSCBStorageBind>::CreateInstance(&callback); |
| 201 callback->AddRef(); | 204 callback->AddRef(); |
| 202 hr = callback->Initialize(me, bind_ctx); | 205 hr = callback->Initialize(me, bind_ctx); |
| 203 DCHECK(SUCCEEDED(hr)); | 206 DCHECK(SUCCEEDED(hr)); |
| 207 |
| 208 // Call the original back under an exception barrier only if we should |
| 209 // wrap the callback. |
| 210 ExceptionBarrier barrier; |
| 211 hr = original(me, bind_ctx, to_left, iid, obj); |
| 212 } else { |
| 213 hr = original(me, bind_ctx, to_left, iid, obj); |
| 204 } | 214 } |
| 205 | 215 |
| 206 hr = original(me, bind_ctx, to_left, iid, obj); | |
| 207 | |
| 208 // If the binding terminates before the data could be played back | 216 // If the binding terminates before the data could be played back |
| 209 // now is the chance. Sometimes OnStopBinding happens after this returns | 217 // now is the chance. Sometimes OnStopBinding happens after this returns |
| 210 // and then it's too late. | 218 // and then it's too late. |
| 211 if ((S_OK == hr) && callback) | 219 if ((S_OK == hr) && callback) |
| 212 callback->MayPlayBack(BSCF_LASTDATANOTIFICATION); | 220 callback->MayPlayBack(BSCF_LASTDATANOTIFICATION); |
| 213 return hr; | 221 return hr; |
| 214 } | 222 } |
| 215 | 223 |
| OLD | NEW |