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

Side by Side Diff: chrome/renderer/render_view.cc

Issue 341043: Changes session restore to use a normal load rather than preferring... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | « chrome/renderer/navigation_state.h ('k') | 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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/renderer/render_view.h" 5 #include "chrome/renderer/render_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 if (!webview()) 713 if (!webview())
714 return; 714 return;
715 715
716 if (devtools_agent_.get()) 716 if (devtools_agent_.get())
717 devtools_agent_->OnNavigate(); 717 devtools_agent_->OnNavigate();
718 718
719 child_process_logging::SetActiveURL(params.url); 719 child_process_logging::SetActiveURL(params.url);
720 720
721 AboutHandler::MaybeHandle(params.url); 721 AboutHandler::MaybeHandle(params.url);
722 722
723 bool is_reload = params.reload; 723 bool is_reload = (params.navigation_type == ViewMsg_Navigate_Params::RELOAD);
724 724
725 WebFrame* main_frame = webview()->mainFrame(); 725 WebFrame* main_frame = webview()->mainFrame();
726 if (is_reload && main_frame->currentHistoryItem().isNull()) { 726 if (is_reload && main_frame->currentHistoryItem().isNull()) {
727 // We cannot reload if we do not have any history state. This happens, for 727 // We cannot reload if we do not have any history state. This happens, for
728 // example, when recovering from a crash. Our workaround here is a bit of 728 // example, when recovering from a crash. Our workaround here is a bit of
729 // a hack since it means that reload after a crashed tab does not cause an 729 // a hack since it means that reload after a crashed tab does not cause an
730 // end-to-end cache validation. 730 // end-to-end cache validation.
731 is_reload = false; 731 is_reload = false;
732 } 732 }
733 733
734 // A navigation resulting from loading a javascript URL should not be treated 734 // A navigation resulting from loading a javascript URL should not be treated
735 // as a browser initiated event. Instead, we want it to look as if the page 735 // as a browser initiated event. Instead, we want it to look as if the page
736 // initiated any load resulting from JS execution. 736 // initiated any load resulting from JS execution.
737 if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) { 737 if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) {
738 pending_navigation_state_.reset(NavigationState::CreateBrowserInitiated( 738 NavigationState* state = NavigationState::CreateBrowserInitiated(
739 params.page_id, params.transition, params.request_time)); 739 params.page_id, params.transition, params.request_time);
740 if (params.navigation_type == ViewMsg_Navigate_Params::RESTORE) {
741 // We're doing a load of a page that was restored from the last session.
742 // By default this prefers the cache over loading (LOAD_PREFERRING_CACHE)
743 // which can result in stale data for pages that are set to expire. We
744 // explicitly override that by setting the policy here so that as
745 // necessary we load from the network.
746 state->set_cache_policy_override(WebURLRequest::UseProtocolCachePolicy);
747 }
748 pending_navigation_state_.reset(state);
740 } 749 }
741 750
742 // If we are reloading, then WebKit will use the history state of the current 751 // If we are reloading, then WebKit will use the history state of the current
743 // page, so we should just ignore any given history state. Otherwise, if we 752 // page, so we should just ignore any given history state. Otherwise, if we
744 // have history state, then we need to navigate to it, which corresponds to a 753 // have history state, then we need to navigate to it, which corresponds to a
745 // back/forward navigation event. 754 // back/forward navigation event.
746 if (is_reload) { 755 if (is_reload) {
747 main_frame->reload(); 756 main_frame->reload();
748 } else if (!params.state.empty()) { 757 } else if (!params.state.empty()) {
749 // We must know the page ID of the page we are navigating back to. 758 // We must know the page ID of the page we are navigating back to.
(...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after
2320 } 2329 }
2321 2330
2322 void RenderView::assignIdentifierToRequest( 2331 void RenderView::assignIdentifierToRequest(
2323 WebFrame* frame, unsigned identifier, const WebURLRequest& request) { 2332 WebFrame* frame, unsigned identifier, const WebURLRequest& request) {
2324 // Ignore 2333 // Ignore
2325 } 2334 }
2326 2335
2327 void RenderView::willSendRequest( 2336 void RenderView::willSendRequest(
2328 WebFrame* frame, unsigned identifier, WebURLRequest& request, 2337 WebFrame* frame, unsigned identifier, WebURLRequest& request,
2329 const WebURLResponse& redirect_response) { 2338 const WebURLResponse& redirect_response) {
2339 WebFrame* top_frame = frame->top();
2340 if (!top_frame)
2341 top_frame = frame;
2342 WebDataSource* data_source = top_frame->provisionalDataSource();
2343 if (!data_source)
2344 data_source = top_frame->dataSource();
2345 if (data_source) {
2346 NavigationState* state = NavigationState::FromDataSource(data_source);
2347 if (state && state->is_cache_policy_override_set())
2348 request.setCachePolicy(state->cache_policy_override());
2349 }
2330 request.setRequestorID(routing_id_); 2350 request.setRequestorID(routing_id_);
2331 } 2351 }
2332 2352
2333 void RenderView::didReceiveResponse( 2353 void RenderView::didReceiveResponse(
2334 WebFrame* frame, unsigned identifier, const WebURLResponse& response) { 2354 WebFrame* frame, unsigned identifier, const WebURLResponse& response) {
2335 // Consider loading an alternate error page for 404 responses. 2355 // Consider loading an alternate error page for 404 responses.
2336 if (response.httpStatusCode() != 404) 2356 if (response.httpStatusCode() != 404)
2337 return; 2357 return;
2338 2358
2339 // Only do this for responses that correspond to a provisional data source 2359 // Only do this for responses that correspond to a provisional data source
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after
3703 new PluginMsg_SignalModalDialogEvent(host_window_)); 3723 new PluginMsg_SignalModalDialogEvent(host_window_));
3704 3724
3705 message->EnableMessagePumping(); // Runs a nested message loop. 3725 message->EnableMessagePumping(); // Runs a nested message loop.
3706 bool rv = Send(message); 3726 bool rv = Send(message);
3707 3727
3708 PluginChannelHost::Broadcast( 3728 PluginChannelHost::Broadcast(
3709 new PluginMsg_ResetModalDialogEvent(host_window_)); 3729 new PluginMsg_ResetModalDialogEvent(host_window_));
3710 3730
3711 return rv; 3731 return rv;
3712 } 3732 }
OLDNEW
« no previous file with comments | « chrome/renderer/navigation_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698