| 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 2553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2564 } | 2564 } |
| 2565 } | 2565 } |
| 2566 | 2566 |
| 2567 // Remember that we've already processed this request, so we don't update | 2567 // Remember that we've already processed this request, so we don't update |
| 2568 // the session history again. We do this regardless of whether this is | 2568 // the session history again. We do this regardless of whether this is |
| 2569 // a session history navigation, because if we attempted a session history | 2569 // a session history navigation, because if we attempted a session history |
| 2570 // navigation without valid HistoryItem state, WebCore will think it is a | 2570 // navigation without valid HistoryItem state, WebCore will think it is a |
| 2571 // new navigation. | 2571 // new navigation. |
| 2572 navigation_state->set_request_committed(true); | 2572 navigation_state->set_request_committed(true); |
| 2573 | 2573 |
| 2574 SendDidCommitProvisionalLoad(frame); | 2574 SendDidCommitProvisionalLoad(frame, commit_type); |
| 2575 | 2575 |
| 2576 // Check whether we have new encoding name. | 2576 // Check whether we have new encoding name. |
| 2577 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 2577 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
| 2578 } | 2578 } |
| 2579 | 2579 |
| 2580 void RenderFrameImpl::didCreateNewDocument(blink::WebLocalFrame* frame) { | 2580 void RenderFrameImpl::didCreateNewDocument(blink::WebLocalFrame* frame) { |
| 2581 DCHECK(!frame_ || frame_ == frame); | 2581 DCHECK(!frame_ || frame_ == frame); |
| 2582 | 2582 |
| 2583 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), | 2583 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), |
| 2584 DidCreateNewDocument(frame)); | 2584 DidCreateNewDocument(frame)); |
| (...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3632 blink::WebPageVisibilityStateVisible, false); | 3632 blink::WebPageVisibilityStateVisible, false); |
| 3633 } | 3633 } |
| 3634 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasShown()); | 3634 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasShown()); |
| 3635 } | 3635 } |
| 3636 | 3636 |
| 3637 bool RenderFrameImpl::IsHidden() { | 3637 bool RenderFrameImpl::IsHidden() { |
| 3638 return GetRenderWidget()->is_hidden(); | 3638 return GetRenderWidget()->is_hidden(); |
| 3639 } | 3639 } |
| 3640 | 3640 |
| 3641 // Tell the embedding application that the URL of the active page has changed. | 3641 // Tell the embedding application that the URL of the active page has changed. |
| 3642 void RenderFrameImpl::SendDidCommitProvisionalLoad(blink::WebFrame* frame) { | 3642 void RenderFrameImpl::SendDidCommitProvisionalLoad( |
| 3643 blink::WebFrame* frame, |
| 3644 blink::WebHistoryCommitType commit_type) { |
| 3643 DCHECK(!frame_ || frame_ == frame); | 3645 DCHECK(!frame_ || frame_ == frame); |
| 3644 WebDataSource* ds = frame->dataSource(); | 3646 WebDataSource* ds = frame->dataSource(); |
| 3645 DCHECK(ds); | 3647 DCHECK(ds); |
| 3646 | 3648 |
| 3647 const WebURLRequest& request = ds->request(); | 3649 const WebURLRequest& request = ds->request(); |
| 3648 const WebURLResponse& response = ds->response(); | 3650 const WebURLResponse& response = ds->response(); |
| 3649 | 3651 |
| 3650 DocumentState* document_state = DocumentState::FromDataSource(ds); | 3652 DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 3651 NavigationState* navigation_state = document_state->navigation_state(); | 3653 NavigationState* navigation_state = document_state->navigation_state(); |
| 3652 InternalDocumentStateData* internal_data = | 3654 InternalDocumentStateData* internal_data = |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3695 params.should_update_history = !ds->hasUnreachableURL() && | 3697 params.should_update_history = !ds->hasUnreachableURL() && |
| 3696 !response.isMultipartPayload() && (response.httpStatusCode() != 404); | 3698 !response.isMultipartPayload() && (response.httpStatusCode() != 404); |
| 3697 | 3699 |
| 3698 params.searchable_form_url = internal_data->searchable_form_url(); | 3700 params.searchable_form_url = internal_data->searchable_form_url(); |
| 3699 params.searchable_form_encoding = internal_data->searchable_form_encoding(); | 3701 params.searchable_form_encoding = internal_data->searchable_form_encoding(); |
| 3700 | 3702 |
| 3701 params.gesture = render_view_->navigation_gesture_; | 3703 params.gesture = render_view_->navigation_gesture_; |
| 3702 render_view_->navigation_gesture_ = NavigationGestureUnknown; | 3704 render_view_->navigation_gesture_ = NavigationGestureUnknown; |
| 3703 | 3705 |
| 3704 // Make navigation state a part of the DidCommitProvisionalLoad message so | 3706 // Make navigation state a part of the DidCommitProvisionalLoad message so |
| 3705 // that commited entry has it at all times. | 3707 // that committed entry has it at all times. |
| 3706 HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry(); | 3708 HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry(); |
| 3707 if (entry) | 3709 if (entry) |
| 3708 params.page_state = HistoryEntryToPageState(entry); | 3710 params.page_state = HistoryEntryToPageState(entry); |
| 3709 else | 3711 else |
| 3710 params.page_state = PageState::CreateFromURL(request.url()); | 3712 params.page_state = PageState::CreateFromURL(request.url()); |
| 3711 | 3713 |
| 3712 if (!frame->parent()) { | 3714 if (!frame->parent()) { |
| 3713 // Top-level navigation. | 3715 // Top-level navigation. |
| 3714 | 3716 |
| 3715 // Reset the zoom limits in case a plugin had changed them previously. This | 3717 // 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... |
| 3800 | 3802 |
| 3801 // This message needs to be sent before any of allowScripts(), | 3803 // This message needs to be sent before any of allowScripts(), |
| 3802 // allowImages(), allowPlugins() is called for the new page, so that when | 3804 // allowImages(), allowPlugins() is called for the new page, so that when |
| 3803 // these functions send a ViewHostMsg_ContentBlocked message, it arrives | 3805 // these functions send a ViewHostMsg_ContentBlocked message, it arrives |
| 3804 // after the FrameHostMsg_DidCommitProvisionalLoad message. | 3806 // after the FrameHostMsg_DidCommitProvisionalLoad message. |
| 3805 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); | 3807 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); |
| 3806 } else { | 3808 } else { |
| 3807 // Subframe navigation: the type depends on whether this navigation | 3809 // Subframe navigation: the type depends on whether this navigation |
| 3808 // generated a new session history entry. When they do generate a session | 3810 // generated a new session history entry. When they do generate a session |
| 3809 // history entry, it means the user initiated the navigation and we should | 3811 // history entry, it means the user initiated the navigation and we should |
| 3810 // mark it as such. This test checks if this is the first time | 3812 // mark it as such. |
| 3811 // SendDidCommitProvisionalLoad has been called since WillNavigateToURL was | 3813 bool is_history_navigation = commit_type == blink::WebBackForwardCommit; |
| 3812 // called to initiate the load. | 3814 if (is_history_navigation || ds->replacesCurrentHistoryItem()) |
| 3813 if (render_view_->page_id_ > render_view_->last_page_id_sent_to_browser_) | 3815 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
| 3816 else |
| 3814 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; | 3817 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; |
| 3815 else | |
| 3816 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | |
| 3817 | 3818 |
| 3818 DCHECK(!navigation_state->history_list_was_cleared()); | 3819 DCHECK(!navigation_state->history_list_was_cleared()); |
| 3819 params.history_list_was_cleared = false; | 3820 params.history_list_was_cleared = false; |
| 3820 params.report_type = FrameMsg_UILoadMetricsReportType::NO_REPORT; | 3821 params.report_type = FrameMsg_UILoadMetricsReportType::NO_REPORT; |
| 3821 | 3822 |
| 3822 // Don't send this message while the subframe is swapped out. | 3823 // Don't send this message while the subframe is swapped out. |
| 3823 if (!is_swapped_out()) | 3824 if (!is_swapped_out()) |
| 3824 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); | 3825 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); |
| 3825 } | 3826 } |
| 3826 | 3827 |
| 3827 render_view_->last_page_id_sent_to_browser_ = | |
| 3828 std::max(render_view_->last_page_id_sent_to_browser_, | |
| 3829 render_view_->page_id_); | |
| 3830 | |
| 3831 // If we end up reusing this WebRequest (for example, due to a #ref click), | 3828 // If we end up reusing this WebRequest (for example, due to a #ref click), |
| 3832 // we don't want the transition type to persist. Just clear it. | 3829 // we don't want the transition type to persist. Just clear it. |
| 3833 navigation_state->set_transition_type(ui::PAGE_TRANSITION_LINK); | 3830 navigation_state->set_transition_type(ui::PAGE_TRANSITION_LINK); |
| 3834 } | 3831 } |
| 3835 | 3832 |
| 3836 WebElement RenderFrameImpl::GetFocusedElement() { | 3833 WebElement RenderFrameImpl::GetFocusedElement() { |
| 3837 WebDocument doc = frame_->document(); | 3834 WebDocument doc = frame_->document(); |
| 3838 if (!doc.isNull()) | 3835 if (!doc.isNull()) |
| 3839 return doc.focusedElement(); | 3836 return doc.focusedElement(); |
| 3840 | 3837 |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4461 | 4458 |
| 4462 #if defined(ENABLE_BROWSER_CDMS) | 4459 #if defined(ENABLE_BROWSER_CDMS) |
| 4463 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 4460 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
| 4464 if (!cdm_manager_) | 4461 if (!cdm_manager_) |
| 4465 cdm_manager_ = new RendererCdmManager(this); | 4462 cdm_manager_ = new RendererCdmManager(this); |
| 4466 return cdm_manager_; | 4463 return cdm_manager_; |
| 4467 } | 4464 } |
| 4468 #endif // defined(ENABLE_BROWSER_CDMS) | 4465 #endif // defined(ENABLE_BROWSER_CDMS) |
| 4469 | 4466 |
| 4470 } // namespace content | 4467 } // namespace content |
| OLD | NEW |