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

Side by Side Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 12569007: Remove URL fragment from referrer HTTP header when opening link using "Open Link in New Tab" option. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: "Address Matt's code review comments" Created 7 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
6 6
7 #include "content/browser/loader/resource_dispatcher_host_impl.h" 7 #include "content/browser/loader/resource_dispatcher_host_impl.h"
8 8
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 return CallbackAndReturn(started_callback, net::ERR_INSUFFICIENT_RESOURCES); 451 return CallbackAndReturn(started_callback, net::ERR_INSUFFICIENT_RESOURCES);
452 452
453 const GURL& url = request->original_url(); 453 const GURL& url = request->original_url();
454 454
455 // http://crbug.com/90971 455 // http://crbug.com/90971
456 char url_buf[128]; 456 char url_buf[128];
457 base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf)); 457 base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf));
458 base::debug::Alias(url_buf); 458 base::debug::Alias(url_buf);
459 CHECK(ContainsKey(active_resource_contexts_, context)); 459 CHECK(ContainsKey(active_resource_contexts_, context));
460 460
461 request->set_referrer(MaybeStripReferrer(GURL(request->referrer())).spec()); 461 request->SetReferrer(MaybeStripReferrer(GURL(request->referrer())).spec());
462 int extra_load_flags = net::LOAD_IS_DOWNLOAD; 462 int extra_load_flags = net::LOAD_IS_DOWNLOAD;
463 if (prefer_cache) { 463 if (prefer_cache) {
464 // If there is upload data attached, only retrieve from cache because there 464 // If there is upload data attached, only retrieve from cache because there
465 // is no current mechanism to prompt the user for their consent for a 465 // is no current mechanism to prompt the user for their consent for a
466 // re-post. For GETs, try to retrieve data from the cache and skip 466 // re-post. For GETs, try to retrieve data from the cache and skip
467 // validating the entry if present. 467 // validating the entry if present.
468 if (request->get_upload() != NULL) 468 if (request->get_upload() != NULL)
469 extra_load_flags |= net::LOAD_ONLY_FROM_CACHE; 469 extra_load_flags |= net::LOAD_ONLY_FROM_CACHE;
470 else 470 else
471 extra_load_flags |= net::LOAD_PREFERRING_CACHE; 471 extra_load_flags |= net::LOAD_PREFERRING_CACHE;
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 // chance to reset some state before we complete the transfer. 903 // chance to reset some state before we complete the transfer.
904 deferred_loader->WillCompleteTransfer(); 904 deferred_loader->WillCompleteTransfer();
905 } else { 905 } else {
906 net::URLRequestContext* context = 906 net::URLRequestContext* context =
907 filter_->GetURLRequestContext(request_data.resource_type); 907 filter_->GetURLRequestContext(request_data.resource_type);
908 new_request.reset(context->CreateRequest(request_data.url, NULL)); 908 new_request.reset(context->CreateRequest(request_data.url, NULL));
909 request = new_request.get(); 909 request = new_request.get();
910 910
911 request->set_method(request_data.method); 911 request->set_method(request_data.method);
912 request->set_first_party_for_cookies(request_data.first_party_for_cookies); 912 request->set_first_party_for_cookies(request_data.first_party_for_cookies);
913 request->set_referrer(referrer.url.spec()); 913 request->SetReferrer(referrer.url.spec());
914 webkit_glue::ConfigureURLRequestForReferrerPolicy(request, 914 webkit_glue::ConfigureURLRequestForReferrerPolicy(request,
915 referrer.policy); 915 referrer.policy);
916 net::HttpRequestHeaders headers; 916 net::HttpRequestHeaders headers;
917 headers.AddHeadersFromString(request_data.headers); 917 headers.AddHeadersFromString(request_data.headers);
918 request->SetExtraRequestHeaders(headers); 918 request->SetExtraRequestHeaders(headers);
919 } 919 }
920 920
921 // TODO(darin): Do we really need all of these URLRequest setters in the 921 // TODO(darin): Do we really need all of these URLRequest setters in the
922 // transferred navigation case? 922 // transferred navigation case?
923 923
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 // Since any URLs which have non-standard scheme have been filtered 1204 // Since any URLs which have non-standard scheme have been filtered
1205 // by save manager(see GURL::SchemeIsStandard). This situation 1205 // by save manager(see GURL::SchemeIsStandard). This situation
1206 // should not happen. 1206 // should not happen.
1207 NOTREACHED(); 1207 NOTREACHED();
1208 return; 1208 return;
1209 } 1209 }
1210 1210
1211 scoped_ptr<net::URLRequest> request( 1211 scoped_ptr<net::URLRequest> request(
1212 request_context->CreateRequest(url, NULL)); 1212 request_context->CreateRequest(url, NULL));
1213 request->set_method("GET"); 1213 request->set_method("GET");
1214 request->set_referrer(MaybeStripReferrer(referrer.url).spec()); 1214 request->SetReferrer(MaybeStripReferrer(referrer.url).spec());
1215 webkit_glue::ConfigureURLRequestForReferrerPolicy(request.get(), 1215 webkit_glue::ConfigureURLRequestForReferrerPolicy(request.get(),
1216 referrer.policy); 1216 referrer.policy);
1217 // So far, for saving page, we need fetch content from cache, in the 1217 // So far, for saving page, we need fetch content from cache, in the
1218 // future, maybe we can use a configuration to configure this behavior. 1218 // future, maybe we can use a configuration to configure this behavior.
1219 request->set_load_flags(net::LOAD_PREFERRING_CACHE); 1219 request->set_load_flags(net::LOAD_PREFERRING_CACHE);
1220 1220
1221 // Since we're just saving some resources we need, disallow downloading. 1221 // Since we're just saving some resources we need, disallow downloading.
1222 ResourceRequestInfoImpl* extra_info = 1222 ResourceRequestInfoImpl* extra_info =
1223 CreateRequestInfo(child_id, route_id, false, context); 1223 CreateRequestInfo(child_id, route_id, false, context);
1224 extra_info->AssociateWithRequest(request.get()); // Request takes ownership. 1224 extra_info->AssociateWithRequest(request.get()); // Request takes ownership.
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
1697 DelegateMap::iterator it = delegate_map_.find(id); 1697 DelegateMap::iterator it = delegate_map_.find(id);
1698 DCHECK(it->second->HasObserver(delegate)); 1698 DCHECK(it->second->HasObserver(delegate));
1699 it->second->RemoveObserver(delegate); 1699 it->second->RemoveObserver(delegate);
1700 if (it->second->size() == 0) { 1700 if (it->second->size() == 0) {
1701 delete it->second; 1701 delete it->second;
1702 delegate_map_.erase(it); 1702 delegate_map_.erase(it);
1703 } 1703 }
1704 } 1704 }
1705 1705
1706 } // namespace content 1706 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698