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

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

Issue 9413038: SPDY - chrome:loadtimes() should display negotiated NPN protocol. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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
« no previous file with comments | « content/public/renderer/document_state.h ('k') | webkit/glue/resource_loader_bridge.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "content/renderer/render_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 #include "webkit/forms/form_data.h" 153 #include "webkit/forms/form_data.h"
154 #include "webkit/forms/form_field.h" 154 #include "webkit/forms/form_field.h"
155 #include "webkit/forms/password_form_dom_manager.h" 155 #include "webkit/forms/password_form_dom_manager.h"
156 #include "webkit/glue/alt_error_page_resource_fetcher.h" 156 #include "webkit/glue/alt_error_page_resource_fetcher.h"
157 #include "webkit/glue/dom_operations.h" 157 #include "webkit/glue/dom_operations.h"
158 #include "webkit/glue/glue_serialize.h" 158 #include "webkit/glue/glue_serialize.h"
159 #include "webkit/glue/webdropdata.h" 159 #include "webkit/glue/webdropdata.h"
160 #include "webkit/glue/webkit_constants.h" 160 #include "webkit/glue/webkit_constants.h"
161 #include "webkit/glue/webkit_glue.h" 161 #include "webkit/glue/webkit_glue.h"
162 #include "webkit/glue/weburlloader_impl.h" 162 #include "webkit/glue/weburlloader_impl.h"
163 #include "webkit/glue/weburlresponse_extradata_impl.h"
163 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" 164 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h"
164 #include "webkit/media/webmediaplayer_impl.h" 165 #include "webkit/media/webmediaplayer_impl.h"
165 #include "webkit/plugins/npapi/plugin_list.h" 166 #include "webkit/plugins/npapi/plugin_list.h"
166 #include "webkit/plugins/npapi/webplugin_delegate.h" 167 #include "webkit/plugins/npapi/webplugin_delegate.h"
167 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" 168 #include "webkit/plugins/npapi/webplugin_delegate_impl.h"
168 #include "webkit/plugins/npapi/webplugin_impl.h" 169 #include "webkit/plugins/npapi/webplugin_impl.h"
169 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" 170 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h"
170 171
171 #if defined(OS_WIN) 172 #if defined(OS_WIN)
172 // TODO(port): these files are currently Windows only because they concern: 173 // TODO(port): these files are currently Windows only because they concern:
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 using content::RenderThread; 263 using content::RenderThread;
263 using content::RenderViewObserver; 264 using content::RenderViewObserver;
264 using content::RenderViewVisitor; 265 using content::RenderViewVisitor;
265 using content::Referrer; 266 using content::Referrer;
266 using content::V8ValueConverter; 267 using content::V8ValueConverter;
267 using webkit::forms::FormField; 268 using webkit::forms::FormField;
268 using webkit::forms::PasswordForm; 269 using webkit::forms::PasswordForm;
269 using webkit::forms::PasswordFormDomManager; 270 using webkit::forms::PasswordFormDomManager;
270 using webkit_glue::AltErrorPageResourceFetcher; 271 using webkit_glue::AltErrorPageResourceFetcher;
271 using webkit_glue::ResourceFetcher; 272 using webkit_glue::ResourceFetcher;
273 using webkit_glue::WebURLResponseExtraDataImpl;
272 274
273 //----------------------------------------------------------------------------- 275 //-----------------------------------------------------------------------------
274 276
275 typedef std::map<WebKit::WebView*, RenderViewImpl*> ViewMap; 277 typedef std::map<WebKit::WebView*, RenderViewImpl*> ViewMap;
276 static base::LazyInstance<ViewMap> g_view_map = LAZY_INSTANCE_INITIALIZER; 278 static base::LazyInstance<ViewMap> g_view_map = LAZY_INSTANCE_INITIALIZER;
277 279
278 // Time, in seconds, we delay before sending content state changes (such as form 280 // Time, in seconds, we delay before sending content state changes (such as form
279 // state and scroll position) to the browser. We delay sending changes to avoid 281 // state and scroll position) to the browser. We delay sending changes to avoid
280 // spamming the browser. 282 // spamming the browser.
281 // To avoid having tab/session restore require sending a message to get the 283 // To avoid having tab/session restore require sending a message to get the
(...skipping 30 matching lines...) Expand all
312 document_state->set_alt_error_page_fetcher(NULL); 314 document_state->set_alt_error_page_fetcher(NULL);
313 } 315 }
314 } 316 }
315 317
316 static bool IsReload(const ViewMsg_Navigate_Params& params) { 318 static bool IsReload(const ViewMsg_Navigate_Params& params) {
317 return 319 return
318 params.navigation_type == ViewMsg_Navigate_Type::RELOAD || 320 params.navigation_type == ViewMsg_Navigate_Type::RELOAD ||
319 params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; 321 params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE;
320 } 322 }
321 323
322 static WebReferrerPolicy getReferrerPolicyFromRequest( 324 static WebReferrerPolicy GetReferrerPolicyFromRequest(
darin (slow to review) 2012/02/27 16:50:30 Thanks for fixing this.
323 const WebURLRequest& request) { 325 const WebURLRequest& request) {
324 return request.extraData() ? 326 return request.extraData() ?
325 static_cast<RequestExtraData*>(request.extraData())->referrer_policy() : 327 static_cast<RequestExtraData*>(request.extraData())->referrer_policy() :
326 WebKit::WebReferrerPolicyDefault; 328 WebKit::WebReferrerPolicyDefault;
327 } 329 }
328 330
331 static WebURLResponseExtraDataImpl* GetExtraDataFromResponse(
332 const WebURLResponse& response) {
333 return static_cast<WebURLResponseExtraDataImpl*>(
334 response.extraData());
335 }
336
329 NOINLINE static void CrashIntentionally() { 337 NOINLINE static void CrashIntentionally() {
330 // NOTE(shess): Crash directly rather than using NOTREACHED() so 338 // NOTE(shess): Crash directly rather than using NOTREACHED() so
331 // that the signature is easier to triage in crash reports. 339 // that the signature is easier to triage in crash reports.
332 volatile int* zero = NULL; 340 volatile int* zero = NULL;
333 *zero = 0; 341 *zero = 0;
334 } 342 }
335 343
336 static void MaybeHandleDebugURL(const GURL& url) { 344 static void MaybeHandleDebugURL(const GURL& url) {
337 if (!url.SchemeIs(chrome::kChromeUIScheme)) 345 if (!url.SchemeIs(chrome::kChromeUIScheme))
338 return; 346 return;
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 if (completed_client_redirect_src_.url.is_valid()) { 1269 if (completed_client_redirect_src_.url.is_valid()) {
1262 DCHECK(completed_client_redirect_src_.url == params.redirects[0]); 1270 DCHECK(completed_client_redirect_src_.url == params.redirects[0]);
1263 params.referrer = completed_client_redirect_src_; 1271 params.referrer = completed_client_redirect_src_;
1264 params.transition = static_cast<content::PageTransition>( 1272 params.transition = static_cast<content::PageTransition>(
1265 params.transition | content::PAGE_TRANSITION_CLIENT_REDIRECT); 1273 params.transition | content::PAGE_TRANSITION_CLIENT_REDIRECT);
1266 } else { 1274 } else {
1267 // Bug 654101: the referrer will be empty on https->http transitions. It 1275 // Bug 654101: the referrer will be empty on https->http transitions. It
1268 // would be nice if we could get the real referrer from somewhere. 1276 // would be nice if we could get the real referrer from somewhere.
1269 params.referrer = Referrer(GURL( 1277 params.referrer = Referrer(GURL(
1270 original_request.httpHeaderField(WebString::fromUTF8("Referer"))), 1278 original_request.httpHeaderField(WebString::fromUTF8("Referer"))),
1271 getReferrerPolicyFromRequest(original_request)); 1279 GetReferrerPolicyFromRequest(original_request));
1272 } 1280 }
1273 1281
1274 string16 method = request.httpMethod(); 1282 string16 method = request.httpMethod();
1275 if (EqualsASCII(method, "POST")) { 1283 if (EqualsASCII(method, "POST")) {
1276 params.is_post = true; 1284 params.is_post = true;
1277 params.post_id = ExtractPostId(item); 1285 params.post_id = ExtractPostId(item);
1278 } 1286 }
1279 1287
1280 // Save some histogram data so we can compute the average memory used per 1288 // Save some histogram data so we can compute the average memory used per
1281 // page load of the glyphs. 1289 // page load of the glyphs.
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
2176 void RenderViewImpl::loadURLExternally( 2184 void RenderViewImpl::loadURLExternally(
2177 WebFrame* frame, const WebURLRequest& request, 2185 WebFrame* frame, const WebURLRequest& request,
2178 WebNavigationPolicy policy, 2186 WebNavigationPolicy policy,
2179 const WebString& suggested_name) { 2187 const WebString& suggested_name) {
2180 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); 2188 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer")));
2181 if (policy == WebKit::WebNavigationPolicyDownload) { 2189 if (policy == WebKit::WebNavigationPolicyDownload) {
2182 Send(new ViewHostMsg_DownloadUrl(routing_id_, request.url(), referrer, 2190 Send(new ViewHostMsg_DownloadUrl(routing_id_, request.url(), referrer,
2183 suggested_name)); 2191 suggested_name));
2184 } else { 2192 } else {
2185 OpenURL(frame, request.url(), 2193 OpenURL(frame, request.url(),
2186 Referrer(referrer, getReferrerPolicyFromRequest(request)), policy); 2194 Referrer(referrer, GetReferrerPolicyFromRequest(request)), policy);
2187 } 2195 }
2188 } 2196 }
2189 2197
2190 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( 2198 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation(
2191 WebFrame* frame, const WebURLRequest& request, WebNavigationType type, 2199 WebFrame* frame, const WebURLRequest& request, WebNavigationType type,
2192 const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) { 2200 const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) {
2193 // TODO(creis): Remove this when we fix OnSwapOut to not need a navigation. 2201 // TODO(creis): Remove this when we fix OnSwapOut to not need a navigation.
2194 if (is_swapped_out_) { 2202 if (is_swapped_out_) {
2195 // It is possible for in-progress navigations to arrive here just after we 2203 // It is possible for in-progress navigations to arrive here just after we
2196 // are swapped out, including iframes. We should cancel them. 2204 // are swapped out, including iframes. We should cancel them.
(...skipping 23 matching lines...) Expand all
2220 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 2228 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
2221 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) && 2229 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) &&
2222 !frame->parent() && (is_content_initiated || is_redirect)) { 2230 !frame->parent() && (is_content_initiated || is_redirect)) {
2223 WebString origin_str = frame->document().securityOrigin().toString(); 2231 WebString origin_str = frame->document().securityOrigin().toString();
2224 GURL frame_url(origin_str.utf8().data()); 2232 GURL frame_url(origin_str.utf8().data());
2225 // TODO(cevans): revisit whether this origin check is still necessary once 2233 // TODO(cevans): revisit whether this origin check is still necessary once
2226 // crbug.com/101395 is fixed. 2234 // crbug.com/101395 is fixed.
2227 if (frame_url.GetOrigin() != url.GetOrigin()) { 2235 if (frame_url.GetOrigin() != url.GetOrigin()) {
2228 Referrer referrer( 2236 Referrer referrer(
2229 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), 2237 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))),
2230 getReferrerPolicyFromRequest(request)); 2238 GetReferrerPolicyFromRequest(request));
2231 OpenURL(frame, url, referrer, default_policy); 2239 OpenURL(frame, url, referrer, default_policy);
2232 return WebKit::WebNavigationPolicyIgnore; 2240 return WebKit::WebNavigationPolicyIgnore;
2233 } 2241 }
2234 } 2242 }
2235 2243
2236 // If the browser is interested, then give it a chance to look at top level 2244 // If the browser is interested, then give it a chance to look at top level
2237 // navigations. 2245 // navigations.
2238 if (is_content_initiated) { 2246 if (is_content_initiated) {
2239 bool browser_handles_top_level_requests = 2247 bool browser_handles_top_level_requests =
2240 renderer_preferences_.browser_handles_top_level_requests && 2248 renderer_preferences_.browser_handles_top_level_requests &&
2241 IsNonLocalTopLevelNavigation(url, frame, type); 2249 IsNonLocalTopLevelNavigation(url, frame, type);
2242 if (browser_handles_top_level_requests || 2250 if (browser_handles_top_level_requests ||
2243 renderer_preferences_.browser_handles_all_requests) { 2251 renderer_preferences_.browser_handles_all_requests) {
2244 Referrer referrer( 2252 Referrer referrer(
2245 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), 2253 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))),
2246 getReferrerPolicyFromRequest(request)); 2254 GetReferrerPolicyFromRequest(request));
2247 // Reset these counters as the RenderView could be reused for the next 2255 // Reset these counters as the RenderView could be reused for the next
2248 // navigation. 2256 // navigation.
2249 page_id_ = -1; 2257 page_id_ = -1;
2250 last_page_id_sent_to_browser_ = -1; 2258 last_page_id_sent_to_browser_ = -1;
2251 OpenURL(frame, url, referrer, default_policy); 2259 OpenURL(frame, url, referrer, default_policy);
2252 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. 2260 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here.
2253 } 2261 }
2254 } 2262 }
2255 2263
2256 // Detect when we're crossing a permission-based boundary (e.g. into or out of 2264 // Detect when we're crossing a permission-based boundary (e.g. into or out of
(...skipping 23 matching lines...) Expand all
2280 // Give the embedder a chance. 2288 // Give the embedder a chance.
2281 bool is_initial_navigation = page_id_ == -1; 2289 bool is_initial_navigation = page_id_ == -1;
2282 should_fork = content::GetContentClient()->renderer()->ShouldFork( 2290 should_fork = content::GetContentClient()->renderer()->ShouldFork(
2283 frame, url, is_content_initiated, is_initial_navigation, 2291 frame, url, is_content_initiated, is_initial_navigation,
2284 &send_referrer); 2292 &send_referrer);
2285 } 2293 }
2286 2294
2287 if (should_fork) { 2295 if (should_fork) {
2288 Referrer referrer( 2296 Referrer referrer(
2289 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), 2297 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))),
2290 getReferrerPolicyFromRequest(request)); 2298 GetReferrerPolicyFromRequest(request));
2291 OpenURL( 2299 OpenURL(
2292 frame, url, send_referrer ? referrer : Referrer(), default_policy); 2300 frame, url, send_referrer ? referrer : Referrer(), default_policy);
2293 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. 2301 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here.
2294 } 2302 }
2295 } 2303 }
2296 2304
2297 // Use the frame's original request's URL rather than the document's URL for 2305 // Use the frame's original request's URL rather than the document's URL for
2298 // this check. For a popup, the document's URL may become the opener window's 2306 // this check. For a popup, the document's URL may become the opener window's
2299 // URL if the opener has called document.write. See http://crbug.com/93517. 2307 // URL if the opener has called document.write. See http://crbug.com/93517.
2300 GURL old_url(frame->dataSource()->request().url()); 2308 GURL old_url(frame->dataSource()->request().url());
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
2455 RenderViewObserver, observers_, DidCancelClientRedirect(frame)); 2463 RenderViewObserver, observers_, DidCancelClientRedirect(frame));
2456 } 2464 }
2457 2465
2458 void RenderViewImpl::didCompleteClientRedirect( 2466 void RenderViewImpl::didCompleteClientRedirect(
2459 WebFrame* frame, const WebURL& from) { 2467 WebFrame* frame, const WebURL& from) {
2460 if (!frame->parent()) { 2468 if (!frame->parent()) {
2461 WebDataSource* ds = frame->provisionalDataSource(); 2469 WebDataSource* ds = frame->provisionalDataSource();
2462 // If there's no provisional data source, it's a reference fragment 2470 // If there's no provisional data source, it's a reference fragment
2463 // navigation. 2471 // navigation.
2464 completed_client_redirect_src_ = Referrer( 2472 completed_client_redirect_src_ = Referrer(
2465 from, ds ? getReferrerPolicyFromRequest(ds->request()) : 2473 from, ds ? GetReferrerPolicyFromRequest(ds->request()) :
2466 frame->referrerPolicy()); 2474 frame->referrerPolicy());
2467 } 2475 }
2468 FOR_EACH_OBSERVER( 2476 FOR_EACH_OBSERVER(
2469 RenderViewObserver, observers_, DidCompleteClientRedirect(frame, from)); 2477 RenderViewObserver, observers_, DidCompleteClientRedirect(frame, from));
2470 } 2478 }
2471 2479
2472 void RenderViewImpl::didCreateDataSource(WebFrame* frame, WebDataSource* ds) { 2480 void RenderViewImpl::didCreateDataSource(WebFrame* frame, WebDataSource* ds) {
2473 DocumentState* document_state = DocumentState::FromDataSource(ds); 2481 DocumentState* document_state = DocumentState::FromDataSource(ds);
2474 if (!document_state) { 2482 if (!document_state) {
2475 document_state = new DocumentState; 2483 document_state = new DocumentState;
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
3010 if (frame->isViewSourceModeEnabled()) 3018 if (frame->isViewSourceModeEnabled())
3011 return; 3019 return;
3012 3020
3013 DocumentState* document_state = 3021 DocumentState* document_state =
3014 DocumentState::FromDataSource(frame->provisionalDataSource()); 3022 DocumentState::FromDataSource(frame->provisionalDataSource());
3015 int http_status_code = response.httpStatusCode(); 3023 int http_status_code = response.httpStatusCode();
3016 3024
3017 // Record page load flags. 3025 // Record page load flags.
3018 document_state->set_was_fetched_via_spdy(response.wasFetchedViaSPDY()); 3026 document_state->set_was_fetched_via_spdy(response.wasFetchedViaSPDY());
3019 document_state->set_was_npn_negotiated(response.wasNpnNegotiated()); 3027 document_state->set_was_npn_negotiated(response.wasNpnNegotiated());
3028 WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse(response);
3029 if (extra_data) {
3030 document_state->set_npn_negotiated_protocol(
3031 extra_data->npn_negotiated_protocol());
3032 } else {
3033 document_state->set_npn_negotiated_protocol("");
darin (slow to review) 2012/02/27 16:50:30 nit: use std::string() instead. std::string("") l
ramant (doing other things) 2012/02/27 18:11:36 Thanks very much for catching this (I am guilty).
3034 }
3020 document_state->set_was_alternate_protocol_available( 3035 document_state->set_was_alternate_protocol_available(
3021 response.wasAlternateProtocolAvailable()); 3036 response.wasAlternateProtocolAvailable());
3022 document_state->set_was_fetched_via_proxy(response.wasFetchedViaProxy()); 3037 document_state->set_was_fetched_via_proxy(response.wasFetchedViaProxy());
3023 document_state->set_http_status_code(http_status_code); 3038 document_state->set_http_status_code(http_status_code);
3024 // Whether or not the http status code actually corresponds to an error is 3039 // Whether or not the http status code actually corresponds to an error is
3025 // only checked when the page is done loading, if |use_error_page| is 3040 // only checked when the page is done loading, if |use_error_page| is
3026 // still true. 3041 // still true.
3027 document_state->set_use_error_page(true); 3042 document_state->set_use_error_page(true);
3028 } 3043 }
3029 3044
(...skipping 2044 matching lines...) Expand 10 before | Expand all | Expand 10 after
5074 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { 5089 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const {
5075 return !!RenderThreadImpl::current()->compositor_thread(); 5090 return !!RenderThreadImpl::current()->compositor_thread();
5076 } 5091 }
5077 5092
5078 void RenderViewImpl::OnJavaBridgeInit() { 5093 void RenderViewImpl::OnJavaBridgeInit() {
5079 DCHECK(!java_bridge_dispatcher_.get()); 5094 DCHECK(!java_bridge_dispatcher_.get());
5080 #if defined(ENABLE_JAVA_BRIDGE) 5095 #if defined(ENABLE_JAVA_BRIDGE)
5081 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); 5096 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this));
5082 #endif 5097 #endif
5083 } 5098 }
OLDNEW
« no previous file with comments | « content/public/renderer/document_state.h ('k') | webkit/glue/resource_loader_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698