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

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

Issue 313313002: Set the default accept header for main resources in RenderFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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
« 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 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 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 using blink::WebVector; 162 using blink::WebVector;
163 using blink::WebView; 163 using blink::WebView;
164 using base::Time; 164 using base::Time;
165 using base::TimeDelta; 165 using base::TimeDelta;
166 using webkit_glue::WebURLResponseExtraDataImpl; 166 using webkit_glue::WebURLResponseExtraDataImpl;
167 167
168 namespace content { 168 namespace content {
169 169
170 namespace { 170 namespace {
171 171
172 const char kDefaultAcceptHeader[] =
173 "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/"
174 "*;q=0.8";
175 const char kAcceptHeader[] = "Accept";
176
172 const size_t kExtraCharsBeforeAndAfterSelection = 100; 177 const size_t kExtraCharsBeforeAndAfterSelection = 100;
173 178
174 typedef std::map<int, RenderFrameImpl*> RoutingIDFrameMap; 179 typedef std::map<int, RenderFrameImpl*> RoutingIDFrameMap;
175 static base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map = 180 static base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map =
176 LAZY_INSTANCE_INITIALIZER; 181 LAZY_INSTANCE_INITIALIZER;
177 182
178 typedef std::map<blink::WebFrame*, RenderFrameImpl*> FrameMap; 183 typedef std::map<blink::WebFrame*, RenderFrameImpl*> FrameMap;
179 base::LazyInstance<FrameMap> g_frame_map = LAZY_INSTANCE_INITIALIZER; 184 base::LazyInstance<FrameMap> g_frame_map = LAZY_INSTANCE_INITIALIZER;
180 185
181 int64 ExtractPostId(const WebHistoryItem& item) { 186 int64 ExtractPostId(const WebHistoryItem& item) {
(...skipping 2215 matching lines...) Expand 10 before | Expand all | Expand 10 after
2397 old_extra_data->was_after_preconnect_request(); 2402 old_extra_data->was_after_preconnect_request();
2398 2403
2399 if (!custom_user_agent.isNull()) { 2404 if (!custom_user_agent.isNull()) {
2400 if (custom_user_agent.isEmpty()) 2405 if (custom_user_agent.isEmpty())
2401 request.clearHTTPHeaderField("User-Agent"); 2406 request.clearHTTPHeaderField("User-Agent");
2402 else 2407 else
2403 request.setHTTPHeaderField("User-Agent", custom_user_agent); 2408 request.setHTTPHeaderField("User-Agent", custom_user_agent);
2404 } 2409 }
2405 } 2410 }
2406 2411
2412 // Add the default accept header for frame request if it has not been set
2413 // already.
ppi 2014/06/05 15:10:10 In which circumstances it will be already set?
clamy 2014/06/05 15:22:01 This function is also called on redirects. If the
2414 if ((request.targetType() == blink::WebURLRequest::TargetIsMainFrame ||
2415 request.targetType() == blink::WebURLRequest::TargetIsSubframe) &&
2416 request.httpHeaderField(WebString::fromUTF8(kAcceptHeader)).isEmpty()) {
2417 request.setHTTPHeaderField(WebString::fromUTF8(kAcceptHeader),
2418 WebString::fromUTF8(kDefaultAcceptHeader));
2419 }
2420
2407 // Attach |should_replace_current_entry| state to requests so that, should 2421 // Attach |should_replace_current_entry| state to requests so that, should
2408 // this navigation later require a request transfer, all state is preserved 2422 // this navigation later require a request transfer, all state is preserved
2409 // when it is re-created in the new process. 2423 // when it is re-created in the new process.
2410 bool should_replace_current_entry = false; 2424 bool should_replace_current_entry = false;
2411 if (navigation_state->is_content_initiated()) { 2425 if (navigation_state->is_content_initiated()) {
2412 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); 2426 should_replace_current_entry = data_source->replacesCurrentHistoryItem();
2413 } else { 2427 } else {
2414 // If the navigation is browser-initiated, the NavigationState contains the 2428 // If the navigation is browser-initiated, the NavigationState contains the
2415 // correct value instead of the WebDataSource. 2429 // correct value instead of the WebDataSource.
2416 // 2430 //
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after
3543 3557
3544 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 3558 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
3545 if (!cdm_manager_) 3559 if (!cdm_manager_)
3546 cdm_manager_ = new RendererCdmManager(this); 3560 cdm_manager_ = new RendererCdmManager(this);
3547 return cdm_manager_; 3561 return cdm_manager_;
3548 } 3562 }
3549 3563
3550 #endif // defined(OS_ANDROID) 3564 #endif // defined(OS_ANDROID)
3551 3565
3552 } // namespace content 3566 } // namespace content
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