| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } | 197 } |
| 198 } | 198 } |
| 199 DLOG(INFO) << __FUNCTION__ << "Url: " << url_ << | 199 DLOG(INFO) << __FUNCTION__ << "Url: " << url_ << |
| 200 StringPrintf("Renderer type: %s", | 200 StringPrintf("Renderer type: %s", |
| 201 renderer_type_ == CHROME ? "CHROME" : "OTHER"); | 201 renderer_type_ == CHROME ? "CHROME" : "OTHER"); |
| 202 } | 202 } |
| 203 } | 203 } |
| 204 | 204 |
| 205 ///////////////////////////////////////////////////////////////////// | 205 ///////////////////////////////////////////////////////////////////// |
| 206 | 206 |
| 207 BSCBStorageBind::BSCBStorageBind() : clip_format_(CF_NULL) { |
| 208 } |
| 209 |
| 210 BSCBStorageBind::~BSCBStorageBind() { |
| 211 for (std::vector<Progress*>::iterator i = saved_progress_.begin(); |
| 212 i != saved_progress_.end(); i++) { |
| 213 delete (*i); |
| 214 } |
| 215 } |
| 216 |
| 207 HRESULT BSCBStorageBind::Initialize(IMoniker* moniker, IBindCtx* bind_ctx) { | 217 HRESULT BSCBStorageBind::Initialize(IMoniker* moniker, IBindCtx* bind_ctx) { |
| 208 DLOG(INFO) << __FUNCTION__ << me() << StringPrintf(" tid=%i", | 218 DLOG(INFO) << __FUNCTION__ << me() << StringPrintf(" tid=%i", |
| 209 PlatformThread::CurrentId()); | 219 PlatformThread::CurrentId()); |
| 210 | 220 |
| 211 std::wstring url = GetActualUrlFromMoniker(moniker, bind_ctx, | 221 std::wstring url = GetActualUrlFromMoniker(moniker, bind_ctx, |
| 212 std::wstring()); | 222 std::wstring()); |
| 213 HRESULT hr = data_sniffer_.InitializeCache(url); | 223 HRESULT hr = data_sniffer_.InitializeCache(url); |
| 214 if (FAILED(hr)) | 224 if (FAILED(hr)) |
| 215 return hr; | 225 return hr; |
| 216 | 226 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 243 // chrome frame | 253 // chrome frame |
| 244 if (status_code == BINDSTATUS_REDIRECTING) { | 254 if (status_code == BINDSTATUS_REDIRECTING) { |
| 245 scoped_refptr<BindContextInfo> info = | 255 scoped_refptr<BindContextInfo> info = |
| 246 BindContextInfo::FromBindContext(bind_ctx_); | 256 BindContextInfo::FromBindContext(bind_ctx_); |
| 247 DCHECK(info); | 257 DCHECK(info); |
| 248 if (info) | 258 if (info) |
| 249 info->set_url(status_text); | 259 info->set_url(status_text); |
| 250 } | 260 } |
| 251 | 261 |
| 252 if (ShouldCacheProgress(status_code)) { | 262 if (ShouldCacheProgress(status_code)) { |
| 253 Progress new_progress = { progress, progress_max, status_code, | 263 saved_progress_.push_back(new Progress(progress, progress_max, status_code, |
| 254 status_text ? status_text : std::wstring() }; | 264 status_text)); |
| 255 saved_progress_.push_back(new_progress); | |
| 256 } else { | 265 } else { |
| 257 hr = CallbackImpl::OnProgress(progress, progress_max, status_code, | 266 hr = CallbackImpl::OnProgress(progress, progress_max, status_code, |
| 258 status_text); | 267 status_text); |
| 259 } | 268 } |
| 260 | 269 |
| 261 return hr; | 270 return hr; |
| 262 } | 271 } |
| 263 | 272 |
| 264 // Refer to urlmon_moniker.h for explanation of how things work. | 273 // Refer to urlmon_moniker.h for explanation of how things work. |
| 265 STDMETHODIMP BSCBStorageBind::OnDataAvailable(DWORD flags, DWORD size, | 274 STDMETHODIMP BSCBStorageBind::OnDataAvailable(DWORD flags, DWORD size, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 if (data_sniffer_.is_chrome()) { | 349 if (data_sniffer_.is_chrome()) { |
| 341 // Remember clip format. If we are switching to chrome, then in order | 350 // Remember clip format. If we are switching to chrome, then in order |
| 342 // to make mshtml return INET_E_TERMINATED_BIND and reissue navigation | 351 // to make mshtml return INET_E_TERMINATED_BIND and reissue navigation |
| 343 // with the same bind context, we have to return a mime type that is | 352 // with the same bind context, we have to return a mime type that is |
| 344 // special cased by mshtml. | 353 // special cased by mshtml. |
| 345 static const CLIPFORMAT kMagicClipFormat = | 354 static const CLIPFORMAT kMagicClipFormat = |
| 346 RegisterClipboardFormat(CFSTR_MIME_MPEG); | 355 RegisterClipboardFormat(CFSTR_MIME_MPEG); |
| 347 clip_format_ = kMagicClipFormat; | 356 clip_format_ = kMagicClipFormat; |
| 348 } else { | 357 } else { |
| 349 if (!saved_progress_.empty()) { | 358 if (!saved_progress_.empty()) { |
| 350 for (std::vector<Progress>::iterator i = saved_progress_.begin(); | 359 for (std::vector<Progress*>::iterator i = saved_progress_.begin(); |
| 351 i != saved_progress_.end(); i++) { | 360 i != saved_progress_.end(); i++) { |
| 352 const wchar_t* status_text = i->status_text_.empty() ? | 361 Progress* p = (*i); |
| 353 NULL : i->status_text_.c_str(); | 362 CallbackImpl::OnProgress(p->progress(), p->progress_max(), |
| 354 CallbackImpl::OnProgress(i->progress_, i->progress_max_, | 363 p->status_code(), p->status_text()); |
| 355 i->status_code_, status_text); | 364 delete p; |
| 356 } | 365 } |
| 357 saved_progress_.clear(); | 366 saved_progress_.clear(); |
| 358 } | 367 } |
| 359 } | 368 } |
| 360 | 369 |
| 361 if (data_sniffer_.is_cache_valid()) { | 370 if (data_sniffer_.is_cache_valid()) { |
| 362 if (data_sniffer_.is_chrome()) { | 371 if (data_sniffer_.is_chrome()) { |
| 363 scoped_refptr<BindContextInfo> info = | 372 scoped_refptr<BindContextInfo> info = |
| 364 BindContextInfo::FromBindContext(bind_ctx_); | 373 BindContextInfo::FromBindContext(bind_ctx_); |
| 365 DCHECK(info); | 374 DCHECK(info); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 case BINDSTATUS_SERVER_MIMETYPEAVAILABLE: | 419 case BINDSTATUS_SERVER_MIMETYPEAVAILABLE: |
| 411 return true; | 420 return true; |
| 412 default: | 421 default: |
| 413 break; | 422 break; |
| 414 } | 423 } |
| 415 } | 424 } |
| 416 | 425 |
| 417 return false; | 426 return false; |
| 418 } | 427 } |
| 419 | 428 |
| OLD | NEW |