OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 3074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3085 internal_data->set_is_overriding_user_agent( | 3085 internal_data->set_is_overriding_user_agent( |
3086 old_internal_data->is_overriding_user_agent()); | 3086 old_internal_data->is_overriding_user_agent()); |
3087 } | 3087 } |
3088 } | 3088 } |
3089 | 3089 |
3090 // The rest of RenderView assumes that a WebDataSource will always have a | 3090 // The rest of RenderView assumes that a WebDataSource will always have a |
3091 // non-null NavigationState. | 3091 // non-null NavigationState. |
3092 UpdateNavigationState(document_state, false /* was_within_same_page */, | 3092 UpdateNavigationState(document_state, false /* was_within_same_page */, |
3093 content_initiated); | 3093 content_initiated); |
3094 | 3094 |
3095 // DocumentState::referred_by_prefetcher_ is true if we are | |
3096 // navigating from a page that used prefetching using a link on that | |
3097 // page. We are early enough in the request process here that we | |
3098 // can still see the DocumentState of the previous page and set | |
3099 // this value appropriately. | |
3100 // TODO(gavinp): catch the important case of navigation in a new | |
3101 // renderer process. | |
3102 if (webview) { | |
3103 if (WebFrame* old_frame = webview->mainFrame()) { | |
3104 const WebURLRequest& original_request = datasource->originalRequest(); | |
3105 const GURL referrer(blink::WebStringToGURL( | |
3106 original_request.httpHeaderField(WebString::fromUTF8("Referer")))); | |
3107 if (!referrer.is_empty() && old_frame->isWebLocalFrame() && | |
3108 DocumentState::FromDataSource(old_frame->dataSource()) | |
3109 ->was_prefetcher()) { | |
3110 for (; old_frame; old_frame = old_frame->traverseNext(false)) { | |
3111 WebDataSource* old_frame_datasource = old_frame->dataSource(); | |
3112 if (old_frame_datasource && | |
3113 referrer == GURL(old_frame_datasource->request().url())) { | |
3114 document_state->set_was_referred_by_prefetcher(true); | |
3115 break; | |
3116 } | |
3117 } | |
3118 } | |
3119 } | |
3120 } | |
3121 | |
3122 if (content_initiated) { | 3095 if (content_initiated) { |
3123 const WebURLRequest& request = datasource->request(); | 3096 const WebURLRequest& request = datasource->request(); |
3124 switch (request.getCachePolicy()) { | 3097 switch (request.getCachePolicy()) { |
3125 case WebCachePolicy::UseProtocolCachePolicy: // normal load. | 3098 case WebCachePolicy::UseProtocolCachePolicy: // normal load. |
3126 document_state->set_load_type(DocumentState::LINK_LOAD_NORMAL); | 3099 document_state->set_load_type(DocumentState::LINK_LOAD_NORMAL); |
3127 break; | 3100 break; |
3128 case WebCachePolicy::ValidatingCacheData: // reload. | 3101 case WebCachePolicy::ValidatingCacheData: // reload. |
3129 case WebCachePolicy::BypassingCache: // end-to-end reload. | 3102 case WebCachePolicy::BypassingCache: // end-to-end reload. |
3130 document_state->set_load_type(DocumentState::LINK_LOAD_RELOAD); | 3103 document_state->set_load_type(DocumentState::LINK_LOAD_RELOAD); |
3131 break; | 3104 break; |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4083 if (request.getLoFiState() == WebURLRequest::LoFiUnspecified) { | 4056 if (request.getLoFiState() == WebURLRequest::LoFiUnspecified) { |
4084 if (is_main_frame_ && !navigation_state->request_committed()) { | 4057 if (is_main_frame_ && !navigation_state->request_committed()) { |
4085 request.setLoFiState(static_cast<WebURLRequest::LoFiState>( | 4058 request.setLoFiState(static_cast<WebURLRequest::LoFiState>( |
4086 navigation_state->common_params().lofi_state)); | 4059 navigation_state->common_params().lofi_state)); |
4087 } else { | 4060 } else { |
4088 request.setLoFiState( | 4061 request.setLoFiState( |
4089 is_using_lofi_ ? WebURLRequest::LoFiOn : WebURLRequest::LoFiOff); | 4062 is_using_lofi_ ? WebURLRequest::LoFiOn : WebURLRequest::LoFiOff); |
4090 } | 4063 } |
4091 } | 4064 } |
4092 | 4065 |
4093 // TODO(creis): Update prefetching to work with out-of-process iframes. | |
4094 WebFrame* top_frame = frame->top(); | |
4095 if (top_frame && top_frame->isWebLocalFrame()) { | |
4096 DocumentState* top_document_state = | |
4097 DocumentState::FromDataSource(top_frame->dataSource()); | |
4098 if (top_document_state) { | |
4099 // TODO(gavinp): separate out prefetching and prerender field trials | |
4100 // if the rel=prerender rel type is sticking around. | |
4101 if (request.getRequestContext() == WebURLRequest::RequestContextPrefetch) | |
4102 top_document_state->set_was_prefetcher(true); | |
4103 } | |
4104 } | |
4105 | |
4106 // This is an instance where we embed a copy of the routing id | 4066 // This is an instance where we embed a copy of the routing id |
4107 // into the data portion of the message. This can cause problems if we | 4067 // into the data portion of the message. This can cause problems if we |
4108 // don't register this id on the browser side, since the download manager | 4068 // don't register this id on the browser side, since the download manager |
4109 // expects to find a RenderViewHost based off the id. | 4069 // expects to find a RenderViewHost based off the id. |
4110 request.setRequestorID(render_view_->GetRoutingID()); | 4070 request.setRequestorID(render_view_->GetRoutingID()); |
4111 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture()); | 4071 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture()); |
4112 | 4072 |
4113 if (!navigation_state->start_params().extra_headers.empty()) { | 4073 if (!navigation_state->start_params().extra_headers.empty()) { |
4114 for (net::HttpUtil::HeadersIterator i( | 4074 for (net::HttpUtil::HeadersIterator i( |
4115 navigation_state->start_params().extra_headers.begin(), | 4075 navigation_state->start_params().extra_headers.begin(), |
(...skipping 2249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6365 // event target. Potentially a Pepper plugin will receive the event. | 6325 // event target. Potentially a Pepper plugin will receive the event. |
6366 // In order to tell whether a plugin gets the last mouse event and which it | 6326 // In order to tell whether a plugin gets the last mouse event and which it |
6367 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6327 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6368 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6328 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6369 // |pepper_last_mouse_event_target_|. | 6329 // |pepper_last_mouse_event_target_|. |
6370 pepper_last_mouse_event_target_ = nullptr; | 6330 pepper_last_mouse_event_target_ = nullptr; |
6371 #endif | 6331 #endif |
6372 } | 6332 } |
6373 | 6333 |
6374 } // namespace content | 6334 } // namespace content |
OLD | NEW |