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

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

Issue 483773002: PlzNavigate: implement CommitNavigation on the browser side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + fix compilation error Created 6 years, 2 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 | « content/renderer/render_view_impl.h ('k') | content/test/test_render_frame_host.cc » ('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 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 #if defined(OS_ANDROID) 336 #if defined(OS_ANDROID)
337 // Delay between tapping in content and launching the associated android intent. 337 // Delay between tapping in content and launching the associated android intent.
338 // Used to allow users see what has been recognized as content. 338 // Used to allow users see what has been recognized as content.
339 const size_t kContentIntentDelayMilliseconds = 700; 339 const size_t kContentIntentDelayMilliseconds = 700;
340 #endif 340 #endif
341 341
342 static RenderViewImpl* (*g_create_render_view_impl)(RenderViewImplParams*) = 342 static RenderViewImpl* (*g_create_render_view_impl)(RenderViewImplParams*) =
343 NULL; 343 NULL;
344 344
345 // static 345 // static
346 bool RenderViewImpl::IsReload(const FrameMsg_Navigate_Params& params) { 346 bool RenderViewImpl::IsReload(FrameMsg_Navigate_Type::Value navigation_type) {
347 return 347 return navigation_type == FrameMsg_Navigate_Type::RELOAD ||
348 params.navigation_type == FrameMsg_Navigate_Type::RELOAD || 348 navigation_type == FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE ||
349 params.navigation_type == FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE || 349 navigation_type == FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL;
350 params.navigation_type ==
351 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL;
352 } 350 }
353 351
354 // static 352 // static
355 Referrer RenderViewImpl::GetReferrerFromRequest( 353 Referrer RenderViewImpl::GetReferrerFromRequest(
356 WebFrame* frame, 354 WebFrame* frame,
357 const WebURLRequest& request) { 355 const WebURLRequest& request) {
358 return Referrer(GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), 356 return Referrer(GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))),
359 request.referrerPolicy()); 357 request.referrerPolicy());
360 } 358 }
361 359
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 webview()->focusedFrame()->selectWordAroundCaret(); 1399 webview()->focusedFrame()->selectWordAroundCaret();
1402 handling_input_event_ = false; 1400 handling_input_event_ = false;
1403 } 1401 }
1404 1402
1405 bool RenderViewImpl::IsBackForwardToStaleEntry( 1403 bool RenderViewImpl::IsBackForwardToStaleEntry(
1406 const FrameMsg_Navigate_Params& params, 1404 const FrameMsg_Navigate_Params& params,
1407 bool is_reload) { 1405 bool is_reload) {
1408 // Make sure this isn't a back/forward to an entry we have already cropped 1406 // Make sure this isn't a back/forward to an entry we have already cropped
1409 // or replaced from our history, before the browser knew about it. If so, 1407 // or replaced from our history, before the browser knew about it. If so,
1410 // a new navigation has committed in the mean time, and we can ignore this. 1408 // a new navigation has committed in the mean time, and we can ignore this.
1411 bool is_back_forward = !is_reload && params.page_state.IsValid(); 1409 bool is_back_forward =
1410 !is_reload && params.commit_params.page_state.IsValid();
1412 1411
1413 // Note: if the history_list_length_ is 0 for a back/forward, we must be 1412 // Note: if the history_list_length_ is 0 for a back/forward, we must be
1414 // restoring from a previous session. We'll update our state in OnNavigate. 1413 // restoring from a previous session. We'll update our state in OnNavigate.
1415 if (!is_back_forward || history_list_length_ <= 0) 1414 if (!is_back_forward || history_list_length_ <= 0)
1416 return false; 1415 return false;
1417 1416
1418 DCHECK_EQ(static_cast<int>(history_page_ids_.size()), history_list_length_); 1417 DCHECK_EQ(static_cast<int>(history_page_ids_.size()), history_list_length_);
1419 1418
1420 // Check for whether the forward history has been cropped due to a recent 1419 // Check for whether the forward history has been cropped due to a recent
1421 // navigation the browser didn't know about. 1420 // navigation the browser didn't know about.
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after
2277 } 2276 }
2278 2277
2279 void RenderViewImpl::PopulateDocumentStateFromPending( 2278 void RenderViewImpl::PopulateDocumentStateFromPending(
2280 DocumentState* document_state) { 2279 DocumentState* document_state) {
2281 const FrameMsg_Navigate_Params& params = *pending_navigation_params_.get(); 2280 const FrameMsg_Navigate_Params& params = *pending_navigation_params_.get();
2282 document_state->set_request_time(params.request_time); 2281 document_state->set_request_time(params.request_time);
2283 2282
2284 InternalDocumentStateData* internal_data = 2283 InternalDocumentStateData* internal_data =
2285 InternalDocumentStateData::FromDocumentState(document_state); 2284 InternalDocumentStateData::FromDocumentState(document_state);
2286 2285
2287 if (!params.url.SchemeIs(url::kJavaScriptScheme) && 2286 if (!params.common_params.url.SchemeIs(url::kJavaScriptScheme) &&
2288 params.navigation_type == FrameMsg_Navigate_Type::RESTORE) { 2287 params.common_params.navigation_type == FrameMsg_Navigate_Type::RESTORE) {
2289 // We're doing a load of a page that was restored from the last session. By 2288 // We're doing a load of a page that was restored from the last session. By
2290 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which 2289 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which
2291 // can result in stale data for pages that are set to expire. We explicitly 2290 // can result in stale data for pages that are set to expire. We explicitly
2292 // override that by setting the policy here so that as necessary we load 2291 // override that by setting the policy here so that as necessary we load
2293 // from the network. 2292 // from the network.
2294 // 2293 //
2295 // TODO(davidben): Remove this in favor of passing a cache policy to the 2294 // TODO(davidben): Remove this in favor of passing a cache policy to the
2296 // loadHistoryItem call in OnNavigate. That requires not overloading 2295 // loadHistoryItem call in OnNavigate. That requires not overloading
2297 // UseProtocolCachePolicy to mean both "normal load" and "determine cache 2296 // UseProtocolCachePolicy to mean both "normal load" and "determine cache
2298 // policy based on load type, etc". 2297 // policy based on load type, etc".
2299 internal_data->set_cache_policy_override( 2298 internal_data->set_cache_policy_override(
2300 WebURLRequest::UseProtocolCachePolicy); 2299 WebURLRequest::UseProtocolCachePolicy);
2301 } 2300 }
2302 2301
2303 if (IsReload(params)) 2302 if (IsReload(params.common_params.navigation_type))
2304 document_state->set_load_type(DocumentState::RELOAD); 2303 document_state->set_load_type(DocumentState::RELOAD);
2305 else if (params.page_state.IsValid()) 2304 else if (params.commit_params.page_state.IsValid())
2306 document_state->set_load_type(DocumentState::HISTORY_LOAD); 2305 document_state->set_load_type(DocumentState::HISTORY_LOAD);
2307 else 2306 else
2308 document_state->set_load_type(DocumentState::NORMAL_LOAD); 2307 document_state->set_load_type(DocumentState::NORMAL_LOAD);
2309 2308
2310 internal_data->set_is_overriding_user_agent(params.is_overriding_user_agent); 2309 internal_data->set_is_overriding_user_agent(
2310 params.commit_params.is_overriding_user_agent);
2311 internal_data->set_must_reset_scroll_and_scale_state( 2311 internal_data->set_must_reset_scroll_and_scale_state(
2312 params.navigation_type == 2312 params.common_params.navigation_type ==
2313 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); 2313 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL);
2314 document_state->set_can_load_local_resources(params.can_load_local_resources); 2314 document_state->set_can_load_local_resources(params.can_load_local_resources);
2315 } 2315 }
2316 2316
2317 NavigationState* RenderViewImpl::CreateNavigationStateFromPending() { 2317 NavigationState* RenderViewImpl::CreateNavigationStateFromPending() {
2318 const FrameMsg_Navigate_Params& params = *pending_navigation_params_.get(); 2318 const FrameMsg_Navigate_Params& params = *pending_navigation_params_.get();
2319 NavigationState* navigation_state = NULL; 2319 NavigationState* navigation_state = NULL;
2320 2320
2321 // A navigation resulting from loading a javascript URL should not be treated 2321 // A navigation resulting from loading a javascript URL should not be treated
2322 // as a browser initiated event. Instead, we want it to look as if the page 2322 // as a browser initiated event. Instead, we want it to look as if the page
2323 // initiated any load resulting from JS execution. 2323 // initiated any load resulting from JS execution.
2324 if (!params.url.SchemeIs(url::kJavaScriptScheme)) { 2324 if (!params.common_params.url.SchemeIs(url::kJavaScriptScheme)) {
2325 navigation_state = NavigationState::CreateBrowserInitiated( 2325 navigation_state = NavigationState::CreateBrowserInitiated(
2326 params.page_id, 2326 params.page_id,
2327 params.pending_history_list_offset, 2327 params.pending_history_list_offset,
2328 params.should_clear_history_list, 2328 params.should_clear_history_list,
2329 params.transition); 2329 params.common_params.transition);
2330 navigation_state->set_should_replace_current_entry( 2330 navigation_state->set_should_replace_current_entry(
2331 params.should_replace_current_entry); 2331 params.should_replace_current_entry);
2332 navigation_state->set_transferred_request_child_id( 2332 navigation_state->set_transferred_request_child_id(
2333 params.transferred_request_child_id); 2333 params.transferred_request_child_id);
2334 navigation_state->set_transferred_request_request_id( 2334 navigation_state->set_transferred_request_request_id(
2335 params.transferred_request_request_id); 2335 params.transferred_request_request_id);
2336 navigation_state->set_allow_download(params.allow_download); 2336 navigation_state->set_allow_download(params.common_params.allow_download);
2337 navigation_state->set_extra_headers(params.extra_headers); 2337 navigation_state->set_extra_headers(params.request_params.extra_headers);
2338 } else { 2338 } else {
2339 navigation_state = NavigationState::CreateContentInitiated(); 2339 navigation_state = NavigationState::CreateContentInitiated();
2340 } 2340 }
2341 return navigation_state; 2341 return navigation_state;
2342 } 2342 }
2343 2343
2344 void RenderViewImpl::ProcessViewLayoutFlags(const CommandLine& command_line) { 2344 void RenderViewImpl::ProcessViewLayoutFlags(const CommandLine& command_line) {
2345 bool enable_viewport = 2345 bool enable_viewport =
2346 command_line.HasSwitch(switches::kEnableViewport) || 2346 command_line.HasSwitch(switches::kEnableViewport) ||
2347 command_line.HasSwitch(switches::kEnableViewportMeta); 2347 command_line.HasSwitch(switches::kEnableViewportMeta);
(...skipping 1836 matching lines...) Expand 10 before | Expand all | Expand 10 after
4184 std::vector<gfx::Size> sizes; 4184 std::vector<gfx::Size> sizes;
4185 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); 4185 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes);
4186 if (!url.isEmpty()) 4186 if (!url.isEmpty())
4187 urls.push_back( 4187 urls.push_back(
4188 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); 4188 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes));
4189 } 4189 }
4190 SendUpdateFaviconURL(urls); 4190 SendUpdateFaviconURL(urls);
4191 } 4191 }
4192 4192
4193 } // namespace content 4193 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | content/test/test_render_frame_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698