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

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: Drop unused variables in test 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 298
299 #if defined(OS_ANDROID) 299 #if defined(OS_ANDROID)
300 using blink::WebFloatPoint; 300 using blink::WebFloatPoint;
301 using blink::WebFloatRect; 301 using blink::WebFloatRect;
302 #endif 302 #endif
303 303
304 namespace content { 304 namespace content {
305 305
306 namespace { 306 namespace {
307 307
308 const char kDefaultAcceptHeader[] =
309 "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/"
310 "*;q=0.8";
311 const char kAcceptHeader[] = "Accept";
312
313 const size_t kExtraCharsBeforeAndAfterSelection = 100; 308 const size_t kExtraCharsBeforeAndAfterSelection = 100;
314 309
315 typedef std::map<int, RenderFrameImpl*> RoutingIDFrameMap; 310 typedef std::map<int, RenderFrameImpl*> RoutingIDFrameMap;
316 static base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map = 311 static base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map =
317 LAZY_INSTANCE_INITIALIZER; 312 LAZY_INSTANCE_INITIALIZER;
318 313
319 typedef std::map<blink::WebFrame*, RenderFrameImpl*> FrameMap; 314 typedef std::map<blink::WebFrame*, RenderFrameImpl*> FrameMap;
320 base::LazyInstance<FrameMap> g_frame_map = LAZY_INSTANCE_INITIALIZER; 315 base::LazyInstance<FrameMap> g_frame_map = LAZY_INSTANCE_INITIALIZER;
321 316
322 int64_t ExtractPostId(const WebHistoryItem& item) { 317 int64_t ExtractPostId(const WebHistoryItem& item) {
(...skipping 3428 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 2257 matching lines...) Expand 10 before | Expand all | Expand 10 after
6037 int match_count, 6023 int match_count,
6038 int ordinal, 6024 int ordinal,
6039 const WebRect& selection_rect, 6025 const WebRect& selection_rect,
6040 bool final_status_update) { 6026 bool final_status_update) {
6041 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, 6027 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count,
6042 selection_rect, ordinal, 6028 selection_rect, ordinal,
6043 final_status_update)); 6029 final_status_update));
6044 } 6030 }
6045 6031
6046 } // namespace content 6032 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698