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

Side by Side Diff: chrome/browser/automation/url_request_automation_job.cc

Issue 195054: Supressing the referrer header in the automation url request job when going f... (Closed) Base URL: svn://svn.chromium.org/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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/automation/url_request_automation_job.h" 5 #include "chrome/browser/automation/url_request_automation_job.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "chrome/browser/automation/automation_resource_message_filter.h" 9 #include "chrome/browser/automation/automation_resource_message_filter.h"
10 #include "chrome/browser/renderer_host/render_view_host.h" 10 #include "chrome/browser/renderer_host/render_view_host.h"
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 313
314 NotifyReadComplete(bytes_to_copy); 314 NotifyReadComplete(bytes_to_copy);
315 } 315 }
316 } 316 }
317 317
318 void URLRequestAutomationJob::OnRequestEnd( 318 void URLRequestAutomationJob::OnRequestEnd(
319 int tab, int id, const URLRequestStatus& status) { 319 int tab, int id, const URLRequestStatus& status) {
320 DLOG(INFO) << "URLRequestAutomationJob: " << 320 DLOG(INFO) << "URLRequestAutomationJob: " <<
321 request_->url().spec() << " - request end. Status: " << status.status(); 321 request_->url().spec() << " - request end. Status: " << status.status();
322 322
323 // TODO(tommi): When we hit certificate errors, notify the delegate via
324 // OnSSLCertificateError(). Right now we don't have the certificate
325 // so we don't. We could possibly call OnSSLCertificateError with a NULL
326 // certificate, but I'm not sure if all implementations expect it.
327 // if (status.status() == URLRequestStatus::FAILED &&
328 // net::IsCertificateError(status.os_error()) && request_->delegate()) {
329 // request_->delegate()->OnSSLCertificateError(request_, status.os_error(),
330 // NULL);
331 // }
332
323 DisconnectFromMessageFilter(); 333 DisconnectFromMessageFilter();
324 NotifyDone(status); 334 NotifyDone(status);
325 335
326 // Reset any pending reads. 336 // Reset any pending reads.
327 if (pending_buf_) { 337 if (pending_buf_) {
328 pending_buf_ = NULL; 338 pending_buf_ = NULL;
329 pending_buf_size_ = 0; 339 pending_buf_size_ = 0;
330 NotifyReadComplete(0); 340 NotifyReadComplete(0);
331 } 341 }
332 } 342 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 message_filter_->RegisterRequest(this); 374 message_filter_->RegisterRequest(this);
365 375
366 // Strip unwanted headers. 376 // Strip unwanted headers.
367 std::string new_request_headers( 377 std::string new_request_headers(
368 net::HttpUtil::StripHeaders(request_->extra_request_headers(), 378 net::HttpUtil::StripHeaders(request_->extra_request_headers(),
369 kFilteredHeaderStrings, 379 kFilteredHeaderStrings,
370 arraysize(kFilteredHeaderStrings))); 380 arraysize(kFilteredHeaderStrings)));
371 381
372 // Ensure that we do not send username and password fields in the referrer. 382 // Ensure that we do not send username and password fields in the referrer.
373 GURL referrer(request_->GetSanitizedReferrer()); 383 GURL referrer(request_->GetSanitizedReferrer());
374 #ifndef NDEBUG 384
375 // The referrer header should be suppressed if the preceding URL was 385 // The referrer header must be suppressed if the preceding URL was
376 // a secure one and the new one is not. 386 // a secure one and the new one is not.
377 if (referrer.SchemeIsSecure() && !request_->url().SchemeIsSecure()) { 387 if (referrer.SchemeIsSecure() && !request_->url().SchemeIsSecure()) {
378 DCHECK(referrer.spec().empty()); 388 DLOG(INFO) <<
389 "Suppressing referrer header since going from secure to non-secure";
390 referrer = GURL();
379 } 391 }
380 #endif
381 392
382 // Ask automation to start this request. 393 // Ask automation to start this request.
383 IPC::AutomationURLRequest automation_request = { 394 IPC::AutomationURLRequest automation_request = {
384 request_->url().spec(), 395 request_->url().spec(),
385 request_->method(), 396 request_->method(),
386 referrer.spec(), 397 referrer.spec(),
387 new_request_headers, 398 new_request_headers,
388 request_->get_upload() 399 request_->get_upload()
389 }; 400 };
390 401
391 DCHECK(message_filter_); 402 DCHECK(message_filter_);
392 message_filter_->Send(new AutomationMsg_RequestStart(0, tab_, id_, 403 message_filter_->Send(new AutomationMsg_RequestStart(0, tab_, id_,
393 automation_request)); 404 automation_request));
394 } 405 }
395 406
396 void URLRequestAutomationJob::DisconnectFromMessageFilter() { 407 void URLRequestAutomationJob::DisconnectFromMessageFilter() {
397 if (message_filter_) { 408 if (message_filter_) {
398 message_filter_->UnRegisterRequest(this); 409 message_filter_->UnRegisterRequest(this);
399 message_filter_ = NULL; 410 message_filter_ = NULL;
400 } 411 }
401 } 412 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698