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 2537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2548 } | 2548 } |
2549 } | 2549 } |
2550 | 2550 |
2551 // Remember that we've already processed this request, so we don't update | 2551 // Remember that we've already processed this request, so we don't update |
2552 // the session history again. We do this regardless of whether this is | 2552 // the session history again. We do this regardless of whether this is |
2553 // a session history navigation, because if we attempted a session history | 2553 // a session history navigation, because if we attempted a session history |
2554 // navigation without valid HistoryItem state, WebCore will think it is a | 2554 // navigation without valid HistoryItem state, WebCore will think it is a |
2555 // new navigation. | 2555 // new navigation. |
2556 navigation_state->set_request_committed(true); | 2556 navigation_state->set_request_committed(true); |
2557 | 2557 |
2558 SendDidCommitProvisionalLoad(frame, commit_type); | 2558 SendDidCommitProvisionalLoad(frame); |
2559 | 2559 |
2560 // Check whether we have new encoding name. | 2560 // Check whether we have new encoding name. |
2561 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 2561 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
2562 } | 2562 } |
2563 | 2563 |
2564 void RenderFrameImpl::didCreateNewDocument(blink::WebLocalFrame* frame) { | 2564 void RenderFrameImpl::didCreateNewDocument(blink::WebLocalFrame* frame) { |
2565 DCHECK(!frame_ || frame_ == frame); | 2565 DCHECK(!frame_ || frame_ == frame); |
2566 | 2566 |
2567 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), | 2567 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), |
2568 DidCreateNewDocument(frame)); | 2568 DidCreateNewDocument(frame)); |
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3612 blink::WebPageVisibilityStateVisible, false); | 3612 blink::WebPageVisibilityStateVisible, false); |
3613 } | 3613 } |
3614 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasShown()); | 3614 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasShown()); |
3615 } | 3615 } |
3616 | 3616 |
3617 bool RenderFrameImpl::IsHidden() { | 3617 bool RenderFrameImpl::IsHidden() { |
3618 return GetRenderWidget()->is_hidden(); | 3618 return GetRenderWidget()->is_hidden(); |
3619 } | 3619 } |
3620 | 3620 |
3621 // Tell the embedding application that the URL of the active page has changed. | 3621 // Tell the embedding application that the URL of the active page has changed. |
3622 void RenderFrameImpl::SendDidCommitProvisionalLoad( | 3622 void RenderFrameImpl::SendDidCommitProvisionalLoad(blink::WebFrame* frame) { |
3623 blink::WebFrame* frame, | |
3624 blink::WebHistoryCommitType commit_type) { | |
3625 DCHECK(!frame_ || frame_ == frame); | 3623 DCHECK(!frame_ || frame_ == frame); |
3626 WebDataSource* ds = frame->dataSource(); | 3624 WebDataSource* ds = frame->dataSource(); |
3627 DCHECK(ds); | 3625 DCHECK(ds); |
3628 | 3626 |
3629 const WebURLRequest& request = ds->request(); | 3627 const WebURLRequest& request = ds->request(); |
3630 const WebURLResponse& response = ds->response(); | 3628 const WebURLResponse& response = ds->response(); |
3631 | 3629 |
3632 DocumentState* document_state = DocumentState::FromDataSource(ds); | 3630 DocumentState* document_state = DocumentState::FromDataSource(ds); |
3633 NavigationState* navigation_state = document_state->navigation_state(); | 3631 NavigationState* navigation_state = document_state->navigation_state(); |
3634 InternalDocumentStateData* internal_data = | 3632 InternalDocumentStateData* internal_data = |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3677 params.should_update_history = !ds->hasUnreachableURL() && | 3675 params.should_update_history = !ds->hasUnreachableURL() && |
3678 !response.isMultipartPayload() && (response.httpStatusCode() != 404); | 3676 !response.isMultipartPayload() && (response.httpStatusCode() != 404); |
3679 | 3677 |
3680 params.searchable_form_url = internal_data->searchable_form_url(); | 3678 params.searchable_form_url = internal_data->searchable_form_url(); |
3681 params.searchable_form_encoding = internal_data->searchable_form_encoding(); | 3679 params.searchable_form_encoding = internal_data->searchable_form_encoding(); |
3682 | 3680 |
3683 params.gesture = render_view_->navigation_gesture_; | 3681 params.gesture = render_view_->navigation_gesture_; |
3684 render_view_->navigation_gesture_ = NavigationGestureUnknown; | 3682 render_view_->navigation_gesture_ = NavigationGestureUnknown; |
3685 | 3683 |
3686 // Make navigation state a part of the DidCommitProvisionalLoad message so | 3684 // Make navigation state a part of the DidCommitProvisionalLoad message so |
3687 // that committed entry has it at all times. | 3685 // that commited entry has it at all times. |
3688 HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry(); | 3686 HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry(); |
3689 if (entry) | 3687 if (entry) |
3690 params.page_state = HistoryEntryToPageState(entry); | 3688 params.page_state = HistoryEntryToPageState(entry); |
3691 else | 3689 else |
3692 params.page_state = PageState::CreateFromURL(request.url()); | 3690 params.page_state = PageState::CreateFromURL(request.url()); |
3693 | 3691 |
3694 if (!frame->parent()) { | 3692 if (!frame->parent()) { |
3695 // Top-level navigation. | 3693 // Top-level navigation. |
3696 | 3694 |
3697 // Reset the zoom limits in case a plugin had changed them previously. This | 3695 // Reset the zoom limits in case a plugin had changed them previously. This |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3782 | 3780 |
3783 // This message needs to be sent before any of allowScripts(), | 3781 // This message needs to be sent before any of allowScripts(), |
3784 // allowImages(), allowPlugins() is called for the new page, so that when | 3782 // allowImages(), allowPlugins() is called for the new page, so that when |
3785 // these functions send a ViewHostMsg_ContentBlocked message, it arrives | 3783 // these functions send a ViewHostMsg_ContentBlocked message, it arrives |
3786 // after the FrameHostMsg_DidCommitProvisionalLoad message. | 3784 // after the FrameHostMsg_DidCommitProvisionalLoad message. |
3787 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); | 3785 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); |
3788 } else { | 3786 } else { |
3789 // Subframe navigation: the type depends on whether this navigation | 3787 // Subframe navigation: the type depends on whether this navigation |
3790 // generated a new session history entry. When they do generate a session | 3788 // generated a new session history entry. When they do generate a session |
3791 // history entry, it means the user initiated the navigation and we should | 3789 // history entry, it means the user initiated the navigation and we should |
3792 // mark it as such. | 3790 // mark it as such. This test checks if this is the first time |
3793 bool is_history_navigation = commit_type == blink::WebBackForwardCommit; | 3791 // SendDidCommitProvisionalLoad has been called since WillNavigateToURL was |
3794 if (is_history_navigation || ds->replacesCurrentHistoryItem()) | 3792 // called to initiate the load. |
| 3793 if (render_view_->page_id_ > render_view_->last_page_id_sent_to_browser_) |
| 3794 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; |
| 3795 else |
3795 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 3796 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
3796 else | |
3797 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; | |
3798 | 3797 |
3799 DCHECK(!navigation_state->history_list_was_cleared()); | 3798 DCHECK(!navigation_state->history_list_was_cleared()); |
3800 params.history_list_was_cleared = false; | 3799 params.history_list_was_cleared = false; |
3801 params.report_type = FrameMsg_UILoadMetricsReportType::NO_REPORT; | 3800 params.report_type = FrameMsg_UILoadMetricsReportType::NO_REPORT; |
3802 | 3801 |
3803 // Don't send this message while the subframe is swapped out. | 3802 // Don't send this message while the subframe is swapped out. |
3804 if (!is_swapped_out()) | 3803 if (!is_swapped_out()) |
3805 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); | 3804 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); |
3806 } | 3805 } |
3807 | 3806 |
| 3807 render_view_->last_page_id_sent_to_browser_ = |
| 3808 std::max(render_view_->last_page_id_sent_to_browser_, |
| 3809 render_view_->page_id_); |
| 3810 |
3808 // If we end up reusing this WebRequest (for example, due to a #ref click), | 3811 // If we end up reusing this WebRequest (for example, due to a #ref click), |
3809 // we don't want the transition type to persist. Just clear it. | 3812 // we don't want the transition type to persist. Just clear it. |
3810 navigation_state->set_transition_type(ui::PAGE_TRANSITION_LINK); | 3813 navigation_state->set_transition_type(ui::PAGE_TRANSITION_LINK); |
3811 } | 3814 } |
3812 | 3815 |
3813 WebElement RenderFrameImpl::GetFocusedElement() { | 3816 WebElement RenderFrameImpl::GetFocusedElement() { |
3814 WebDocument doc = frame_->document(); | 3817 WebDocument doc = frame_->document(); |
3815 if (!doc.isNull()) | 3818 if (!doc.isNull()) |
3816 return doc.focusedElement(); | 3819 return doc.focusedElement(); |
3817 | 3820 |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4437 | 4440 |
4438 #if defined(ENABLE_BROWSER_CDMS) | 4441 #if defined(ENABLE_BROWSER_CDMS) |
4439 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 4442 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
4440 if (!cdm_manager_) | 4443 if (!cdm_manager_) |
4441 cdm_manager_ = new RendererCdmManager(this); | 4444 cdm_manager_ = new RendererCdmManager(this); |
4442 return cdm_manager_; | 4445 return cdm_manager_; |
4443 } | 4446 } |
4444 #endif // defined(ENABLE_BROWSER_CDMS) | 4447 #endif // defined(ENABLE_BROWSER_CDMS) |
4445 | 4448 |
4446 } // namespace content | 4449 } // namespace content |
OLD | NEW |