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

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

Issue 9808029: Prepending view-source: does not load the source of the userscript. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Removed comments. Created 8 years, 8 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
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 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 859
860 // If this is a stale back/forward (due to a recent navigation the browser 860 // If this is a stale back/forward (due to a recent navigation the browser
861 // didn't know about), ignore it. 861 // didn't know about), ignore it.
862 if (IsBackForwardToStaleEntry(params, is_reload)) 862 if (IsBackForwardToStaleEntry(params, is_reload))
863 return; 863 return;
864 864
865 // Swap this renderer back in if necessary. 865 // Swap this renderer back in if necessary.
866 if (is_swapped_out_) 866 if (is_swapped_out_)
867 SetSwappedOut(false); 867 SetSwappedOut(false);
868 868
869 pending_allow_download_ = params.allow_download;
869 history_list_offset_ = params.current_history_list_offset; 870 history_list_offset_ = params.current_history_list_offset;
870 history_list_length_ = params.current_history_list_length; 871 history_list_length_ = params.current_history_list_length;
871 if (history_list_length_ >= 0) 872 if (history_list_length_ >= 0)
872 history_page_ids_.resize(history_list_length_, -1); 873 history_page_ids_.resize(history_list_length_, -1);
873 if (params.pending_history_list_offset >= 0 && 874 if (params.pending_history_list_offset >= 0 &&
874 params.pending_history_list_offset < history_list_length_) 875 params.pending_history_list_offset < history_list_length_)
875 history_page_ids_[params.pending_history_list_offset] = params.page_id; 876 history_page_ids_[params.pending_history_list_offset] = params.page_id;
876 877
877 content::GetContentClient()->SetActiveURL(params.url); 878 content::GetContentClient()->SetActiveURL(params.url);
878 879
879 WebFrame* main_frame = webview()->mainFrame(); 880 WebFrame* main_frame = webview()->mainFrame();
880 if (is_reload && main_frame->currentHistoryItem().isNull()) { 881 if (is_reload && main_frame->currentHistoryItem().isNull()) {
881 // We cannot reload if we do not have any history state. This happens, for 882 // We cannot reload if we do not have any history state. This happens, for
882 // example, when recovering from a crash. Our workaround here is a bit of 883 // example, when recovering from a crash. Our workaround here is a bit of
883 // a hack since it means that reload after a crashed tab does not cause an 884 // a hack since it means that reload after a crashed tab does not cause an
884 // end-to-end cache validation. 885 // end-to-end cache validation.
885 is_reload = false; 886 is_reload = false;
886 } 887 }
887 888
888 pending_navigation_params_.reset(new ViewMsg_Navigate_Params); 889 pending_navigation_params_.reset(new ViewMsg_Navigate_Params);
889 *pending_navigation_params_.get() = params; 890 *pending_navigation_params_.get() = params;
darin (slow to review) 2012/04/03 21:56:20 it seems like pending_allow_download_ should not b
chebert 2012/04/03 22:13:23 There is a call to pending_navigation_params_.rese
890 891
891 // If we are reloading, then WebKit will use the history state of the current 892 // If we are reloading, then WebKit will use the history state of the current
892 // page, so we should just ignore any given history state. Otherwise, if we 893 // page, so we should just ignore any given history state. Otherwise, if we
893 // have history state, then we need to navigate to it, which corresponds to a 894 // have history state, then we need to navigate to it, which corresponds to a
894 // back/forward navigation event. 895 // back/forward navigation event.
895 if (is_reload) { 896 if (is_reload) {
896 bool ignore_cache = (params.navigation_type == 897 bool ignore_cache = (params.navigation_type ==
897 ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE); 898 ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE);
898 main_frame->reload(ignore_cache); 899 main_frame->reload(ignore_cache);
899 } else if (!params.state.empty()) { 900 } else if (!params.state.empty()) {
(...skipping 1689 matching lines...) Expand 10 before | Expand all | Expand 10 after
2589 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_ONLY); 2590 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_ONLY);
2590 break; 2591 break;
2591 } 2592 }
2592 } 2593 }
2593 2594
2594 FOR_EACH_OBSERVER( 2595 FOR_EACH_OBSERVER(
2595 RenderViewObserver, observers_, DidCreateDataSource(frame, ds)); 2596 RenderViewObserver, observers_, DidCreateDataSource(frame, ds));
2596 } 2597 }
2597 2598
2598 void RenderViewImpl::PopulateStateFromPendingNavigationParams( 2599 void RenderViewImpl::PopulateStateFromPendingNavigationParams(
2599 DocumentState* document_state) { 2600 DocumentState* document_state) {
darin (slow to review) 2012/04/03 21:56:20 here, it seems that you could copy the allow_downl
chebert 2012/04/03 22:13:23 Would it be better to put the assignment here than
2600 const ViewMsg_Navigate_Params& params = *pending_navigation_params_.get(); 2601 const ViewMsg_Navigate_Params& params = *pending_navigation_params_.get();
2601 2602
2602 if (document_state->request_time().is_null()) 2603 if (document_state->request_time().is_null())
2603 document_state->set_request_time(params.request_time); 2604 document_state->set_request_time(params.request_time);
2604 2605
2605 // A navigation resulting from loading a javascript URL should not be treated 2606 // A navigation resulting from loading a javascript URL should not be treated
2606 // as a browser initiated event. Instead, we want it to look as if the page 2607 // as a browser initiated event. Instead, we want it to look as if the page
2607 // initiated any load resulting from JS execution. 2608 // initiated any load resulting from JS execution.
2608 if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) { 2609 if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) {
2609 NavigationState* navigation_state = NavigationState::CreateBrowserInitiated( 2610 NavigationState* navigation_state = NavigationState::CreateBrowserInitiated(
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
3035 if (!top_frame) 3036 if (!top_frame)
3036 top_frame = frame; 3037 top_frame = frame;
3037 WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); 3038 WebDataSource* provisional_data_source = top_frame->provisionalDataSource();
3038 WebDataSource* top_data_source = top_frame->dataSource(); 3039 WebDataSource* top_data_source = top_frame->dataSource();
3039 WebDataSource* data_source = 3040 WebDataSource* data_source =
3040 provisional_data_source ? provisional_data_source : top_data_source; 3041 provisional_data_source ? provisional_data_source : top_data_source;
3041 3042
3042 GURL request_url(request.url()); 3043 GURL request_url(request.url());
3043 GURL new_url; 3044 GURL new_url;
3044 if (content::GetContentClient()->renderer()->WillSendRequest( 3045 if (content::GetContentClient()->renderer()->WillSendRequest(
3045 frame, request_url, &new_url)) { 3046 frame, request_url, &new_url)) {
3046 request.setURL(WebURL(new_url)); 3047 request.setURL(WebURL(new_url));
3047 } 3048 }
3048 3049
3049 content::PageTransition transition_type = content::PAGE_TRANSITION_LINK; 3050 content::PageTransition transition_type = content::PAGE_TRANSITION_LINK;
3050 DocumentState* document_state = DocumentState::FromDataSource(data_source); 3051 DocumentState* document_state = DocumentState::FromDataSource(data_source);
3051 NavigationState* navigation_state = document_state->navigation_state(); 3052 NavigationState* navigation_state = document_state->navigation_state();
3052 if (document_state) { 3053 if (document_state) {
3053 if (document_state->is_cache_policy_override_set()) 3054 if (document_state->is_cache_policy_override_set())
3054 request.setCachePolicy(document_state->cache_policy_override()); 3055 request.setCachePolicy(document_state->cache_policy_override());
3055 transition_type = navigation_state->transition_type(); 3056 transition_type = navigation_state->transition_type();
3056 } 3057 }
3057 3058
3058 request.setExtraData( 3059 request.setExtraData(
3059 new RequestExtraData(frame->referrerPolicy(), 3060 new RequestExtraData(frame->referrerPolicy(),
3060 (frame == top_frame), 3061 (frame == top_frame),
3061 frame->identifier(), 3062 frame->identifier(),
3062 frame->parent() == top_frame, 3063 frame->parent() == top_frame,
3063 frame->parent() ? frame->parent()->identifier() : -1, 3064 frame->parent() ? frame->parent()->identifier() : -1,
3065 pending_allow_download_,
3064 transition_type, 3066 transition_type,
3065 navigation_state->transferred_request_child_id(), 3067 navigation_state->transferred_request_child_id(),
3066 navigation_state->transferred_request_request_id())); 3068 navigation_state->transferred_request_request_id()));
3067 3069
3068 DocumentState* top_document_state = 3070 DocumentState* top_document_state =
3069 DocumentState::FromDataSource(top_data_source); 3071 DocumentState::FromDataSource(top_data_source);
3070 // TODO(gavinp): separate out prefetching and prerender field trials 3072 // TODO(gavinp): separate out prefetching and prerender field trials
3071 // if the rel=prerender rel type is sticking around. 3073 // if the rel=prerender rel type is sticking around.
3072 if (top_document_state && 3074 if (top_document_state &&
3073 (request.targetType() == WebURLRequest::TargetIsPrefetch || 3075 (request.targetType() == WebURLRequest::TargetIsPrefetch ||
(...skipping 2150 matching lines...) Expand 10 before | Expand all | Expand 10 after
5224 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { 5226 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const {
5225 return !!RenderThreadImpl::current()->compositor_thread(); 5227 return !!RenderThreadImpl::current()->compositor_thread();
5226 } 5228 }
5227 5229
5228 void RenderViewImpl::OnJavaBridgeInit() { 5230 void RenderViewImpl::OnJavaBridgeInit() {
5229 DCHECK(!java_bridge_dispatcher_.get()); 5231 DCHECK(!java_bridge_dispatcher_.get());
5230 #if defined(ENABLE_JAVA_BRIDGE) 5232 #if defined(ENABLE_JAVA_BRIDGE)
5231 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); 5233 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this));
5232 #endif 5234 #endif
5233 } 5235 }
OLDNEW
« content/renderer/render_view_impl.h ('K') | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698