| 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 1867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1878 } | 1878 } |
| 1879 | 1879 |
| 1880 void RenderFrameImpl::didCommitProvisionalLoad( | 1880 void RenderFrameImpl::didCommitProvisionalLoad( |
| 1881 blink::WebLocalFrame* frame, | 1881 blink::WebLocalFrame* frame, |
| 1882 const blink::WebHistoryItem& item, | 1882 const blink::WebHistoryItem& item, |
| 1883 blink::WebHistoryCommitType commit_type) { | 1883 blink::WebHistoryCommitType commit_type) { |
| 1884 DCHECK(!frame_ || frame_ == frame); | 1884 DCHECK(!frame_ || frame_ == frame); |
| 1885 DocumentState* document_state = | 1885 DocumentState* document_state = |
| 1886 DocumentState::FromDataSource(frame->dataSource()); | 1886 DocumentState::FromDataSource(frame->dataSource()); |
| 1887 NavigationState* navigation_state = document_state->navigation_state(); | 1887 NavigationState* navigation_state = document_state->navigation_state(); |
| 1888 |
| 1889 // When we perform a new navigation, we need to update the last committed |
| 1890 // session history entry with state for the page we are leaving. Do this |
| 1891 // before updating the HistoryController state. |
| 1892 render_view_->UpdateSessionHistory(frame); |
| 1893 |
| 1888 render_view_->history_controller()->UpdateForCommit(this, item, commit_type, | 1894 render_view_->history_controller()->UpdateForCommit(this, item, commit_type, |
| 1889 navigation_state->was_within_same_page()); | 1895 navigation_state->was_within_same_page()); |
| 1890 | 1896 |
| 1891 InternalDocumentStateData* internal_data = | 1897 InternalDocumentStateData* internal_data = |
| 1892 InternalDocumentStateData::FromDocumentState(document_state); | 1898 InternalDocumentStateData::FromDocumentState(document_state); |
| 1893 | 1899 |
| 1894 if (document_state->commit_load_time().is_null()) | 1900 if (document_state->commit_load_time().is_null()) |
| 1895 document_state->set_commit_load_time(Time::Now()); | 1901 document_state->set_commit_load_time(Time::Now()); |
| 1896 | 1902 |
| 1897 if (internal_data->must_reset_scroll_and_scale_state()) { | 1903 if (internal_data->must_reset_scroll_and_scale_state()) { |
| 1898 render_view_->webview()->resetScrollAndScaleState(); | 1904 render_view_->webview()->resetScrollAndScaleState(); |
| 1899 internal_data->set_must_reset_scroll_and_scale_state(false); | 1905 internal_data->set_must_reset_scroll_and_scale_state(false); |
| 1900 } | 1906 } |
| 1901 internal_data->set_use_error_page(false); | 1907 internal_data->set_use_error_page(false); |
| 1902 | 1908 |
| 1903 bool is_new_navigation = commit_type == blink::WebStandardCommit; | 1909 bool is_new_navigation = commit_type == blink::WebStandardCommit; |
| 1904 if (is_new_navigation) { | 1910 if (is_new_navigation) { |
| 1905 // When we perform a new navigation, we need to update the last committed | |
| 1906 // session history entry with state for the page we are leaving. | |
| 1907 render_view_->UpdateSessionHistory(frame); | |
| 1908 | |
| 1909 // We bump our Page ID to correspond with the new session history entry. | 1911 // We bump our Page ID to correspond with the new session history entry. |
| 1910 render_view_->page_id_ = render_view_->next_page_id_++; | 1912 render_view_->page_id_ = render_view_->next_page_id_++; |
| 1911 | 1913 |
| 1912 // Don't update history_page_ids_ (etc) for kSwappedOutURL, since | 1914 // Don't update history_page_ids_ (etc) for kSwappedOutURL, since |
| 1913 // we don't want to forget the entry that was there, and since we will | 1915 // we don't want to forget the entry that was there, and since we will |
| 1914 // never come back to kSwappedOutURL. Note that we have to call | 1916 // never come back to kSwappedOutURL. Note that we have to call |
| 1915 // UpdateSessionHistory and update page_id_ even in this case, so that | 1917 // UpdateSessionHistory and update page_id_ even in this case, so that |
| 1916 // the current entry gets a state update and so that we don't send a | 1918 // the current entry gets a state update and so that we don't send a |
| 1917 // state update to the wrong entry when we swap back in. | 1919 // state update to the wrong entry when we swap back in. |
| 1918 if (render_view_->GetLoadingUrl(frame) != GURL(kSwappedOutURL)) { | 1920 if (render_view_->GetLoadingUrl(frame) != GURL(kSwappedOutURL)) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1936 // we've seen this commit before so that only capture session history once | 1938 // we've seen this commit before so that only capture session history once |
| 1937 // per navigation. | 1939 // per navigation. |
| 1938 // | 1940 // |
| 1939 // Note that we need to check if the page ID changed. In the case of a | 1941 // Note that we need to check if the page ID changed. In the case of a |
| 1940 // reload, the page ID doesn't change, and UpdateSessionHistory gets the | 1942 // reload, the page ID doesn't change, and UpdateSessionHistory gets the |
| 1941 // previous URL and the current page ID, which would be wrong. | 1943 // previous URL and the current page ID, which would be wrong. |
| 1942 if (navigation_state->pending_page_id() != -1 && | 1944 if (navigation_state->pending_page_id() != -1 && |
| 1943 navigation_state->pending_page_id() != render_view_->page_id_ && | 1945 navigation_state->pending_page_id() != render_view_->page_id_ && |
| 1944 !navigation_state->request_committed()) { | 1946 !navigation_state->request_committed()) { |
| 1945 // This is a successful session history navigation! | 1947 // This is a successful session history navigation! |
| 1946 render_view_->UpdateSessionHistory(frame); | |
| 1947 render_view_->page_id_ = navigation_state->pending_page_id(); | 1948 render_view_->page_id_ = navigation_state->pending_page_id(); |
| 1948 | 1949 |
| 1949 render_view_->history_list_offset_ = | 1950 render_view_->history_list_offset_ = |
| 1950 navigation_state->pending_history_list_offset(); | 1951 navigation_state->pending_history_list_offset(); |
| 1951 | 1952 |
| 1952 // If the history list is valid, our list of page IDs should be correct. | 1953 // If the history list is valid, our list of page IDs should be correct. |
| 1953 DCHECK(render_view_->history_list_length_ <= 0 || | 1954 DCHECK(render_view_->history_list_length_ <= 0 || |
| 1954 render_view_->history_list_offset_ < 0 || | 1955 render_view_->history_list_offset_ < 0 || |
| 1955 render_view_->history_list_offset_ >= | 1956 render_view_->history_list_offset_ >= |
| 1956 render_view_->history_list_length_ || | 1957 render_view_->history_list_length_ || |
| (...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3470 weak_factory_.GetWeakPtr(), | 3471 weak_factory_.GetWeakPtr(), |
| 3471 render_view_->media_player_manager_, | 3472 render_view_->media_player_manager_, |
| 3472 stream_texture_factory, | 3473 stream_texture_factory, |
| 3473 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy(), | 3474 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy(), |
| 3474 new RenderMediaLog()); | 3475 new RenderMediaLog()); |
| 3475 } | 3476 } |
| 3476 | 3477 |
| 3477 #endif | 3478 #endif |
| 3478 | 3479 |
| 3479 } // namespace content | 3480 } // namespace content |
| OLD | NEW |