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

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