| 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_bind_status_callback.h" | 5 #include "chrome_frame/urlmon_bind_status_callback.h" |
| 6 | 6 |
| 7 #include <mshtml.h> | 7 #include <mshtml.h> |
| 8 #include <shlguid.h> | 8 #include <shlguid.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // Note that document_contents_ may have NULL characters in it. While | 189 // Note that document_contents_ may have NULL characters in it. While |
| 190 // browsers may handle this properly, we don't and will stop scanning | 190 // browsers may handle this properly, we don't and will stop scanning |
| 191 // for the XUACompat content value if we encounter one. | 191 // for the XUACompat content value if we encounter one. |
| 192 std::wstring xua_compat_content; | 192 std::wstring xua_compat_content; |
| 193 UtilGetXUACompatContentValue(html_contents, &xua_compat_content); | 193 UtilGetXUACompatContentValue(html_contents, &xua_compat_content); |
| 194 if (StrStrI(xua_compat_content.c_str(), kChromeContentPrefix)) { | 194 if (StrStrI(xua_compat_content.c_str(), kChromeContentPrefix)) { |
| 195 renderer_type_ = CHROME; | 195 renderer_type_ = CHROME; |
| 196 } | 196 } |
| 197 } | 197 } |
| 198 } | 198 } |
| 199 DLOG(INFO) << __FUNCTION__ << "Url: " << url_ << | 199 DVLOG(1) << __FUNCTION__ << "Url: " << url_ << base::StringPrintf( |
| 200 base::StringPrintf("Renderer type: %s", | 200 "Renderer type: %s", renderer_type_ == CHROME ? "CHROME" : "OTHER"); |
| 201 renderer_type_ == CHROME ? "CHROME" : "OTHER"); | |
| 202 } | 201 } |
| 203 } | 202 } |
| 204 | 203 |
| 205 ///////////////////////////////////////////////////////////////////// | 204 ///////////////////////////////////////////////////////////////////// |
| 206 | 205 |
| 207 BSCBStorageBind::BSCBStorageBind() : clip_format_(CF_NULL) { | 206 BSCBStorageBind::BSCBStorageBind() : clip_format_(CF_NULL) { |
| 208 } | 207 } |
| 209 | 208 |
| 210 BSCBStorageBind::~BSCBStorageBind() { | 209 BSCBStorageBind::~BSCBStorageBind() { |
| 211 std::for_each(saved_progress_.begin(), saved_progress_.end(), | 210 std::for_each(saved_progress_.begin(), saved_progress_.end(), |
| 212 utils::DeleteObject()); | 211 utils::DeleteObject()); |
| 213 } | 212 } |
| 214 | 213 |
| 215 HRESULT BSCBStorageBind::Initialize(IMoniker* moniker, IBindCtx* bind_ctx) { | 214 HRESULT BSCBStorageBind::Initialize(IMoniker* moniker, IBindCtx* bind_ctx) { |
| 216 DLOG(INFO) << __FUNCTION__ << me() << base::StringPrintf(" tid=%i", | 215 DVLOG(1) << __FUNCTION__ << me() |
| 217 PlatformThread::CurrentId()); | 216 << base::StringPrintf(" tid=%i", PlatformThread::CurrentId()); |
| 218 | 217 |
| 219 std::wstring url = GetActualUrlFromMoniker(moniker, bind_ctx, | 218 std::wstring url = GetActualUrlFromMoniker(moniker, bind_ctx, |
| 220 std::wstring()); | 219 std::wstring()); |
| 221 HRESULT hr = data_sniffer_.InitializeCache(url); | 220 HRESULT hr = data_sniffer_.InitializeCache(url); |
| 222 if (FAILED(hr)) | 221 if (FAILED(hr)) |
| 223 return hr; | 222 return hr; |
| 224 | 223 |
| 225 hr = AttachToBind(bind_ctx); | 224 hr = AttachToBind(bind_ctx); |
| 226 if (FAILED(hr)) { | 225 if (FAILED(hr)) { |
| 227 NOTREACHED() << __FUNCTION__ << me() << "AttachToBind error: " << hr; | 226 NOTREACHED() << __FUNCTION__ << me() << "AttachToBind error: " << hr; |
| 228 return hr; | 227 return hr; |
| 229 } | 228 } |
| 230 | 229 |
| 231 if (!delegate()) { | 230 if (!delegate()) { |
| 232 NOTREACHED() << __FUNCTION__ << me() << "No existing callback: " << hr; | 231 NOTREACHED() << __FUNCTION__ << me() << "No existing callback: " << hr; |
| 233 return E_FAIL; | 232 return E_FAIL; |
| 234 } | 233 } |
| 235 | 234 |
| 236 return hr; | 235 return hr; |
| 237 } | 236 } |
| 238 | 237 |
| 239 STDMETHODIMP BSCBStorageBind::OnProgress(ULONG progress, ULONG progress_max, | 238 STDMETHODIMP BSCBStorageBind::OnProgress(ULONG progress, ULONG progress_max, |
| 240 ULONG status_code, LPCWSTR status_text) { | 239 ULONG status_code, LPCWSTR status_text) { |
| 241 DLOG(INFO) << __FUNCTION__ << me() << base::StringPrintf( | 240 DVLOG(1) << __FUNCTION__ << me() |
| 242 " status=%i tid=%i %ls", status_code, PlatformThread::CurrentId(), | 241 << base::StringPrintf(" status=%i tid=%i %ls", status_code, |
| 243 status_text); | 242 PlatformThread::CurrentId(), status_text); |
| 244 // Report all crashes in the exception handler if we wrap the callback. | 243 // Report all crashes in the exception handler if we wrap the callback. |
| 245 // Note that this avoids having the VEH report a crash if an SEH earlier in | 244 // Note that this avoids having the VEH report a crash if an SEH earlier in |
| 246 // the chain handles the exception. | 245 // the chain handles the exception. |
| 247 ExceptionBarrier barrier; | 246 ExceptionBarrier barrier; |
| 248 | 247 |
| 249 HRESULT hr = S_OK; | 248 HRESULT hr = S_OK; |
| 250 | 249 |
| 251 // Remember the last redirected URL in case we get switched into | 250 // Remember the last redirected URL in case we get switched into |
| 252 // chrome frame | 251 // chrome frame |
| 253 if (status_code == BINDSTATUS_REDIRECTING) { | 252 if (status_code == BINDSTATUS_REDIRECTING) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 266 status_text); | 265 status_text); |
| 267 } | 266 } |
| 268 | 267 |
| 269 return hr; | 268 return hr; |
| 270 } | 269 } |
| 271 | 270 |
| 272 // Refer to urlmon_moniker.h for explanation of how things work. | 271 // Refer to urlmon_moniker.h for explanation of how things work. |
| 273 STDMETHODIMP BSCBStorageBind::OnDataAvailable(DWORD flags, DWORD size, | 272 STDMETHODIMP BSCBStorageBind::OnDataAvailable(DWORD flags, DWORD size, |
| 274 FORMATETC* format_etc, | 273 FORMATETC* format_etc, |
| 275 STGMEDIUM* stgmed) { | 274 STGMEDIUM* stgmed) { |
| 276 DLOG(INFO) << __FUNCTION__ << base::StringPrintf(" tid=%i", | 275 DVLOG(1) << __FUNCTION__ |
| 277 PlatformThread::CurrentId()); | 276 << base::StringPrintf(" tid=%i", PlatformThread::CurrentId()); |
| 278 // Report all crashes in the exception handler if we wrap the callback. | 277 // Report all crashes in the exception handler if we wrap the callback. |
| 279 // Note that this avoids having the VEH report a crash if an SEH earlier in | 278 // Note that this avoids having the VEH report a crash if an SEH earlier in |
| 280 // the chain handles the exception. | 279 // the chain handles the exception. |
| 281 ExceptionBarrier barrier; | 280 ExceptionBarrier barrier; |
| 282 // Do not touch anything other than text/html. | 281 // Do not touch anything other than text/html. |
| 283 bool is_interesting = (format_etc && stgmed && stgmed->pstm && | 282 bool is_interesting = (format_etc && stgmed && stgmed->pstm && |
| 284 stgmed->tymed == TYMED_ISTREAM && | 283 stgmed->tymed == TYMED_ISTREAM && |
| 285 IsTextHtmlClipFormat(format_etc->cfFormat)); | 284 IsTextHtmlClipFormat(format_etc->cfFormat)); |
| 286 | 285 |
| 287 if (!is_interesting) { | 286 if (!is_interesting) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 309 if (data_sniffer_.is_cache_valid()) { | 308 if (data_sniffer_.is_cache_valid()) { |
| 310 hr = MayPlayBack(flags); | 309 hr = MayPlayBack(flags); |
| 311 DCHECK(!data_sniffer_.is_cache_valid()); | 310 DCHECK(!data_sniffer_.is_cache_valid()); |
| 312 } else { | 311 } else { |
| 313 hr = CallbackImpl::OnDataAvailable(flags, size, format_etc, stgmed); | 312 hr = CallbackImpl::OnDataAvailable(flags, size, format_etc, stgmed); |
| 314 } | 313 } |
| 315 return hr; | 314 return hr; |
| 316 } | 315 } |
| 317 | 316 |
| 318 STDMETHODIMP BSCBStorageBind::OnStopBinding(HRESULT hresult, LPCWSTR error) { | 317 STDMETHODIMP BSCBStorageBind::OnStopBinding(HRESULT hresult, LPCWSTR error) { |
| 319 DLOG(INFO) << __FUNCTION__ << base::StringPrintf(" tid=%i", | 318 DVLOG(1) << __FUNCTION__ |
| 320 PlatformThread::CurrentId()); | 319 << base::StringPrintf(" tid=%i", PlatformThread::CurrentId()); |
| 321 // Report all crashes in the exception handler if we wrap the callback. | 320 // Report all crashes in the exception handler if we wrap the callback. |
| 322 // Note that this avoids having the VEH report a crash if an SEH earlier in | 321 // Note that this avoids having the VEH report a crash if an SEH earlier in |
| 323 // the chain handles the exception. | 322 // the chain handles the exception. |
| 324 ExceptionBarrier barrier; | 323 ExceptionBarrier barrier; |
| 325 | 324 |
| 326 HRESULT hr = MayPlayBack(BSCF_LASTDATANOTIFICATION); | 325 HRESULT hr = MayPlayBack(BSCF_LASTDATANOTIFICATION); |
| 327 hr = CallbackImpl::OnStopBinding(hresult, error); | 326 hr = CallbackImpl::OnStopBinding(hresult, error); |
| 328 ReleaseBind(); | 327 ReleaseBind(); |
| 329 return hr; | 328 return hr; |
| 330 } | 329 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 case BINDSTATUS_SERVER_MIMETYPEAVAILABLE: | 422 case BINDSTATUS_SERVER_MIMETYPEAVAILABLE: |
| 424 return true; | 423 return true; |
| 425 default: | 424 default: |
| 426 break; | 425 break; |
| 427 } | 426 } |
| 428 } | 427 } |
| 429 | 428 |
| 430 return false; | 429 return false; |
| 431 } | 430 } |
| 432 | 431 |
| OLD | NEW |