| 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 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1999 // Received a redirect on the main frame. | 1999 // Received a redirect on the main frame. |
| 2000 WebDataSource* data_source = frame->provisionalDataSource(); | 2000 WebDataSource* data_source = frame->provisionalDataSource(); |
| 2001 if (!data_source) { | 2001 if (!data_source) { |
| 2002 // Should only be invoked when we have a data source. | 2002 // Should only be invoked when we have a data source. |
| 2003 NOTREACHED(); | 2003 NOTREACHED(); |
| 2004 return; | 2004 return; |
| 2005 } | 2005 } |
| 2006 std::vector<GURL> redirects; | 2006 std::vector<GURL> redirects; |
| 2007 GetRedirectChain(data_source, &redirects); | 2007 GetRedirectChain(data_source, &redirects); |
| 2008 if (redirects.size() >= 2) { | 2008 if (redirects.size() >= 2) { |
| 2009 CHECK(!render_view_->page_id_not_yet_reported_); | |
| 2010 Send(new FrameHostMsg_DidRedirectProvisionalLoad( | 2009 Send(new FrameHostMsg_DidRedirectProvisionalLoad( |
| 2011 routing_id_, | 2010 routing_id_, |
| 2012 render_view_->page_id_, | 2011 render_view_->page_id_, |
| 2013 redirects[redirects.size() - 2], | 2012 redirects[redirects.size() - 2], |
| 2014 redirects.back())); | 2013 redirects.back())); |
| 2015 } | 2014 } |
| 2016 } | 2015 } |
| 2017 | 2016 |
| 2018 void RenderFrameImpl::didFailProvisionalLoad(blink::WebLocalFrame* frame, | 2017 void RenderFrameImpl::didFailProvisionalLoad(blink::WebLocalFrame* frame, |
| 2019 const blink::WebURLError& error) { | 2018 const blink::WebURLError& error) { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2149 if (internal_data->must_reset_scroll_and_scale_state()) { | 2148 if (internal_data->must_reset_scroll_and_scale_state()) { |
| 2150 render_view_->webview()->resetScrollAndScaleState(); | 2149 render_view_->webview()->resetScrollAndScaleState(); |
| 2151 internal_data->set_must_reset_scroll_and_scale_state(false); | 2150 internal_data->set_must_reset_scroll_and_scale_state(false); |
| 2152 } | 2151 } |
| 2153 internal_data->set_use_error_page(false); | 2152 internal_data->set_use_error_page(false); |
| 2154 | 2153 |
| 2155 bool is_new_navigation = commit_type == blink::WebStandardCommit; | 2154 bool is_new_navigation = commit_type == blink::WebStandardCommit; |
| 2156 if (is_new_navigation) { | 2155 if (is_new_navigation) { |
| 2157 // We bump our Page ID to correspond with the new session history entry. | 2156 // We bump our Page ID to correspond with the new session history entry. |
| 2158 render_view_->page_id_ = render_view_->next_page_id_++; | 2157 render_view_->page_id_ = render_view_->next_page_id_++; |
| 2159 render_view_->page_id_not_yet_reported_ = true; | |
| 2160 | 2158 |
| 2161 // Don't update history_page_ids_ (etc) for kSwappedOutURL, since | 2159 // Don't update history_page_ids_ (etc) for kSwappedOutURL, since |
| 2162 // we don't want to forget the entry that was there, and since we will | 2160 // we don't want to forget the entry that was there, and since we will |
| 2163 // never come back to kSwappedOutURL. Note that we have to call | 2161 // never come back to kSwappedOutURL. Note that we have to call |
| 2164 // UpdateSessionHistory and update page_id_ even in this case, so that | 2162 // UpdateSessionHistory and update page_id_ even in this case, so that |
| 2165 // the current entry gets a state update and so that we don't send a | 2163 // the current entry gets a state update and so that we don't send a |
| 2166 // state update to the wrong entry when we swap back in. | 2164 // state update to the wrong entry when we swap back in. |
| 2167 if (GetLoadingUrl() != GURL(kSwappedOutURL)) { | 2165 if (GetLoadingUrl() != GURL(kSwappedOutURL)) { |
| 2168 // Advance our offset in session history, applying the length limit. | 2166 // Advance our offset in session history, applying the length limit. |
| 2169 // There is now no forward history. | 2167 // There is now no forward history. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2186 // per navigation. | 2184 // per navigation. |
| 2187 // | 2185 // |
| 2188 // Note that we need to check if the page ID changed. In the case of a | 2186 // Note that we need to check if the page ID changed. In the case of a |
| 2189 // reload, the page ID doesn't change, and UpdateSessionHistory gets the | 2187 // reload, the page ID doesn't change, and UpdateSessionHistory gets the |
| 2190 // previous URL and the current page ID, which would be wrong. | 2188 // previous URL and the current page ID, which would be wrong. |
| 2191 if (navigation_state->pending_page_id() != -1 && | 2189 if (navigation_state->pending_page_id() != -1 && |
| 2192 navigation_state->pending_page_id() != render_view_->page_id_ && | 2190 navigation_state->pending_page_id() != render_view_->page_id_ && |
| 2193 !navigation_state->request_committed()) { | 2191 !navigation_state->request_committed()) { |
| 2194 // This is a successful session history navigation! | 2192 // This is a successful session history navigation! |
| 2195 render_view_->page_id_ = navigation_state->pending_page_id(); | 2193 render_view_->page_id_ = navigation_state->pending_page_id(); |
| 2196 render_view_->page_id_not_yet_reported_ = true; | |
| 2197 | 2194 |
| 2198 render_view_->history_list_offset_ = | 2195 render_view_->history_list_offset_ = |
| 2199 navigation_state->pending_history_list_offset(); | 2196 navigation_state->pending_history_list_offset(); |
| 2200 | 2197 |
| 2201 // If the history list is valid, our list of page IDs should be correct. | 2198 // If the history list is valid, our list of page IDs should be correct. |
| 2202 DCHECK(render_view_->history_list_length_ <= 0 || | 2199 DCHECK(render_view_->history_list_length_ <= 0 || |
| 2203 render_view_->history_list_offset_ < 0 || | 2200 render_view_->history_list_offset_ < 0 || |
| 2204 render_view_->history_list_offset_ >= | 2201 render_view_->history_list_offset_ >= |
| 2205 render_view_->history_list_length_ || | 2202 render_view_->history_list_length_ || |
| 2206 render_view_->history_page_ids_[render_view_->history_list_offset_] | 2203 render_view_->history_page_ids_[render_view_->history_list_offset_] |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2277 const blink::WebString& title, | 2274 const blink::WebString& title, |
| 2278 blink::WebTextDirection direction) { | 2275 blink::WebTextDirection direction) { |
| 2279 DCHECK(!frame_ || frame_ == frame); | 2276 DCHECK(!frame_ || frame_ == frame); |
| 2280 // Ignore all but top level navigations. | 2277 // Ignore all but top level navigations. |
| 2281 if (!frame->parent()) { | 2278 if (!frame->parent()) { |
| 2282 base::string16 title16 = title; | 2279 base::string16 title16 = title; |
| 2283 base::debug::TraceLog::GetInstance()->UpdateProcessLabel( | 2280 base::debug::TraceLog::GetInstance()->UpdateProcessLabel( |
| 2284 routing_id_, base::UTF16ToUTF8(title16)); | 2281 routing_id_, base::UTF16ToUTF8(title16)); |
| 2285 | 2282 |
| 2286 base::string16 shortened_title = title16.substr(0, kMaxTitleChars); | 2283 base::string16 shortened_title = title16.substr(0, kMaxTitleChars); |
| 2287 CHECK(!render_view_->page_id_not_yet_reported_); | |
| 2288 Send(new FrameHostMsg_UpdateTitle(routing_id_, | 2284 Send(new FrameHostMsg_UpdateTitle(routing_id_, |
| 2289 render_view_->page_id_, | 2285 render_view_->page_id_, |
| 2290 shortened_title, direction)); | 2286 shortened_title, direction)); |
| 2291 } | 2287 } |
| 2292 | 2288 |
| 2293 // Also check whether we have new encoding name. | 2289 // Also check whether we have new encoding name. |
| 2294 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 2290 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
| 2295 } | 2291 } |
| 2296 | 2292 |
| 2297 void RenderFrameImpl::didChangeIcon(blink::WebLocalFrame* frame, | 2293 void RenderFrameImpl::didChangeIcon(blink::WebLocalFrame* frame, |
| (...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3364 else | 3360 else |
| 3365 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; | 3361 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; |
| 3366 | 3362 |
| 3367 DCHECK(!navigation_state->history_list_was_cleared()); | 3363 DCHECK(!navigation_state->history_list_was_cleared()); |
| 3368 params.history_list_was_cleared = false; | 3364 params.history_list_was_cleared = false; |
| 3369 | 3365 |
| 3370 // Don't send this message while the subframe is swapped out. | 3366 // Don't send this message while the subframe is swapped out. |
| 3371 if (!is_swapped_out()) | 3367 if (!is_swapped_out()) |
| 3372 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); | 3368 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); |
| 3373 } | 3369 } |
| 3374 render_view_->page_id_not_yet_reported_ = false; | |
| 3375 | 3370 |
| 3376 render_view_->last_page_id_sent_to_browser_ = | 3371 render_view_->last_page_id_sent_to_browser_ = |
| 3377 std::max(render_view_->last_page_id_sent_to_browser_, | 3372 std::max(render_view_->last_page_id_sent_to_browser_, |
| 3378 render_view_->page_id_); | 3373 render_view_->page_id_); |
| 3379 | 3374 |
| 3380 // If we end up reusing this WebRequest (for example, due to a #ref click), | 3375 // If we end up reusing this WebRequest (for example, due to a #ref click), |
| 3381 // we don't want the transition type to persist. Just clear it. | 3376 // we don't want the transition type to persist. Just clear it. |
| 3382 navigation_state->set_transition_type(PAGE_TRANSITION_LINK); | 3377 navigation_state->set_transition_type(PAGE_TRANSITION_LINK); |
| 3383 } | 3378 } |
| 3384 | 3379 |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3854 | 3849 |
| 3855 #if defined(ENABLE_BROWSER_CDMS) | 3850 #if defined(ENABLE_BROWSER_CDMS) |
| 3856 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 3851 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
| 3857 if (!cdm_manager_) | 3852 if (!cdm_manager_) |
| 3858 cdm_manager_ = new RendererCdmManager(this); | 3853 cdm_manager_ = new RendererCdmManager(this); |
| 3859 return cdm_manager_; | 3854 return cdm_manager_; |
| 3860 } | 3855 } |
| 3861 #endif // defined(ENABLE_BROWSER_CDMS) | 3856 #endif // defined(ENABLE_BROWSER_CDMS) |
| 3862 | 3857 |
| 3863 } // namespace content | 3858 } // namespace content |
| OLD | NEW |