| 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 2949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2960 InternalDocumentStateData::FromDocumentState(document_state); | 2960 InternalDocumentStateData::FromDocumentState(document_state); |
| 2961 InternalDocumentStateData* old_internal_data = | 2961 InternalDocumentStateData* old_internal_data = |
| 2962 InternalDocumentStateData::FromDocumentState(old_document_state); | 2962 InternalDocumentStateData::FromDocumentState(old_document_state); |
| 2963 internal_data->set_is_overriding_user_agent( | 2963 internal_data->set_is_overriding_user_agent( |
| 2964 old_internal_data->is_overriding_user_agent()); | 2964 old_internal_data->is_overriding_user_agent()); |
| 2965 } | 2965 } |
| 2966 } | 2966 } |
| 2967 | 2967 |
| 2968 // The rest of RenderView assumes that a WebDataSource will always have a | 2968 // The rest of RenderView assumes that a WebDataSource will always have a |
| 2969 // non-null NavigationState. | 2969 // non-null NavigationState. |
| 2970 UpdateNavigationState(document_state, false /* was_within_same_page */); | 2970 UpdateNavigationState(document_state, false /* was_within_same_page */, |
| 2971 content_initiated); |
| 2971 | 2972 |
| 2972 // DocumentState::referred_by_prefetcher_ is true if we are | 2973 // DocumentState::referred_by_prefetcher_ is true if we are |
| 2973 // navigating from a page that used prefetching using a link on that | 2974 // navigating from a page that used prefetching using a link on that |
| 2974 // page. We are early enough in the request process here that we | 2975 // page. We are early enough in the request process here that we |
| 2975 // can still see the DocumentState of the previous page and set | 2976 // can still see the DocumentState of the previous page and set |
| 2976 // this value appropriately. | 2977 // this value appropriately. |
| 2977 // TODO(gavinp): catch the important case of navigation in a new | 2978 // TODO(gavinp): catch the important case of navigation in a new |
| 2978 // renderer process. | 2979 // renderer process. |
| 2979 if (webview) { | 2980 if (webview) { |
| 2980 if (WebFrame* old_frame = webview->mainFrame()) { | 2981 if (WebFrame* old_frame = webview->mainFrame()) { |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3559 } | 3560 } |
| 3560 | 3561 |
| 3561 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), | 3562 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), |
| 3562 DidFinishLoad(frame)); | 3563 DidFinishLoad(frame)); |
| 3563 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidFinishLoad()); | 3564 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidFinishLoad()); |
| 3564 | 3565 |
| 3565 Send(new FrameHostMsg_DidFinishLoad(routing_id_, | 3566 Send(new FrameHostMsg_DidFinishLoad(routing_id_, |
| 3566 ds->request().url())); | 3567 ds->request().url())); |
| 3567 } | 3568 } |
| 3568 | 3569 |
| 3569 void RenderFrameImpl::didNavigateWithinPage(blink::WebLocalFrame* frame, | 3570 void RenderFrameImpl::didNavigateWithinPage( |
| 3571 blink::WebLocalFrame* frame, |
| 3570 const blink::WebHistoryItem& item, | 3572 const blink::WebHistoryItem& item, |
| 3571 blink::WebHistoryCommitType commit_type) { | 3573 blink::WebHistoryCommitType commit_type, |
| 3574 bool content_initiated) { |
| 3572 TRACE_EVENT1("navigation", "RenderFrameImpl::didNavigateWithinPage", | 3575 TRACE_EVENT1("navigation", "RenderFrameImpl::didNavigateWithinPage", |
| 3573 "id", routing_id_); | 3576 "id", routing_id_); |
| 3574 DCHECK_EQ(frame_, frame); | 3577 DCHECK_EQ(frame_, frame); |
| 3575 // If this was a reference fragment navigation that we initiated, then we | |
| 3576 // could end up having a non-null pending navigation params. We just need to | |
| 3577 // update the ExtraData on the datasource so that others who read the | |
| 3578 // ExtraData will get the new NavigationState. Similarly, if we did not | |
| 3579 // initiate this navigation, then we need to take care to reset any pre- | |
| 3580 // existing navigation state to a content-initiated navigation state. | |
| 3581 // UpdateNavigationState conveniently takes care of this for us. | |
| 3582 DocumentState* document_state = | 3578 DocumentState* document_state = |
| 3583 DocumentState::FromDataSource(frame->dataSource()); | 3579 DocumentState::FromDataSource(frame->dataSource()); |
| 3584 UpdateNavigationState(document_state, true /* was_within_same_page */); | 3580 UpdateNavigationState(document_state, true /* was_within_same_page */, |
| 3581 content_initiated); |
| 3585 static_cast<NavigationStateImpl*>(document_state->navigation_state()) | 3582 static_cast<NavigationStateImpl*>(document_state->navigation_state()) |
| 3586 ->set_was_within_same_page(true); | 3583 ->set_was_within_same_page(true); |
| 3587 | 3584 |
| 3588 didCommitProvisionalLoad(frame, item, commit_type); | 3585 didCommitProvisionalLoad(frame, item, commit_type); |
| 3589 } | 3586 } |
| 3590 | 3587 |
| 3591 void RenderFrameImpl::didUpdateCurrentHistoryItem() { | 3588 void RenderFrameImpl::didUpdateCurrentHistoryItem() { |
| 3592 render_view_->StartNavStateSyncTimerIfNecessary(this); | 3589 render_view_->StartNavStateSyncTimerIfNecessary(this); |
| 3593 } | 3590 } |
| 3594 | 3591 |
| (...skipping 2287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5882 if (IsBrowserInitiated(pending_navigation_params_.get())) { | 5879 if (IsBrowserInitiated(pending_navigation_params_.get())) { |
| 5883 return NavigationStateImpl::CreateBrowserInitiated( | 5880 return NavigationStateImpl::CreateBrowserInitiated( |
| 5884 pending_navigation_params_->common_params, | 5881 pending_navigation_params_->common_params, |
| 5885 pending_navigation_params_->start_params, | 5882 pending_navigation_params_->start_params, |
| 5886 pending_navigation_params_->request_params); | 5883 pending_navigation_params_->request_params); |
| 5887 } | 5884 } |
| 5888 return NavigationStateImpl::CreateContentInitiated(); | 5885 return NavigationStateImpl::CreateContentInitiated(); |
| 5889 } | 5886 } |
| 5890 | 5887 |
| 5891 void RenderFrameImpl::UpdateNavigationState(DocumentState* document_state, | 5888 void RenderFrameImpl::UpdateNavigationState(DocumentState* document_state, |
| 5892 bool was_within_same_page) { | 5889 bool was_within_same_page, |
| 5893 if (pending_navigation_params_) { | 5890 bool content_initiated) { |
| 5894 // If this is a browser-initiated load that doesn't override | 5891 // If this was a browser-initiated navigation, then there could be pending |
| 5895 // navigation_start, set it here. | 5892 // navigation params, so use them. Otherwise, just reset the document state |
| 5896 if (pending_navigation_params_->common_params.navigation_start.is_null()) { | 5893 // here, since if pending navigation params exist they are for some other |
| 5897 pending_navigation_params_->common_params.navigation_start = | 5894 // navigation <https://crbug.com/597239>. |
| 5898 base::TimeTicks::Now(); | 5895 if (!pending_navigation_params_ || content_initiated) { |
| 5899 } | |
| 5900 document_state->set_navigation_state(CreateNavigationStateFromPending()); | |
| 5901 | |
| 5902 // The |set_was_load_data_with_base_url_request| state should not change for | |
| 5903 // an in-page navigation, so skip updating it from the in-page navigation | |
| 5904 // params in this case. | |
| 5905 if (!was_within_same_page) { | |
| 5906 const CommonNavigationParams& common_params = | |
| 5907 pending_navigation_params_->common_params; | |
| 5908 bool load_data = !common_params.base_url_for_data_url.is_empty() && | |
| 5909 !common_params.history_url_for_data_url.is_empty() && | |
| 5910 common_params.url.SchemeIs(url::kDataScheme); | |
| 5911 document_state->set_was_load_data_with_base_url_request(load_data); | |
| 5912 if (load_data) | |
| 5913 document_state->set_data_url(common_params.url); | |
| 5914 } | |
| 5915 | |
| 5916 pending_navigation_params_.reset(); | |
| 5917 } else { | |
| 5918 document_state->set_navigation_state( | 5896 document_state->set_navigation_state( |
| 5919 NavigationStateImpl::CreateContentInitiated()); | 5897 NavigationStateImpl::CreateContentInitiated()); |
| 5898 return; |
| 5920 } | 5899 } |
| 5900 |
| 5901 // If this is a browser-initiated load that doesn't override |
| 5902 // navigation_start, set it here. |
| 5903 if (pending_navigation_params_->common_params.navigation_start.is_null()) { |
| 5904 pending_navigation_params_->common_params.navigation_start = |
| 5905 base::TimeTicks::Now(); |
| 5906 } |
| 5907 document_state->set_navigation_state(CreateNavigationStateFromPending()); |
| 5908 |
| 5909 // The |set_was_load_data_with_base_url_request| state should not change for |
| 5910 // an in-page navigation, so skip updating it from the in-page navigation |
| 5911 // params in this case. |
| 5912 if (!was_within_same_page) { |
| 5913 const CommonNavigationParams& common_params = |
| 5914 pending_navigation_params_->common_params; |
| 5915 bool load_data = !common_params.base_url_for_data_url.is_empty() && |
| 5916 !common_params.history_url_for_data_url.is_empty() && |
| 5917 common_params.url.SchemeIs(url::kDataScheme); |
| 5918 document_state->set_was_load_data_with_base_url_request(load_data); |
| 5919 if (load_data) |
| 5920 document_state->set_data_url(common_params.url); |
| 5921 } |
| 5922 |
| 5923 pending_navigation_params_.reset(); |
| 5921 } | 5924 } |
| 5922 | 5925 |
| 5923 #if defined(OS_ANDROID) | 5926 #if defined(OS_ANDROID) |
| 5924 WebMediaPlayer* RenderFrameImpl::CreateAndroidWebMediaPlayer( | 5927 WebMediaPlayer* RenderFrameImpl::CreateAndroidWebMediaPlayer( |
| 5925 WebMediaPlayerClient* client, | 5928 WebMediaPlayerClient* client, |
| 5926 WebMediaPlayerEncryptedMediaClient* encrypted_client, | 5929 WebMediaPlayerEncryptedMediaClient* encrypted_client, |
| 5927 const media::WebMediaPlayerParams& params) { | 5930 const media::WebMediaPlayerParams& params) { |
| 5928 scoped_refptr<StreamTextureFactory> stream_texture_factory = | 5931 scoped_refptr<StreamTextureFactory> stream_texture_factory = |
| 5929 RenderThreadImpl::current()->GetStreamTexureFactory(); | 5932 RenderThreadImpl::current()->GetStreamTexureFactory(); |
| 5930 if (!stream_texture_factory.get()) { | 5933 if (!stream_texture_factory.get()) { |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6144 // event target. Potentially a Pepper plugin will receive the event. | 6147 // event target. Potentially a Pepper plugin will receive the event. |
| 6145 // In order to tell whether a plugin gets the last mouse event and which it | 6148 // In order to tell whether a plugin gets the last mouse event and which it |
| 6146 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6149 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6147 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6150 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6148 // |pepper_last_mouse_event_target_|. | 6151 // |pepper_last_mouse_event_target_|. |
| 6149 pepper_last_mouse_event_target_ = nullptr; | 6152 pepper_last_mouse_event_target_ = nullptr; |
| 6150 #endif | 6153 #endif |
| 6151 } | 6154 } |
| 6152 | 6155 |
| 6153 } // namespace content | 6156 } // namespace content |
| OLD | NEW |