| 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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 | 322 |
| 323 return item.httpBody().identifier(); | 323 return item.httpBody().identifier(); |
| 324 } | 324 } |
| 325 | 325 |
| 326 WebURLResponseExtraDataImpl* GetExtraDataFromResponse( | 326 WebURLResponseExtraDataImpl* GetExtraDataFromResponse( |
| 327 const WebURLResponse& response) { | 327 const WebURLResponse& response) { |
| 328 return static_cast<WebURLResponseExtraDataImpl*>(response.getExtraData()); | 328 return static_cast<WebURLResponseExtraDataImpl*>(response.getExtraData()); |
| 329 } | 329 } |
| 330 | 330 |
| 331 void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { | 331 void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { |
| 332 // Replace any occurrences of swappedout:// with about:blank. | |
| 333 const WebURL& blank_url = GURL(url::kAboutBlankURL); | |
| 334 WebVector<WebURL> urls; | 332 WebVector<WebURL> urls; |
| 335 ds->redirectChain(urls); | 333 ds->redirectChain(urls); |
| 336 result->reserve(urls.size()); | 334 result->reserve(urls.size()); |
| 337 for (size_t i = 0; i < urls.size(); ++i) { | 335 for (size_t i = 0; i < urls.size(); ++i) { |
| 338 if (urls[i] != GURL(kSwappedOutURL)) | 336 result->push_back(urls[i]); |
| 339 result->push_back(urls[i]); | |
| 340 else | |
| 341 result->push_back(blank_url); | |
| 342 } | 337 } |
| 343 } | 338 } |
| 344 | 339 |
| 345 // Gets URL that should override the default getter for this data source | 340 // Gets URL that should override the default getter for this data source |
| 346 // (if any), storing it in |output|. Returns true if there is an override URL. | 341 // (if any), storing it in |output|. Returns true if there is an override URL. |
| 347 bool MaybeGetOverriddenURL(WebDataSource* ds, GURL* output) { | 342 bool MaybeGetOverriddenURL(WebDataSource* ds, GURL* output) { |
| 348 DocumentState* document_state = DocumentState::FromDataSource(ds); | 343 DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 349 | 344 |
| 350 // If load was from a data URL, then the saved data URL, not the history | 345 // If load was from a data URL, then the saved data URL, not the history |
| 351 // URL, should be the URL of the data source. | 346 // URL, should be the URL of the data source. |
| (...skipping 2618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2970 // In fast/loader/stop-provisional-loads.html, we abort the load before this | 2965 // In fast/loader/stop-provisional-loads.html, we abort the load before this |
| 2971 // callback is invoked. | 2966 // callback is invoked. |
| 2972 if (!ds) | 2967 if (!ds) |
| 2973 return; | 2968 return; |
| 2974 | 2969 |
| 2975 TRACE_EVENT2("navigation,benchmark", | 2970 TRACE_EVENT2("navigation,benchmark", |
| 2976 "RenderFrameImpl::didStartProvisionalLoad", "id", routing_id_, | 2971 "RenderFrameImpl::didStartProvisionalLoad", "id", routing_id_, |
| 2977 "url", ds->request().url().string().utf8()); | 2972 "url", ds->request().url().string().utf8()); |
| 2978 DocumentState* document_state = DocumentState::FromDataSource(ds); | 2973 DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 2979 | 2974 |
| 2980 // We should never navigate to swappedout://. | |
| 2981 CHECK(ds->request().url() != GURL(kSwappedOutURL)) << "Heard swappedout://."; | |
| 2982 | |
| 2983 // Update the request time if WebKit has better knowledge of it. | 2975 // Update the request time if WebKit has better knowledge of it. |
| 2984 if (document_state->request_time().is_null() && | 2976 if (document_state->request_time().is_null() && |
| 2985 triggering_event_time != 0.0) { | 2977 triggering_event_time != 0.0) { |
| 2986 document_state->set_request_time(Time::FromDoubleT(triggering_event_time)); | 2978 document_state->set_request_time(Time::FromDoubleT(triggering_event_time)); |
| 2987 } | 2979 } |
| 2988 | 2980 |
| 2989 // Start time is only set after request time. | 2981 // Start time is only set after request time. |
| 2990 document_state->set_start_load_time(Time::Now()); | 2982 document_state->set_start_load_time(Time::Now()); |
| 2991 | 2983 |
| 2992 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>( | 2984 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>( |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3172 if (internal_data->must_reset_scroll_and_scale_state()) { | 3164 if (internal_data->must_reset_scroll_and_scale_state()) { |
| 3173 render_view_->webview()->resetScrollAndScaleState(); | 3165 render_view_->webview()->resetScrollAndScaleState(); |
| 3174 internal_data->set_must_reset_scroll_and_scale_state(false); | 3166 internal_data->set_must_reset_scroll_and_scale_state(false); |
| 3175 } | 3167 } |
| 3176 | 3168 |
| 3177 bool is_new_navigation = commit_type == blink::WebStandardCommit; | 3169 bool is_new_navigation = commit_type == blink::WebStandardCommit; |
| 3178 if (is_new_navigation) { | 3170 if (is_new_navigation) { |
| 3179 // We bump our Page ID to correspond with the new session history entry. | 3171 // We bump our Page ID to correspond with the new session history entry. |
| 3180 render_view_->page_id_ = render_view_->next_page_id_++; | 3172 render_view_->page_id_ = render_view_->next_page_id_++; |
| 3181 | 3173 |
| 3182 // Don't update history list values for kSwappedOutURL, since | |
| 3183 // we don't want to forget the entry that was there, and since we will | |
| 3184 // never come back to kSwappedOutURL. Note that we have to call | |
| 3185 // SendUpdateState and update page_id_ even in this case, so that | |
| 3186 // the current entry gets a state update and so that we don't send a | |
| 3187 // state update to the wrong entry when we swap back in. | |
| 3188 DCHECK(!navigation_state->common_params().should_replace_current_entry || | 3174 DCHECK(!navigation_state->common_params().should_replace_current_entry || |
| 3189 render_view_->history_list_length_ > 0); | 3175 render_view_->history_list_length_ > 0); |
| 3190 if (GetLoadingUrl() != GURL(kSwappedOutURL) && | 3176 if (!navigation_state->common_params().should_replace_current_entry) { |
| 3191 !navigation_state->common_params().should_replace_current_entry) { | |
| 3192 // Advance our offset in session history, applying the length limit. | 3177 // Advance our offset in session history, applying the length limit. |
| 3193 // There is now no forward history. | 3178 // There is now no forward history. |
| 3194 render_view_->history_list_offset_++; | 3179 render_view_->history_list_offset_++; |
| 3195 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) | 3180 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) |
| 3196 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; | 3181 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; |
| 3197 render_view_->history_list_length_ = | 3182 render_view_->history_list_length_ = |
| 3198 render_view_->history_list_offset_ + 1; | 3183 render_view_->history_list_offset_ + 1; |
| 3199 } | 3184 } |
| 3200 } else { | 3185 } else { |
| 3201 const RequestNavigationParams& request_params = | 3186 const RequestNavigationParams& request_params = |
| (...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4695 ->IsContentInitiated() | 4680 ->IsContentInitiated() |
| 4696 : !IsBrowserInitiated(pending_navigation_params_.get()); | 4681 : !IsBrowserInitiated(pending_navigation_params_.get()); |
| 4697 bool is_redirect = | 4682 bool is_redirect = |
| 4698 info.extraData || | 4683 info.extraData || |
| 4699 (pending_navigation_params_ && | 4684 (pending_navigation_params_ && |
| 4700 !pending_navigation_params_->request_params.redirects.empty()); | 4685 !pending_navigation_params_->request_params.redirects.empty()); |
| 4701 | 4686 |
| 4702 #ifdef OS_ANDROID | 4687 #ifdef OS_ANDROID |
| 4703 // The handlenavigation API is deprecated and will be removed once | 4688 // The handlenavigation API is deprecated and will be removed once |
| 4704 // crbug.com/325351 is resolved. | 4689 // crbug.com/325351 is resolved. |
| 4705 if (info.urlRequest.url() != GURL(kSwappedOutURL) && | 4690 if (GetContentClient()->renderer()->HandleNavigation( |
| 4706 GetContentClient()->renderer()->HandleNavigation( | |
| 4707 this, is_content_initiated, render_view_->opener_id_, frame_, | 4691 this, is_content_initiated, render_view_->opener_id_, frame_, |
| 4708 info.urlRequest, info.navigationType, info.defaultPolicy, | 4692 info.urlRequest, info.navigationType, info.defaultPolicy, |
| 4709 is_redirect)) { | 4693 is_redirect)) { |
| 4710 return blink::WebNavigationPolicyIgnore; | 4694 return blink::WebNavigationPolicyIgnore; |
| 4711 } | 4695 } |
| 4712 #endif | 4696 #endif |
| 4713 | 4697 |
| 4714 Referrer referrer( | 4698 Referrer referrer( |
| 4715 RenderViewImpl::GetReferrerFromRequest(frame_, info.urlRequest)); | 4699 RenderViewImpl::GetReferrerFromRequest(frame_, info.urlRequest)); |
| 4716 | 4700 |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5312 } else if (is_history_navigation) { | 5296 } else if (is_history_navigation) { |
| 5313 // We must know the page ID of the page we are navigating back to. | 5297 // We must know the page ID of the page we are navigating back to. |
| 5314 DCHECK_NE(request_params.page_id, -1); | 5298 DCHECK_NE(request_params.page_id, -1); |
| 5315 // We must know the nav entry ID of the page we are navigating back to, | 5299 // We must know the nav entry ID of the page we are navigating back to, |
| 5316 // which should be the case because history navigations are routed via the | 5300 // which should be the case because history navigations are routed via the |
| 5317 // browser. | 5301 // browser. |
| 5318 DCHECK_NE(0, request_params.nav_entry_id); | 5302 DCHECK_NE(0, request_params.nav_entry_id); |
| 5319 scoped_ptr<HistoryEntry> entry = | 5303 scoped_ptr<HistoryEntry> entry = |
| 5320 PageStateToHistoryEntry(request_params.page_state); | 5304 PageStateToHistoryEntry(request_params.page_state); |
| 5321 if (entry) { | 5305 if (entry) { |
| 5322 // Ensure we didn't save the swapped out URL in UpdateState, since the | |
| 5323 // browser should never be telling us to navigate to swappedout://. | |
| 5324 CHECK(entry->root().urlString() != kSwappedOutURL); | |
| 5325 | |
| 5326 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 5306 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| 5327 // By default, tell the HistoryController to go the deserialized | 5307 // By default, tell the HistoryController to go the deserialized |
| 5328 // HistoryEntry. This only works if all frames are in the same | 5308 // HistoryEntry. This only works if all frames are in the same |
| 5329 // process. | 5309 // process. |
| 5330 DCHECK(!frame_->parent()); | 5310 DCHECK(!frame_->parent()); |
| 5331 DCHECK(!browser_side_navigation); | 5311 DCHECK(!browser_side_navigation); |
| 5332 scoped_ptr<NavigationParams> navigation_params( | 5312 scoped_ptr<NavigationParams> navigation_params( |
| 5333 new NavigationParams(*pending_navigation_params_.get())); | 5313 new NavigationParams(*pending_navigation_params_.get())); |
| 5334 has_history_navigation_in_frame = | 5314 has_history_navigation_in_frame = |
| 5335 render_view_->history_controller()->GoToEntry( | 5315 render_view_->history_controller()->GoToEntry( |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6025 int match_count, | 6005 int match_count, |
| 6026 int ordinal, | 6006 int ordinal, |
| 6027 const WebRect& selection_rect, | 6007 const WebRect& selection_rect, |
| 6028 bool final_status_update) { | 6008 bool final_status_update) { |
| 6029 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | 6009 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, |
| 6030 selection_rect, ordinal, | 6010 selection_rect, ordinal, |
| 6031 final_status_update)); | 6011 final_status_update)); |
| 6032 } | 6012 } |
| 6033 | 6013 |
| 6034 } // namespace content | 6014 } // namespace content |
| OLD | NEW |