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

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: Rebase again 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 3431 matching lines...) Expand 10 before | Expand all | Expand 10 after
3751 requested_with = old_extra_data->requested_with(); 3746 requested_with = old_extra_data->requested_with();
3752 if (!requested_with.isNull()) { 3747 if (!requested_with.isNull()) {
3753 if (requested_with.isEmpty()) 3748 if (requested_with.isEmpty())
3754 request.clearHTTPHeaderField("X-Requested-With"); 3749 request.clearHTTPHeaderField("X-Requested-With");
3755 else 3750 else
3756 request.setHTTPHeaderField("X-Requested-With", requested_with); 3751 request.setHTTPHeaderField("X-Requested-With", requested_with);
3757 } 3752 }
3758 stream_override = old_extra_data->TakeStreamOverrideOwnership(); 3753 stream_override = old_extra_data->TakeStreamOverrideOwnership();
3759 } 3754 }
3760 3755
3761 // Add the default accept header for frame request if it has not been set
3762 // already.
3763 if ((request.getFrameType() == blink::WebURLRequest::FrameTypeTopLevel ||
3764 request.getFrameType() == blink::WebURLRequest::FrameTypeNested) &&
3765 request.httpHeaderField(WebString::fromUTF8(kAcceptHeader)).isEmpty()) {
3766 request.setHTTPHeaderField(WebString::fromUTF8(kAcceptHeader),
3767 WebString::fromUTF8(kDefaultAcceptHeader));
3768 }
3769
3770 // Add an empty HTTP origin header for non GET methods if none is currently 3756 // Add an empty HTTP origin header for non GET methods if none is currently
3771 // present. 3757 // present.
3772 request.addHTTPOriginIfNeeded(WebString()); 3758 request.addHTTPOriginIfNeeded(WebString());
3773 3759
3774 // Attach |should_replace_current_entry| state to requests so that, should 3760 // Attach |should_replace_current_entry| state to requests so that, should
3775 // this navigation later require a request transfer, all state is preserved 3761 // this navigation later require a request transfer, all state is preserved
3776 // when it is re-created in the new process. 3762 // when it is re-created in the new process.
3777 bool should_replace_current_entry = data_source->replacesCurrentHistoryItem(); 3763 bool should_replace_current_entry = data_source->replacesCurrentHistoryItem();
3778 3764
3779 int provider_id = kInvalidServiceWorkerProviderId; 3765 int provider_id = kInvalidServiceWorkerProviderId;
(...skipping 2261 matching lines...) Expand 10 before | Expand all | Expand 10 after
6041 int match_count, 6027 int match_count,
6042 int ordinal, 6028 int ordinal,
6043 const WebRect& selection_rect, 6029 const WebRect& selection_rect,
6044 bool final_status_update) { 6030 bool final_status_update) {
6045 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, 6031 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count,
6046 selection_rect, ordinal, 6032 selection_rect, ordinal,
6047 final_status_update)); 6033 final_status_update));
6048 } 6034 }
6049 6035
6050 } // namespace content 6036 } // namespace content
OLDNEW
« no previous file with comments | « content/child/web_url_request_util.cc ('k') | third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698