| 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_url_request.h" | 5 #include "chrome_frame/urlmon_url_request.h" |
| 6 | 6 |
| 7 #include <wininet.h> | 7 #include <wininet.h> |
| 8 #include <urlmon.h> | 8 #include <urlmon.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 UrlmonUrlRequest::UrlmonUrlRequest() | 26 UrlmonUrlRequest::UrlmonUrlRequest() |
| 27 : pending_read_size_(0), | 27 : pending_read_size_(0), |
| 28 headers_received_(false), | 28 headers_received_(false), |
| 29 calling_delegate_(0), | 29 calling_delegate_(0), |
| 30 thread_(NULL), | 30 thread_(NULL), |
| 31 parent_window_(NULL), | 31 parent_window_(NULL), |
| 32 privileged_mode_(false), | 32 privileged_mode_(false), |
| 33 pending_(false), | 33 pending_(false), |
| 34 is_expecting_download_(true), | 34 is_expecting_download_(true), |
| 35 cleanup_transaction_(false) { | 35 cleanup_transaction_(false) { |
| 36 DLOG(INFO) << __FUNCTION__ << me(); | 36 DVLOG(1) << __FUNCTION__ << me(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 UrlmonUrlRequest::~UrlmonUrlRequest() { | 39 UrlmonUrlRequest::~UrlmonUrlRequest() { |
| 40 DLOG(INFO) << __FUNCTION__ << me(); | 40 DVLOG(1) << __FUNCTION__ << me(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 std::string UrlmonUrlRequest::me() const { | 43 std::string UrlmonUrlRequest::me() const { |
| 44 return base::StringPrintf(" id: %i Obj: %X ", id(), this); | 44 return base::StringPrintf(" id: %i Obj: %X ", id(), this); |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool UrlmonUrlRequest::Start() { | 47 bool UrlmonUrlRequest::Start() { |
| 48 DLOG(INFO) << __FUNCTION__ << me() << url(); | 48 DVLOG(1) << __FUNCTION__ << me() << url(); |
| 49 DCHECK(thread_ == 0 || thread_ == PlatformThread::CurrentId()); | 49 DCHECK(thread_ == 0 || thread_ == PlatformThread::CurrentId()); |
| 50 thread_ = PlatformThread::CurrentId(); | 50 thread_ = PlatformThread::CurrentId(); |
| 51 status_.Start(); | 51 status_.Start(); |
| 52 // The UrlmonUrlRequest instance can get destroyed in the context of | 52 // The UrlmonUrlRequest instance can get destroyed in the context of |
| 53 // StartAsyncDownload if BindToStorage finishes synchronously with an error. | 53 // StartAsyncDownload if BindToStorage finishes synchronously with an error. |
| 54 // Grab a reference to protect against this. | 54 // Grab a reference to protect against this. |
| 55 scoped_refptr<UrlmonUrlRequest> ref(this); | 55 scoped_refptr<UrlmonUrlRequest> ref(this); |
| 56 HRESULT hr = StartAsyncDownload(); | 56 HRESULT hr = StartAsyncDownload(); |
| 57 if (FAILED(hr) && status_.get_state() != UrlmonUrlRequest::Status::DONE) { | 57 if (FAILED(hr) && status_.get_state() != UrlmonUrlRequest::Status::DONE) { |
| 58 status_.Done(); | 58 status_.Done(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 87 status_.Cancel(); | 87 status_.Cancel(); |
| 88 NotifyDelegateAndDie(); | 88 NotifyDelegateAndDie(); |
| 89 break; | 89 break; |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool UrlmonUrlRequest::Read(int bytes_to_read) { | 93 bool UrlmonUrlRequest::Read(int bytes_to_read) { |
| 94 DCHECK_EQ(thread_, PlatformThread::CurrentId()); | 94 DCHECK_EQ(thread_, PlatformThread::CurrentId()); |
| 95 DCHECK_GE(bytes_to_read, 0); | 95 DCHECK_GE(bytes_to_read, 0); |
| 96 DCHECK_EQ(0, calling_delegate_); | 96 DCHECK_EQ(0, calling_delegate_); |
| 97 DLOG(INFO) << __FUNCTION__ << me(); | 97 DVLOG(1) << __FUNCTION__ << me(); |
| 98 | 98 |
| 99 is_expecting_download_ = false; | 99 is_expecting_download_ = false; |
| 100 | 100 |
| 101 // Re-entrancy check. Thou shall not call Read() while process OnReadComplete! | 101 // Re-entrancy check. Thou shall not call Read() while process OnReadComplete! |
| 102 DCHECK_EQ(0u, pending_read_size_); | 102 DCHECK_EQ(0u, pending_read_size_); |
| 103 if (pending_read_size_ != 0) | 103 if (pending_read_size_ != 0) |
| 104 return false; | 104 return false; |
| 105 | 105 |
| 106 DCHECK((status_.get_state() != Status::DONE) == (binding_ != NULL)); | 106 DCHECK((status_.get_state() != Status::DONE) == (binding_ != NULL)); |
| 107 if (status_.get_state() == Status::ABORTING) | 107 if (status_.get_state() == Status::ABORTING) |
| 108 return true; | 108 return true; |
| 109 | 109 |
| 110 // Send data if available. | 110 // Send data if available. |
| 111 size_t bytes_copied = 0; | 111 size_t bytes_copied = 0; |
| 112 if ((bytes_copied = SendDataToDelegate(bytes_to_read))) { | 112 if ((bytes_copied = SendDataToDelegate(bytes_to_read))) { |
| 113 DLOG(INFO) << __FUNCTION__ << me() << " bytes read: " << bytes_copied; | 113 DVLOG(1) << __FUNCTION__ << me() << " bytes read: " << bytes_copied; |
| 114 return true; | 114 return true; |
| 115 } | 115 } |
| 116 | 116 |
| 117 if (status_.get_state() == Status::WORKING) { | 117 if (status_.get_state() == Status::WORKING) { |
| 118 DLOG(INFO) << __FUNCTION__ << me() << " pending: " << bytes_to_read; | 118 DVLOG(1) << __FUNCTION__ << me() << " pending: " << bytes_to_read; |
| 119 pending_read_size_ = bytes_to_read; | 119 pending_read_size_ = bytes_to_read; |
| 120 } else { | 120 } else { |
| 121 DLOG(INFO) << __FUNCTION__ << me() << " Response finished."; | 121 DVLOG(1) << __FUNCTION__ << me() << " Response finished."; |
| 122 NotifyDelegateAndDie(); | 122 NotifyDelegateAndDie(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 return true; | 125 return true; |
| 126 } | 126 } |
| 127 | 127 |
| 128 HRESULT UrlmonUrlRequest::InitPending(const GURL& url, IMoniker* moniker, | 128 HRESULT UrlmonUrlRequest::InitPending(const GURL& url, IMoniker* moniker, |
| 129 IBindCtx* bind_context, | 129 IBindCtx* bind_context, |
| 130 bool enable_frame_busting, | 130 bool enable_frame_busting, |
| 131 bool privileged_mode, | 131 bool privileged_mode, |
| 132 HWND notification_window, | 132 HWND notification_window, |
| 133 IStream* cache) { | 133 IStream* cache) { |
| 134 DLOG(INFO) << __FUNCTION__ << me() << url.spec(); | 134 DVLOG(1) << __FUNCTION__ << me() << url.spec(); |
| 135 DCHECK(bind_context_ == NULL); | 135 DCHECK(bind_context_ == NULL); |
| 136 DCHECK(moniker_ == NULL); | 136 DCHECK(moniker_ == NULL); |
| 137 DCHECK(cache_ == NULL); | 137 DCHECK(cache_ == NULL); |
| 138 DCHECK(thread_ == 0 || thread_ == PlatformThread::CurrentId()); | 138 DCHECK(thread_ == 0 || thread_ == PlatformThread::CurrentId()); |
| 139 thread_ = PlatformThread::CurrentId(); | 139 thread_ = PlatformThread::CurrentId(); |
| 140 bind_context_ = bind_context; | 140 bind_context_ = bind_context; |
| 141 moniker_ = moniker; | 141 moniker_ = moniker; |
| 142 enable_frame_busting_ = enable_frame_busting; | 142 enable_frame_busting_ = enable_frame_busting; |
| 143 privileged_mode_ = privileged_mode; | 143 privileged_mode_ = privileged_mode; |
| 144 parent_window_ = notification_window; | 144 parent_window_ = notification_window; |
| 145 cache_ = cache; | 145 cache_ = cache; |
| 146 set_url(url.spec()); | 146 set_url(url.spec()); |
| 147 set_pending(true); | 147 set_pending(true); |
| 148 | 148 |
| 149 // Request has already started and data is fetched. We will get the | 149 // Request has already started and data is fetched. We will get the |
| 150 // GetBindInfo call as per contract but the return values are | 150 // GetBindInfo call as per contract but the return values are |
| 151 // ignored. So just set "get" as a method to make our GetBindInfo | 151 // ignored. So just set "get" as a method to make our GetBindInfo |
| 152 // implementation happy. | 152 // implementation happy. |
| 153 method_ = "get"; | 153 method_ = "get"; |
| 154 return S_OK; | 154 return S_OK; |
| 155 } | 155 } |
| 156 | 156 |
| 157 void UrlmonUrlRequest::TerminateBind(TerminateBindCallback* callback) { | 157 void UrlmonUrlRequest::TerminateBind(TerminateBindCallback* callback) { |
| 158 DCHECK_EQ(thread_, PlatformThread::CurrentId()); | 158 DCHECK_EQ(thread_, PlatformThread::CurrentId()); |
| 159 DLOG(INFO) << __FUNCTION__ << me(); | 159 DVLOG(1) << __FUNCTION__ << me(); |
| 160 cleanup_transaction_ = false; | 160 cleanup_transaction_ = false; |
| 161 if (status_.get_state() == Status::DONE) { | 161 if (status_.get_state() == Status::DONE) { |
| 162 // Binding is stopped. Note result could be an error. | 162 // Binding is stopped. Note result could be an error. |
| 163 callback->Run(moniker_, bind_context_); | 163 callback->Run(moniker_, bind_context_); |
| 164 delete callback; | 164 delete callback; |
| 165 } else { | 165 } else { |
| 166 // WORKING (ABORTING?). Save the callback. | 166 // WORKING (ABORTING?). Save the callback. |
| 167 // Now we will return INET_TERMINATE_BIND from ::OnDataAvailable() and in | 167 // Now we will return INET_TERMINATE_BIND from ::OnDataAvailable() and in |
| 168 // ::OnStopBinding will invoke the callback passing our moniker and | 168 // ::OnStopBinding will invoke the callback passing our moniker and |
| 169 // bind context. | 169 // bind context. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 191 size_t UrlmonUrlRequest::SendDataToDelegate(size_t bytes_to_read) { | 191 size_t UrlmonUrlRequest::SendDataToDelegate(size_t bytes_to_read) { |
| 192 DCHECK_EQ(thread_, PlatformThread::CurrentId()); | 192 DCHECK_EQ(thread_, PlatformThread::CurrentId()); |
| 193 DCHECK_NE(id(), -1); | 193 DCHECK_NE(id(), -1); |
| 194 DCHECK_GT(bytes_to_read, 0U); | 194 DCHECK_GT(bytes_to_read, 0U); |
| 195 size_t bytes_copied = 0; | 195 size_t bytes_copied = 0; |
| 196 if (delegate_) { | 196 if (delegate_) { |
| 197 std::string read_data; | 197 std::string read_data; |
| 198 if (cache_) { | 198 if (cache_) { |
| 199 HRESULT hr = ReadStream(cache_, bytes_to_read, &read_data); | 199 HRESULT hr = ReadStream(cache_, bytes_to_read, &read_data); |
| 200 if (hr == S_FALSE || read_data.length() < bytes_to_read) { | 200 if (hr == S_FALSE || read_data.length() < bytes_to_read) { |
| 201 DLOG(INFO) << __FUNCTION__ << me() << "all cached data read"; | 201 DVLOG(1) << __FUNCTION__ << me() << "all cached data read"; |
| 202 cache_.Release(); | 202 cache_.Release(); |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 if (read_data.empty() && pending_data_) { | 206 if (read_data.empty() && pending_data_) { |
| 207 size_t pending_data_read_save = pending_read_size_; | 207 size_t pending_data_read_save = pending_read_size_; |
| 208 pending_read_size_ = 0; | 208 pending_read_size_ = 0; |
| 209 | 209 |
| 210 // AddRef the stream while we call Read to avoid a potential issue | 210 // AddRef the stream while we call Read to avoid a potential issue |
| 211 // where we can get a call to OnDataAvailable while inside Read and | 211 // where we can get a call to OnDataAvailable while inside Read and |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 267 |
| 268 if (status_.get_state() != Status::WORKING) | 268 if (status_.get_state() != Status::WORKING) |
| 269 return S_OK; | 269 return S_OK; |
| 270 | 270 |
| 271 // Ignore any notifications received while we are in the pending state | 271 // Ignore any notifications received while we are in the pending state |
| 272 // waiting for the request to be initiated by Chrome. | 272 // waiting for the request to be initiated by Chrome. |
| 273 if (pending_ && status_code != BINDSTATUS_REDIRECTING) | 273 if (pending_ && status_code != BINDSTATUS_REDIRECTING) |
| 274 return S_OK; | 274 return S_OK; |
| 275 | 275 |
| 276 if (!delegate_) { | 276 if (!delegate_) { |
| 277 DLOG(INFO) << "Invalid delegate"; | 277 DVLOG(1) << "Invalid delegate"; |
| 278 return S_OK; | 278 return S_OK; |
| 279 } | 279 } |
| 280 | 280 |
| 281 switch (status_code) { | 281 switch (status_code) { |
| 282 case BINDSTATUS_REDIRECTING: { | 282 case BINDSTATUS_REDIRECTING: { |
| 283 // If we receive a redirect for the initial pending request initiated | 283 // If we receive a redirect for the initial pending request initiated |
| 284 // when our document loads we should stash it away and inform Chrome | 284 // when our document loads we should stash it away and inform Chrome |
| 285 // accordingly when it requests data for the original URL. | 285 // accordingly when it requests data for the original URL. |
| 286 ScopedComPtr<BindContextInfo> info; | 286 ScopedComPtr<BindContextInfo> info; |
| 287 BindContextInfo::FromBindContext(bind_context_, info.Receive()); | 287 BindContextInfo::FromBindContext(bind_context_, info.Receive()); |
| 288 DCHECK(info); | 288 DCHECK(info); |
| 289 GURL previously_redirected(info ? info->url() : std::wstring()); | 289 GURL previously_redirected(info ? info->url() : std::wstring()); |
| 290 if (GURL(status_text) != previously_redirected) { | 290 if (GURL(status_text) != previously_redirected) { |
| 291 DLOG(INFO) << __FUNCTION__ << me() << "redirect from " << url() | 291 DVLOG(1) << __FUNCTION__ << me() << "redirect from " << url() |
| 292 << " to " << status_text; | 292 << " to " << status_text; |
| 293 // Fetch the redirect status as they aren't all equal (307 in particular | 293 // Fetch the redirect status as they aren't all equal (307 in particular |
| 294 // retains the HTTP request verb). | 294 // retains the HTTP request verb). |
| 295 int http_code = GetHttpResponseStatusFromBinding(binding_); | 295 int http_code = GetHttpResponseStatusFromBinding(binding_); |
| 296 status_.SetRedirected(http_code, WideToUTF8(status_text)); | 296 status_.SetRedirected(http_code, WideToUTF8(status_text)); |
| 297 // Abort. We will inform Chrome in OnStopBinding callback. | 297 // Abort. We will inform Chrome in OnStopBinding callback. |
| 298 binding_->Abort(); | 298 binding_->Abort(); |
| 299 return E_ABORT; | 299 return E_ABORT; |
| 300 } | 300 } |
| 301 break; | 301 break; |
| 302 } | 302 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 323 | 323 |
| 324 case BINDSTATUS_COOKIE_STATE_DOWNGRADE: | 324 case BINDSTATUS_COOKIE_STATE_DOWNGRADE: |
| 325 delegate_->AddPrivacyDataForUrl(url(), "", COOKIEACTION_DOWNGRADE); | 325 delegate_->AddPrivacyDataForUrl(url(), "", COOKIEACTION_DOWNGRADE); |
| 326 break; | 326 break; |
| 327 | 327 |
| 328 case BINDSTATUS_COOKIE_STATE_UNKNOWN: | 328 case BINDSTATUS_COOKIE_STATE_UNKNOWN: |
| 329 NOTREACHED() << L"Unknown cookie state received"; | 329 NOTREACHED() << L"Unknown cookie state received"; |
| 330 break; | 330 break; |
| 331 | 331 |
| 332 default: | 332 default: |
| 333 DLOG(INFO) << __FUNCTION__ << me() | 333 DVLOG(1) << __FUNCTION__ << me() |
| 334 << base::StringPrintf(L"code: %i status: %ls", status_code, | 334 << base::StringPrintf(L"code: %i status: %ls", status_code, |
| 335 status_text); | 335 status_text); |
| 336 break; | 336 break; |
| 337 } | 337 } |
| 338 | 338 |
| 339 return S_OK; | 339 return S_OK; |
| 340 } | 340 } |
| 341 | 341 |
| 342 STDMETHODIMP UrlmonUrlRequest::OnStopBinding(HRESULT result, LPCWSTR error) { | 342 STDMETHODIMP UrlmonUrlRequest::OnStopBinding(HRESULT result, LPCWSTR error) { |
| 343 DCHECK_EQ(thread_, PlatformThread::CurrentId()); | 343 DCHECK_EQ(thread_, PlatformThread::CurrentId()); |
| 344 DLOG(INFO) << __FUNCTION__ << me() << | 344 DVLOG(1) << __FUNCTION__ << me() |
| 345 "- Request stopped, Result: " << std::hex << result; | 345 << "- Request stopped, Result: " << std::hex << result; |
| 346 DCHECK(status_.get_state() == Status::WORKING || | 346 DCHECK(status_.get_state() == Status::WORKING || |
| 347 status_.get_state() == Status::ABORTING); | 347 status_.get_state() == Status::ABORTING); |
| 348 | 348 |
| 349 Status::State state = status_.get_state(); | 349 Status::State state = status_.get_state(); |
| 350 | 350 |
| 351 // Mark we a are done. | 351 // Mark we a are done. |
| 352 status_.Done(); | 352 status_.Done(); |
| 353 | 353 |
| 354 if (result == INET_E_TERMINATED_BIND) { | 354 if (result == INET_E_TERMINATED_BIND) { |
| 355 if (terminate_requested()) { | 355 if (terminate_requested()) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 if (resource_type_ != ResourceType::MAIN_FRAME) | 460 if (resource_type_ != ResourceType::MAIN_FRAME) |
| 461 *bind_flags |= BINDF_NOWRITECACHE; | 461 *bind_flags |= BINDF_NOWRITECACHE; |
| 462 | 462 |
| 463 // Initialize the STGMEDIUM. | 463 // Initialize the STGMEDIUM. |
| 464 memset(&bind_info->stgmedData, 0, sizeof(STGMEDIUM)); | 464 memset(&bind_info->stgmedData, 0, sizeof(STGMEDIUM)); |
| 465 bind_info->grfBindInfoF = 0; | 465 bind_info->grfBindInfoF = 0; |
| 466 bind_info->szCustomVerb = NULL; | 466 bind_info->szCustomVerb = NULL; |
| 467 | 467 |
| 468 if (get_upload_data(&bind_info->stgmedData.pstm) == S_OK) { | 468 if (get_upload_data(&bind_info->stgmedData.pstm) == S_OK) { |
| 469 bind_info->stgmedData.tymed = TYMED_ISTREAM; | 469 bind_info->stgmedData.tymed = TYMED_ISTREAM; |
| 470 DLOG(INFO) << __FUNCTION__ << me() << method() | 470 DVLOG(1) << __FUNCTION__ << me() << method() |
| 471 << " request with " << base::Int64ToString(post_data_len()) | 471 << " request with " << base::Int64ToString(post_data_len()) |
| 472 << " bytes. url=" << url(); | 472 << " bytes. url=" << url(); |
| 473 } else { | 473 } else { |
| 474 DLOG(INFO) << __FUNCTION__ << me() << "POST request with no data!"; | 474 DVLOG(1) << __FUNCTION__ << me() << "POST request with no data!"; |
| 475 } | 475 } |
| 476 } | 476 } |
| 477 | 477 |
| 478 return S_OK; | 478 return S_OK; |
| 479 } | 479 } |
| 480 | 480 |
| 481 STDMETHODIMP UrlmonUrlRequest::OnDataAvailable(DWORD flags, DWORD size, | 481 STDMETHODIMP UrlmonUrlRequest::OnDataAvailable(DWORD flags, DWORD size, |
| 482 FORMATETC* formatetc, | 482 FORMATETC* formatetc, |
| 483 STGMEDIUM* storage) { | 483 STGMEDIUM* storage) { |
| 484 DCHECK_EQ(thread_, PlatformThread::CurrentId()); | 484 DCHECK_EQ(thread_, PlatformThread::CurrentId()); |
| 485 DLOG(INFO) << __FUNCTION__ << me() << "bytes available: " << size; | 485 DVLOG(1) << __FUNCTION__ << me() << "bytes available: " << size; |
| 486 | 486 |
| 487 if (terminate_requested()) { | 487 if (terminate_requested()) { |
| 488 DLOG(INFO) << " Download requested. INET_E_TERMINATED_BIND returned"; | 488 DVLOG(1) << " Download requested. INET_E_TERMINATED_BIND returned"; |
| 489 return INET_E_TERMINATED_BIND; | 489 return INET_E_TERMINATED_BIND; |
| 490 } | 490 } |
| 491 | 491 |
| 492 if (!storage || (storage->tymed != TYMED_ISTREAM)) { | 492 if (!storage || (storage->tymed != TYMED_ISTREAM)) { |
| 493 NOTREACHED(); | 493 NOTREACHED(); |
| 494 return E_INVALIDARG; | 494 return E_INVALIDARG; |
| 495 } | 495 } |
| 496 | 496 |
| 497 IStream* read_stream = storage->pstm; | 497 IStream* read_stream = storage->pstm; |
| 498 if (!read_stream) { | 498 if (!read_stream) { |
| 499 NOTREACHED(); | 499 NOTREACHED(); |
| 500 return E_UNEXPECTED; | 500 return E_UNEXPECTED; |
| 501 } | 501 } |
| 502 | 502 |
| 503 // Some requests such as HEAD have zero data. | 503 // Some requests such as HEAD have zero data. |
| 504 if (size > 0) | 504 if (size > 0) |
| 505 pending_data_ = read_stream; | 505 pending_data_ = read_stream; |
| 506 | 506 |
| 507 if (pending_read_size_) { | 507 if (pending_read_size_) { |
| 508 size_t bytes_copied = SendDataToDelegate(pending_read_size_); | 508 size_t bytes_copied = SendDataToDelegate(pending_read_size_); |
| 509 DLOG(INFO) << __FUNCTION__ << me() << "size read: " << bytes_copied; | 509 DVLOG(1) << __FUNCTION__ << me() << "size read: " << bytes_copied; |
| 510 } else { | 510 } else { |
| 511 DLOG(INFO) << __FUNCTION__ << me() << "- waiting for remote read"; | 511 DVLOG(1) << __FUNCTION__ << me() << "- waiting for remote read"; |
| 512 } | 512 } |
| 513 | 513 |
| 514 if (BSCF_LASTDATANOTIFICATION & flags) { | 514 if (BSCF_LASTDATANOTIFICATION & flags) { |
| 515 if (!is_expecting_download_ || pending()) { | 515 if (!is_expecting_download_ || pending()) { |
| 516 DLOG(INFO) << __FUNCTION__ << me() << "EOF"; | 516 DVLOG(1) << __FUNCTION__ << me() << "EOF"; |
| 517 return S_OK; | 517 return S_OK; |
| 518 } | 518 } |
| 519 // Always return INET_E_TERMINATED_BIND to allow bind context reuse | 519 // Always return INET_E_TERMINATED_BIND to allow bind context reuse |
| 520 // if DownloadToHost is suddenly requested. | 520 // if DownloadToHost is suddenly requested. |
| 521 DLOG(INFO) << __FUNCTION__ << " EOF: INET_E_TERMINATED_BIND returned"; | 521 DVLOG(1) << __FUNCTION__ << " EOF: INET_E_TERMINATED_BIND returned"; |
| 522 return INET_E_TERMINATED_BIND; | 522 return INET_E_TERMINATED_BIND; |
| 523 } | 523 } |
| 524 return S_OK; | 524 return S_OK; |
| 525 } | 525 } |
| 526 | 526 |
| 527 STDMETHODIMP UrlmonUrlRequest::OnObjectAvailable(REFIID iid, IUnknown* object) { | 527 STDMETHODIMP UrlmonUrlRequest::OnObjectAvailable(REFIID iid, IUnknown* object) { |
| 528 // We are calling BindToStorage on the moniker we should always get called | 528 // We are calling BindToStorage on the moniker we should always get called |
| 529 // back on OnDataAvailable and should never get OnObjectAvailable | 529 // back on OnDataAvailable and should never get OnObjectAvailable |
| 530 NOTREACHED(); | 530 NOTREACHED(); |
| 531 return E_NOTIMPL; | 531 return E_NOTIMPL; |
| 532 } | 532 } |
| 533 | 533 |
| 534 STDMETHODIMP UrlmonUrlRequest::BeginningTransaction(const wchar_t* url, | 534 STDMETHODIMP UrlmonUrlRequest::BeginningTransaction(const wchar_t* url, |
| 535 const wchar_t* current_headers, DWORD reserved, | 535 const wchar_t* current_headers, DWORD reserved, |
| 536 wchar_t** additional_headers) { | 536 wchar_t** additional_headers) { |
| 537 DCHECK_EQ(thread_, PlatformThread::CurrentId()); | 537 DCHECK_EQ(thread_, PlatformThread::CurrentId()); |
| 538 if (!additional_headers) { | 538 if (!additional_headers) { |
| 539 NOTREACHED(); | 539 NOTREACHED(); |
| 540 return E_POINTER; | 540 return E_POINTER; |
| 541 } | 541 } |
| 542 | 542 |
| 543 DLOG(INFO) << __FUNCTION__ << me() << "headers: \n" << current_headers; | 543 DVLOG(1) << __FUNCTION__ << me() << "headers: \n" << current_headers; |
| 544 | 544 |
| 545 if (status_.get_state() == Status::ABORTING) { | 545 if (status_.get_state() == Status::ABORTING) { |
| 546 // At times the BINDSTATUS_REDIRECTING notification which is sent to the | 546 // At times the BINDSTATUS_REDIRECTING notification which is sent to the |
| 547 // IBindStatusCallback interface does not have an accompanying HTTP | 547 // IBindStatusCallback interface does not have an accompanying HTTP |
| 548 // redirect status code, i.e. the attempt to query the HTTP status code | 548 // redirect status code, i.e. the attempt to query the HTTP status code |
| 549 // from the binding returns 0, 200, etc which are invalid redirect codes. | 549 // from the binding returns 0, 200, etc which are invalid redirect codes. |
| 550 // We don't want urlmon to follow redirects. We return E_ABORT in our | 550 // We don't want urlmon to follow redirects. We return E_ABORT in our |
| 551 // IBindStatusCallback::OnProgress function and also abort the binding. | 551 // IBindStatusCallback::OnProgress function and also abort the binding. |
| 552 // However urlmon still tries to establish a transaction with the | 552 // However urlmon still tries to establish a transaction with the |
| 553 // redirected URL which confuses the web server. | 553 // redirected URL which confuses the web server. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 } | 601 } |
| 602 } | 602 } |
| 603 | 603 |
| 604 return hr; | 604 return hr; |
| 605 } | 605 } |
| 606 | 606 |
| 607 STDMETHODIMP UrlmonUrlRequest::OnResponse(DWORD dwResponseCode, | 607 STDMETHODIMP UrlmonUrlRequest::OnResponse(DWORD dwResponseCode, |
| 608 const wchar_t* response_headers, const wchar_t* request_headers, | 608 const wchar_t* response_headers, const wchar_t* request_headers, |
| 609 wchar_t** additional_headers) { | 609 wchar_t** additional_headers) { |
| 610 DCHECK_EQ(thread_, PlatformThread::CurrentId()); | 610 DCHECK_EQ(thread_, PlatformThread::CurrentId()); |
| 611 DLOG(INFO) << __FUNCTION__ << me() << "headers: \n" << response_headers; | 611 DVLOG(1) << __FUNCTION__ << me() << "headers: \n" << response_headers; |
| 612 | 612 |
| 613 if (!delegate_) { | 613 if (!delegate_) { |
| 614 DLOG(WARNING) << "Invalid delegate"; | 614 DLOG(WARNING) << "Invalid delegate"; |
| 615 return S_OK; | 615 return S_OK; |
| 616 } | 616 } |
| 617 | 617 |
| 618 std::string raw_headers = WideToUTF8(response_headers); | 618 std::string raw_headers = WideToUTF8(response_headers); |
| 619 | 619 |
| 620 delegate_->AddPrivacyDataForUrl(url(), "", 0); | 620 delegate_->AddPrivacyDataForUrl(url(), "", 0); |
| 621 | 621 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 636 // NOTE(slightlyoff): We don't use net::HttpResponseHeaders here because | 636 // NOTE(slightlyoff): We don't use net::HttpResponseHeaders here because |
| 637 // of lingering ICU/base_noicu issues. | 637 // of lingering ICU/base_noicu issues. |
| 638 if (enable_frame_busting_) { | 638 if (enable_frame_busting_) { |
| 639 if (http_utils::HasFrameBustingHeader(raw_headers)) { | 639 if (http_utils::HasFrameBustingHeader(raw_headers)) { |
| 640 DLOG(ERROR) << "X-Frame-Options header other than ALLOWALL " << | 640 DLOG(ERROR) << "X-Frame-Options header other than ALLOWALL " << |
| 641 "detected, navigation canceled"; | 641 "detected, navigation canceled"; |
| 642 return E_FAIL; | 642 return E_FAIL; |
| 643 } | 643 } |
| 644 } | 644 } |
| 645 | 645 |
| 646 DLOG(INFO) << __FUNCTION__ << me() << "Calling OnResponseStarted"; | 646 DVLOG(1) << __FUNCTION__ << me() << "Calling OnResponseStarted"; |
| 647 | 647 |
| 648 // Inform the delegate. | 648 // Inform the delegate. |
| 649 headers_received_ = true; | 649 headers_received_ = true; |
| 650 DCHECK_NE(id(), -1); | 650 DCHECK_NE(id(), -1); |
| 651 delegate_->OnResponseStarted(id(), | 651 delegate_->OnResponseStarted(id(), |
| 652 "", // mime_type | 652 "", // mime_type |
| 653 raw_headers.c_str(), // headers | 653 raw_headers.c_str(), // headers |
| 654 0, // size | 654 0, // size |
| 655 base::Time(), // last_modified | 655 base::Time(), // last_modified |
| 656 status_.get_redirection().utf8_url, | 656 status_.get_redirection().utf8_url, |
| 657 status_.get_redirection().http_code); | 657 status_.get_redirection().http_code); |
| 658 return S_OK; | 658 return S_OK; |
| 659 } | 659 } |
| 660 | 660 |
| 661 STDMETHODIMP UrlmonUrlRequest::GetWindow(const GUID& guid_reason, | 661 STDMETHODIMP UrlmonUrlRequest::GetWindow(const GUID& guid_reason, |
| 662 HWND* parent_window) { | 662 HWND* parent_window) { |
| 663 if (!parent_window) | 663 if (!parent_window) |
| 664 return E_INVALIDARG; | 664 return E_INVALIDARG; |
| 665 | 665 |
| 666 #ifndef NDEBUG | 666 #ifndef NDEBUG |
| 667 wchar_t guid[40] = {0}; | 667 wchar_t guid[40] = {0}; |
| 668 ::StringFromGUID2(guid_reason, guid, arraysize(guid)); | 668 ::StringFromGUID2(guid_reason, guid, arraysize(guid)); |
| 669 | 669 const wchar_t* str = guid; |
| 670 DLOG(INFO) << __FUNCTION__ << me() << "GetWindow: " << | 670 if (guid_reason == IID_IAuthenticate) |
| 671 (guid_reason == IID_IAuthenticate ? L" - IAuthenticate" : | 671 str = L"IAuthenticate"; |
| 672 (guid_reason == IID_IHttpSecurity ? L"IHttpSecurity" : | 672 else if (guid_reason == IID_IHttpSecurity) |
| 673 (guid_reason == IID_IWindowForBindingUI ? L"IWindowForBindingUI" : | 673 str = L"IHttpSecurity"; |
| 674 guid))); | 674 else if (guid_reason == IID_IWindowForBindingUI) |
| 675 str = L"IWindowForBindingUI"; |
| 676 DVLOG(1) << __FUNCTION__ << me() << "GetWindow: " << str; |
| 675 #endif | 677 #endif |
| 676 // We should return a non-NULL HWND as parent. Otherwise no dialog is shown. | 678 // We should return a non-NULL HWND as parent. Otherwise no dialog is shown. |
| 677 // TODO(iyengar): This hits when running the URL request tests. | 679 // TODO(iyengar): This hits when running the URL request tests. |
| 678 DLOG_IF(WARNING, !::IsWindow(parent_window_)) | 680 DLOG_IF(WARNING, !::IsWindow(parent_window_)) |
| 679 << "UrlmonUrlRequest::GetWindow - no window!"; | 681 << "UrlmonUrlRequest::GetWindow - no window!"; |
| 680 *parent_window = parent_window_; | 682 *parent_window = parent_window_; |
| 681 return S_OK; | 683 return S_OK; |
| 682 } | 684 } |
| 683 | 685 |
| 684 STDMETHODIMP UrlmonUrlRequest::Authenticate(HWND* parent_window, | 686 STDMETHODIMP UrlmonUrlRequest::Authenticate(HWND* parent_window, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 // Chrome about the result. Ideally Chrome should behave in a manner similar | 718 // Chrome about the result. Ideally Chrome should behave in a manner similar |
| 717 // to IE, i.e. display the SSL error interstitial page and if the user | 719 // to IE, i.e. display the SSL error interstitial page and if the user |
| 718 // decides to proceed anyway we would turn off SSL warnings for that | 720 // decides to proceed anyway we would turn off SSL warnings for that |
| 719 // particular navigation and allow IE to download the content. | 721 // particular navigation and allow IE to download the content. |
| 720 // We would need to return the certificate information to Chrome for display | 722 // We would need to return the certificate information to Chrome for display |
| 721 // purposes. Currently we only return a dummy certificate to Chrome. | 723 // purposes. Currently we only return a dummy certificate to Chrome. |
| 722 // At this point we decided that it is a lot of work at this point and | 724 // At this point we decided that it is a lot of work at this point and |
| 723 // decided to go with the easier option of implementing the IHttpSecurity | 725 // decided to go with the easier option of implementing the IHttpSecurity |
| 724 // interface and replicating the checks performed by Urlmon. This | 726 // interface and replicating the checks performed by Urlmon. This |
| 725 // causes Urlmon to display a dialog box on the same lines as IE6. | 727 // causes Urlmon to display a dialog box on the same lines as IE6. |
| 726 DLOG(INFO) << __FUNCTION__ << me() << "Security problem : " << problem; | 728 DVLOG(1) << __FUNCTION__ << me() << "Security problem : " << problem; |
| 727 | 729 |
| 728 // On IE6 the default IBindStatusCallback interface does not implement the | 730 // On IE6 the default IBindStatusCallback interface does not implement the |
| 729 // IHttpSecurity interface and thus causes IE to put up a certificate error | 731 // IHttpSecurity interface and thus causes IE to put up a certificate error |
| 730 // dialog box. We need to emulate this behavior for sites with mismatched | 732 // dialog box. We need to emulate this behavior for sites with mismatched |
| 731 // certificates to work. | 733 // certificates to work. |
| 732 if (GetIEVersion() == IE_6) | 734 if (GetIEVersion() == IE_6) |
| 733 return S_FALSE; | 735 return S_FALSE; |
| 734 | 736 |
| 735 HRESULT hr = E_ABORT; | 737 HRESULT hr = E_ABORT; |
| 736 | 738 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 749 | 751 |
| 750 default: { | 752 default: { |
| 751 NOTREACHED() << "Unhandled security problem : " << problem; | 753 NOTREACHED() << "Unhandled security problem : " << problem; |
| 752 break; | 754 break; |
| 753 } | 755 } |
| 754 } | 756 } |
| 755 return hr; | 757 return hr; |
| 756 } | 758 } |
| 757 | 759 |
| 758 HRESULT UrlmonUrlRequest::StartAsyncDownload() { | 760 HRESULT UrlmonUrlRequest::StartAsyncDownload() { |
| 759 DLOG(INFO) << __FUNCTION__ << me() << url(); | 761 DVLOG(1) << __FUNCTION__ << me() << url(); |
| 760 HRESULT hr = E_FAIL; | 762 HRESULT hr = E_FAIL; |
| 761 DCHECK((moniker_ && bind_context_) || (!moniker_ && !bind_context_)); | 763 DCHECK((moniker_ && bind_context_) || (!moniker_ && !bind_context_)); |
| 762 | 764 |
| 763 if (!moniker_.get()) { | 765 if (!moniker_.get()) { |
| 764 std::wstring wide_url = UTF8ToWide(url()); | 766 std::wstring wide_url = UTF8ToWide(url()); |
| 765 hr = CreateURLMonikerEx(NULL, wide_url.c_str(), moniker_.Receive(), | 767 hr = CreateURLMonikerEx(NULL, wide_url.c_str(), moniker_.Receive(), |
| 766 URL_MK_UNIFORM); | 768 URL_MK_UNIFORM); |
| 767 if (FAILED(hr)) { | 769 if (FAILED(hr)) { |
| 768 NOTREACHED() << "CreateURLMonikerEx failed. Error: " << hr; | 770 NOTREACHED() << "CreateURLMonikerEx failed. Error: " << hr; |
| 769 return hr; | 771 return hr; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 } | 816 } |
| 815 | 817 |
| 816 DLOG_IF(ERROR, FAILED(hr)) << me() << | 818 DLOG_IF(ERROR, FAILED(hr)) << me() << |
| 817 base::StringPrintf(L"StartAsyncDownload failed: 0x%08X", hr); | 819 base::StringPrintf(L"StartAsyncDownload failed: 0x%08X", hr); |
| 818 | 820 |
| 819 return hr; | 821 return hr; |
| 820 } | 822 } |
| 821 | 823 |
| 822 void UrlmonUrlRequest::NotifyDelegateAndDie() { | 824 void UrlmonUrlRequest::NotifyDelegateAndDie() { |
| 823 DCHECK_EQ(thread_, PlatformThread::CurrentId()); | 825 DCHECK_EQ(thread_, PlatformThread::CurrentId()); |
| 824 DLOG(INFO) << __FUNCTION__ << me(); | 826 DVLOG(1) << __FUNCTION__ << me(); |
| 825 | 827 |
| 826 PluginUrlRequestDelegate* delegate = delegate_; | 828 PluginUrlRequestDelegate* delegate = delegate_; |
| 827 delegate_ = NULL; | 829 delegate_ = NULL; |
| 828 ReleaseBindings(); | 830 ReleaseBindings(); |
| 829 TerminateTransaction(); | 831 TerminateTransaction(); |
| 830 if (delegate) { | 832 if (delegate) { |
| 831 URLRequestStatus result = status_.get_result(); | 833 URLRequestStatus result = status_.get_result(); |
| 832 delegate->OnResponseEnd(id(), result); | 834 delegate->OnResponseEnd(id(), result); |
| 833 } else { | 835 } else { |
| 834 DLOG(WARNING) << __FUNCTION__ << me() << "no delegate"; | 836 DLOG(WARNING) << __FUNCTION__ << me() << "no delegate"; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 enable_frame_busting_, privileged_mode_, | 950 enable_frame_busting_, privileged_mode_, |
| 949 notification_window_, cache); | 951 notification_window_, cache); |
| 950 // Start the request | 952 // Start the request |
| 951 bool is_started = pending_request_->Start(); | 953 bool is_started = pending_request_->Start(); |
| 952 DCHECK(is_started); | 954 DCHECK(is_started); |
| 953 } | 955 } |
| 954 } | 956 } |
| 955 | 957 |
| 956 void UrlmonUrlRequestManager::StartRequest(int request_id, | 958 void UrlmonUrlRequestManager::StartRequest(int request_id, |
| 957 const IPC::AutomationURLRequest& request_info) { | 959 const IPC::AutomationURLRequest& request_info) { |
| 958 DLOG(INFO) << __FUNCTION__ << " id: " << request_id; | 960 DVLOG(1) << __FUNCTION__ << " id: " << request_id; |
| 959 DCHECK_EQ(0, calling_delegate_); | 961 DCHECK_EQ(0, calling_delegate_); |
| 960 | 962 |
| 961 if (stopping_) { | 963 if (stopping_) { |
| 962 DLOG(WARNING) << __FUNCTION__ << " request not started (stopping)"; | 964 DLOG(WARNING) << __FUNCTION__ << " request not started (stopping)"; |
| 963 return; | 965 return; |
| 964 } | 966 } |
| 965 | 967 |
| 966 DCHECK(request_map_.find(request_id) == request_map_.end()); | 968 DCHECK(request_map_.find(request_id) == request_map_.end()); |
| 967 DCHECK(GURL(request_info.url).is_valid()); | 969 DCHECK(GURL(request_info.url).is_valid()); |
| 968 | 970 |
| 969 scoped_refptr<UrlmonUrlRequest> new_request; | 971 scoped_refptr<UrlmonUrlRequest> new_request; |
| 970 bool is_started = false; | 972 bool is_started = false; |
| 971 if (pending_request_) { | 973 if (pending_request_) { |
| 972 DCHECK_EQ(pending_request_->url(), request_info.url); | 974 DCHECK_EQ(pending_request_->url(), request_info.url); |
| 973 new_request.swap(pending_request_); | 975 new_request.swap(pending_request_); |
| 974 is_started = true; | 976 is_started = true; |
| 975 DLOG(INFO) << __FUNCTION__ << new_request->me() | 977 DVLOG(1) << __FUNCTION__ << new_request->me() |
| 976 << "assigned id " << request_id; | 978 << " assigned id " << request_id; |
| 977 } else { | 979 } else { |
| 978 CComObject<UrlmonUrlRequest>* created_request = NULL; | 980 CComObject<UrlmonUrlRequest>* created_request = NULL; |
| 979 CComObject<UrlmonUrlRequest>::CreateInstance(&created_request); | 981 CComObject<UrlmonUrlRequest>::CreateInstance(&created_request); |
| 980 new_request = created_request; | 982 new_request = created_request; |
| 981 } | 983 } |
| 982 | 984 |
| 983 new_request->Initialize(static_cast<PluginUrlRequestDelegate*>(this), | 985 new_request->Initialize(static_cast<PluginUrlRequestDelegate*>(this), |
| 984 request_id, | 986 request_id, |
| 985 request_info.url, | 987 request_info.url, |
| 986 request_info.method, | 988 request_info.method, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1000 } else { | 1002 } else { |
| 1001 // Request is already underway, call OnResponse so that the | 1003 // Request is already underway, call OnResponse so that the |
| 1002 // other side can start reading. | 1004 // other side can start reading. |
| 1003 DCHECK(!new_request->response_headers().empty()); | 1005 DCHECK(!new_request->response_headers().empty()); |
| 1004 new_request->OnResponse( | 1006 new_request->OnResponse( |
| 1005 0, UTF8ToWide(new_request->response_headers()).c_str(), NULL, NULL); | 1007 0, UTF8ToWide(new_request->response_headers()).c_str(), NULL, NULL); |
| 1006 } | 1008 } |
| 1007 } | 1009 } |
| 1008 | 1010 |
| 1009 void UrlmonUrlRequestManager::ReadRequest(int request_id, int bytes_to_read) { | 1011 void UrlmonUrlRequestManager::ReadRequest(int request_id, int bytes_to_read) { |
| 1010 DLOG(INFO) << __FUNCTION__ << " id: " << request_id; | 1012 DVLOG(1) << __FUNCTION__ << " id: " << request_id; |
| 1011 DCHECK_EQ(0, calling_delegate_); | 1013 DCHECK_EQ(0, calling_delegate_); |
| 1012 scoped_refptr<UrlmonUrlRequest> request = LookupRequest(request_id); | 1014 scoped_refptr<UrlmonUrlRequest> request = LookupRequest(request_id); |
| 1013 // if zero, it may just have had network error. | 1015 // if zero, it may just have had network error. |
| 1014 if (request) | 1016 if (request) |
| 1015 request->Read(bytes_to_read); | 1017 request->Read(bytes_to_read); |
| 1016 } | 1018 } |
| 1017 | 1019 |
| 1018 void UrlmonUrlRequestManager::DownloadRequestInHost(int request_id) { | 1020 void UrlmonUrlRequestManager::DownloadRequestInHost(int request_id) { |
| 1019 DLOG(INFO) << __FUNCTION__ << " " << request_id; | 1021 DVLOG(1) << __FUNCTION__ << " " << request_id; |
| 1020 if (IsWindow(notification_window_)) { | 1022 if (IsWindow(notification_window_)) { |
| 1021 scoped_refptr<UrlmonUrlRequest> request(LookupRequest(request_id)); | 1023 scoped_refptr<UrlmonUrlRequest> request(LookupRequest(request_id)); |
| 1022 if (request) { | 1024 if (request) { |
| 1023 UrlmonUrlRequest::TerminateBindCallback* callback = NewCallback(this, | 1025 UrlmonUrlRequest::TerminateBindCallback* callback = NewCallback(this, |
| 1024 &UrlmonUrlRequestManager::BindTerminated); | 1026 &UrlmonUrlRequestManager::BindTerminated); |
| 1025 request->TerminateBind(callback); | 1027 request->TerminateBind(callback); |
| 1026 } else { | 1028 } else { |
| 1027 NOTREACHED(); | 1029 NOTREACHED(); |
| 1028 } | 1030 } |
| 1029 } else { | 1031 } else { |
| 1030 NOTREACHED() | 1032 NOTREACHED() << "Cannot handle download if we don't have anyone to hand it " |
| 1031 << "Cannot handle download if we don't have anyone to hand it to."; | 1033 "to."; |
| 1032 } | 1034 } |
| 1033 } | 1035 } |
| 1034 | 1036 |
| 1035 void UrlmonUrlRequestManager::BindTerminated(IMoniker* moniker, | 1037 void UrlmonUrlRequestManager::BindTerminated(IMoniker* moniker, |
| 1036 IBindCtx* bind_ctx) { | 1038 IBindCtx* bind_ctx) { |
| 1037 // We use SendMessage and not PostMessage to make sure that if the | 1039 // We use SendMessage and not PostMessage to make sure that if the |
| 1038 // notification window does not handle the message we won't leak | 1040 // notification window does not handle the message we won't leak |
| 1039 // the moniker. | 1041 // the moniker. |
| 1040 ::SendMessage(notification_window_, WM_DOWNLOAD_IN_HOST, | 1042 ::SendMessage(notification_window_, WM_DOWNLOAD_IN_HOST, |
| 1041 reinterpret_cast<WPARAM>(bind_ctx), | 1043 reinterpret_cast<WPARAM>(bind_ctx), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1058 &cookie_size)) { | 1060 &cookie_size)) { |
| 1059 success = false; | 1061 success = false; |
| 1060 error = GetLastError(); | 1062 error = GetLastError(); |
| 1061 NOTREACHED() << "InternetGetCookie failed. Error: " << error; | 1063 NOTREACHED() << "InternetGetCookie failed. Error: " << error; |
| 1062 } else { | 1064 } else { |
| 1063 cookie_string = cookies.get(); | 1065 cookie_string = cookies.get(); |
| 1064 } | 1066 } |
| 1065 } else { | 1067 } else { |
| 1066 success = false; | 1068 success = false; |
| 1067 error = GetLastError(); | 1069 error = GetLastError(); |
| 1068 DLOG(INFO) << "InternetGetCookie failed. Error: " << error; | 1070 DVLOG(1) << "InternetGetCookie failed. Error: " << error; |
| 1069 } | 1071 } |
| 1070 | 1072 |
| 1071 OnCookiesRetrieved(success, url, cookie_string, cookie_id); | 1073 OnCookiesRetrieved(success, url, cookie_string, cookie_id); |
| 1072 if (!success && !error) | 1074 if (!success && !error) |
| 1073 cookie_action = COOKIEACTION_SUPPRESS; | 1075 cookie_action = COOKIEACTION_SUPPRESS; |
| 1074 | 1076 |
| 1075 AddPrivacyDataForUrl(url.spec(), "", cookie_action); | 1077 AddPrivacyDataForUrl(url.spec(), "", cookie_action); |
| 1076 } | 1078 } |
| 1077 | 1079 |
| 1078 void UrlmonUrlRequestManager::SetCookiesForUrl(const GURL& url, | 1080 void UrlmonUrlRequestManager::SetCookiesForUrl(const GURL& url, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1091 | 1093 |
| 1092 int32 cookie_action = MapCookieStateToCookieAction(cookie_state); | 1094 int32 cookie_action = MapCookieStateToCookieAction(cookie_state); |
| 1093 AddPrivacyDataForUrl(url.spec(), "", cookie_action); | 1095 AddPrivacyDataForUrl(url.spec(), "", cookie_action); |
| 1094 | 1096 |
| 1095 if (container_) { | 1097 if (container_) { |
| 1096 container_->Release(); | 1098 container_->Release(); |
| 1097 } | 1099 } |
| 1098 } | 1100 } |
| 1099 | 1101 |
| 1100 void UrlmonUrlRequestManager::EndRequest(int request_id) { | 1102 void UrlmonUrlRequestManager::EndRequest(int request_id) { |
| 1101 DLOG(INFO) << __FUNCTION__ << " id: " << request_id; | 1103 DVLOG(1) << __FUNCTION__ << " id: " << request_id; |
| 1102 DCHECK_EQ(0, calling_delegate_); | 1104 DCHECK_EQ(0, calling_delegate_); |
| 1103 scoped_refptr<UrlmonUrlRequest> request = LookupRequest(request_id); | 1105 scoped_refptr<UrlmonUrlRequest> request = LookupRequest(request_id); |
| 1104 if (request) { | 1106 if (request) { |
| 1105 request_map_.erase(request_id); | 1107 request_map_.erase(request_id); |
| 1106 request->Stop(); | 1108 request->Stop(); |
| 1107 } else { | 1109 } else { |
| 1108 DLOG(ERROR) << __FUNCTION__ << " no request found for " << request_id; | 1110 DLOG(ERROR) << __FUNCTION__ << " no request found for " << request_id; |
| 1109 } | 1111 } |
| 1110 } | 1112 } |
| 1111 | 1113 |
| 1112 void UrlmonUrlRequestManager::StopAll() { | 1114 void UrlmonUrlRequestManager::StopAll() { |
| 1113 DLOG(INFO) << __FUNCTION__; | 1115 DVLOG(1) << __FUNCTION__; |
| 1114 if (stopping_) | 1116 if (stopping_) |
| 1115 return; | 1117 return; |
| 1116 | 1118 |
| 1117 stopping_ = true; | 1119 stopping_ = true; |
| 1118 | 1120 |
| 1119 DLOG(INFO) << __FUNCTION__ << " stopping " << | 1121 DVLOG(1) << __FUNCTION__ << " stopping " << request_map_.size() |
| 1120 request_map_.size() << " requests"; | 1122 << " requests"; |
| 1121 | 1123 |
| 1122 for (RequestMap::iterator it = request_map_.begin(); | 1124 for (RequestMap::iterator it = request_map_.begin(); |
| 1123 it != request_map_.end(); ++it) { | 1125 it != request_map_.end(); ++it) { |
| 1124 DCHECK(it->second != NULL); | 1126 DCHECK(it->second != NULL); |
| 1125 it->second->Stop(); | 1127 it->second->Stop(); |
| 1126 } | 1128 } |
| 1127 | 1129 |
| 1128 request_map_.empty(); | 1130 request_map_.empty(); |
| 1129 } | 1131 } |
| 1130 | 1132 |
| 1131 void UrlmonUrlRequestManager::OnResponseStarted(int request_id, | 1133 void UrlmonUrlRequestManager::OnResponseStarted(int request_id, |
| 1132 const char* mime_type, const char* headers, int size, | 1134 const char* mime_type, const char* headers, int size, |
| 1133 base::Time last_modified, const std::string& redirect_url, | 1135 base::Time last_modified, const std::string& redirect_url, |
| 1134 int redirect_status) { | 1136 int redirect_status) { |
| 1135 DCHECK_NE(request_id, -1); | 1137 DCHECK_NE(request_id, -1); |
| 1136 DLOG(INFO) << __FUNCTION__; | 1138 DVLOG(1) << __FUNCTION__; |
| 1137 DCHECK(LookupRequest(request_id) != NULL); | 1139 DCHECK(LookupRequest(request_id) != NULL); |
| 1138 ++calling_delegate_; | 1140 ++calling_delegate_; |
| 1139 delegate_->OnResponseStarted(request_id, mime_type, headers, size, | 1141 delegate_->OnResponseStarted(request_id, mime_type, headers, size, |
| 1140 last_modified, redirect_url, redirect_status); | 1142 last_modified, redirect_url, redirect_status); |
| 1141 --calling_delegate_; | 1143 --calling_delegate_; |
| 1142 } | 1144 } |
| 1143 | 1145 |
| 1144 void UrlmonUrlRequestManager::OnReadComplete(int request_id, | 1146 void UrlmonUrlRequestManager::OnReadComplete(int request_id, |
| 1145 const std::string& data) { | 1147 const std::string& data) { |
| 1146 DCHECK_NE(request_id, -1); | 1148 DCHECK_NE(request_id, -1); |
| 1147 DLOG(INFO) << __FUNCTION__ << " id: " << request_id; | 1149 DVLOG(1) << __FUNCTION__ << " id: " << request_id; |
| 1148 DCHECK(LookupRequest(request_id) != NULL); | 1150 DCHECK(LookupRequest(request_id) != NULL); |
| 1149 ++calling_delegate_; | 1151 ++calling_delegate_; |
| 1150 delegate_->OnReadComplete(request_id, data); | 1152 delegate_->OnReadComplete(request_id, data); |
| 1151 --calling_delegate_; | 1153 --calling_delegate_; |
| 1152 DLOG(INFO) << __FUNCTION__ << " done id: " << request_id; | 1154 DVLOG(1) << __FUNCTION__ << " done id: " << request_id; |
| 1153 } | 1155 } |
| 1154 | 1156 |
| 1155 void UrlmonUrlRequestManager::OnResponseEnd(int request_id, | 1157 void UrlmonUrlRequestManager::OnResponseEnd(int request_id, |
| 1156 const URLRequestStatus& status) { | 1158 const URLRequestStatus& status) { |
| 1157 DCHECK_NE(request_id, -1); | 1159 DCHECK_NE(request_id, -1); |
| 1158 DLOG(INFO) << __FUNCTION__; | 1160 DVLOG(1) << __FUNCTION__; |
| 1159 DCHECK(status.status() != URLRequestStatus::CANCELED); | 1161 DCHECK(status.status() != URLRequestStatus::CANCELED); |
| 1160 RequestMap::size_type n = request_map_.erase(request_id); | 1162 RequestMap::size_type n = request_map_.erase(request_id); |
| 1161 DCHECK_EQ(1u, n); | 1163 DCHECK_EQ(1u, n); |
| 1162 ++calling_delegate_; | 1164 ++calling_delegate_; |
| 1163 delegate_->OnResponseEnd(request_id, status); | 1165 delegate_->OnResponseEnd(request_id, status); |
| 1164 --calling_delegate_; | 1166 --calling_delegate_; |
| 1165 } | 1167 } |
| 1166 | 1168 |
| 1167 void UrlmonUrlRequestManager::OnCookiesRetrieved(bool success, const GURL& url, | 1169 void UrlmonUrlRequestManager::OnCookiesRetrieved(bool success, const GURL& url, |
| 1168 const std::string& cookie_string, int cookie_id) { | 1170 const std::string& cookie_string, int cookie_id) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1211 privacy_info_.privacy_records[UTF8ToWide(url)]; | 1213 privacy_info_.privacy_records[UTF8ToWide(url)]; |
| 1212 | 1214 |
| 1213 privacy_entry.flags |= flags; | 1215 privacy_entry.flags |= flags; |
| 1214 privacy_entry.policy_ref = UTF8ToWide(policy_ref); | 1216 privacy_entry.policy_ref = UTF8ToWide(policy_ref); |
| 1215 | 1217 |
| 1216 if (fire_privacy_event && IsWindow(notification_window_)) { | 1218 if (fire_privacy_event && IsWindow(notification_window_)) { |
| 1217 PostMessage(notification_window_, WM_FIRE_PRIVACY_CHANGE_NOTIFICATION, 1, | 1219 PostMessage(notification_window_, WM_FIRE_PRIVACY_CHANGE_NOTIFICATION, 1, |
| 1218 0); | 1220 0); |
| 1219 } | 1221 } |
| 1220 } | 1222 } |
| OLD | NEW |