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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 1839473002: Centralize the setting of Accept headers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove accept header checking from LinkLoaderTest.Preload Created 4 years, 8 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 295
296 #if defined(OS_ANDROID) 296 #if defined(OS_ANDROID)
297 using blink::WebFloatPoint; 297 using blink::WebFloatPoint;
298 using blink::WebFloatRect; 298 using blink::WebFloatRect;
299 #endif 299 #endif
300 300
301 namespace content { 301 namespace content {
302 302
303 namespace { 303 namespace {
304 304
305 const char kDefaultAcceptHeader[] =
306 "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/"
307 "*;q=0.8";
308 const char kAcceptHeader[] = "Accept";
309
310 const size_t kExtraCharsBeforeAndAfterSelection = 100; 305 const size_t kExtraCharsBeforeAndAfterSelection = 100;
311 306
312 typedef std::map<int, RenderFrameImpl*> RoutingIDFrameMap; 307 typedef std::map<int, RenderFrameImpl*> RoutingIDFrameMap;
313 static base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map = 308 static base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map =
314 LAZY_INSTANCE_INITIALIZER; 309 LAZY_INSTANCE_INITIALIZER;
315 310
316 typedef std::map<blink::WebFrame*, RenderFrameImpl*> FrameMap; 311 typedef std::map<blink::WebFrame*, RenderFrameImpl*> FrameMap;
317 base::LazyInstance<FrameMap> g_frame_map = LAZY_INSTANCE_INITIALIZER; 312 base::LazyInstance<FrameMap> g_frame_map = LAZY_INSTANCE_INITIALIZER;
318 313
319 int64_t ExtractPostId(const WebHistoryItem& item) { 314 int64_t ExtractPostId(const WebHistoryItem& item) {
(...skipping 3409 matching lines...) Expand 10 before | Expand all | Expand 10 after
3729 requested_with = old_extra_data->requested_with(); 3724 requested_with = old_extra_data->requested_with();
3730 if (!requested_with.isNull()) { 3725 if (!requested_with.isNull()) {
3731 if (requested_with.isEmpty()) 3726 if (requested_with.isEmpty())
3732 request.clearHTTPHeaderField("X-Requested-With"); 3727 request.clearHTTPHeaderField("X-Requested-With");
3733 else 3728 else
3734 request.setHTTPHeaderField("X-Requested-With", requested_with); 3729 request.setHTTPHeaderField("X-Requested-With", requested_with);
3735 } 3730 }
3736 stream_override = old_extra_data->TakeStreamOverrideOwnership(); 3731 stream_override = old_extra_data->TakeStreamOverrideOwnership();
3737 } 3732 }
3738 3733
3739 // Add the default accept header for frame request if it has not been set
3740 // already.
3741 if ((request.getFrameType() == blink::WebURLRequest::FrameTypeTopLevel ||
3742 request.getFrameType() == blink::WebURLRequest::FrameTypeNested) &&
3743 request.httpHeaderField(WebString::fromUTF8(kAcceptHeader)).isEmpty()) {
3744 request.setHTTPHeaderField(WebString::fromUTF8(kAcceptHeader),
3745 WebString::fromUTF8(kDefaultAcceptHeader));
3746 }
3747
3748 // Add an empty HTTP origin header for non GET methods if none is currently 3734 // Add an empty HTTP origin header for non GET methods if none is currently
3749 // present. 3735 // present.
3750 request.addHTTPOriginIfNeeded(WebString()); 3736 request.addHTTPOriginIfNeeded(WebString());
3751 3737
3752 // Attach |should_replace_current_entry| state to requests so that, should 3738 // Attach |should_replace_current_entry| state to requests so that, should
3753 // this navigation later require a request transfer, all state is preserved 3739 // this navigation later require a request transfer, all state is preserved
3754 // when it is re-created in the new process. 3740 // when it is re-created in the new process.
3755 bool should_replace_current_entry = data_source->replacesCurrentHistoryItem(); 3741 bool should_replace_current_entry = data_source->replacesCurrentHistoryItem();
3756 3742
3757 int provider_id = kInvalidServiceWorkerProviderId; 3743 int provider_id = kInvalidServiceWorkerProviderId;
(...skipping 2255 matching lines...) Expand 10 before | Expand all | Expand 10 after
6013 int match_count, 5999 int match_count,
6014 int ordinal, 6000 int ordinal,
6015 const WebRect& selection_rect, 6001 const WebRect& selection_rect,
6016 bool final_status_update) { 6002 bool final_status_update) {
6017 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, 6003 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count,
6018 selection_rect, ordinal, 6004 selection_rect, ordinal,
6019 final_status_update)); 6005 final_status_update));
6020 } 6006 }
6021 6007
6022 } // namespace content 6008 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698