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 3296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3307 // TODO(creis): Look into cleaning this up. | 3307 // TODO(creis): Look into cleaning this up. |
3308 return WebHistoryItem(); | 3308 return WebHistoryItem(); |
3309 } | 3309 } |
3310 | 3310 |
3311 void RenderFrameImpl::willSendSubmitEvent(const blink::WebFormElement& form) { | 3311 void RenderFrameImpl::willSendSubmitEvent(const blink::WebFormElement& form) { |
3312 for (auto& observer : observers_) | 3312 for (auto& observer : observers_) |
3313 observer.WillSendSubmitEvent(form); | 3313 observer.WillSendSubmitEvent(form); |
3314 } | 3314 } |
3315 | 3315 |
3316 void RenderFrameImpl::willSubmitForm(const blink::WebFormElement& form) { | 3316 void RenderFrameImpl::willSubmitForm(const blink::WebFormElement& form) { |
3317 // With PlzNavigate-enabled, this will be called before a DataSource has been | |
3318 // set-up. | |
3319 // TODO(clamy): make sure the internal state is properly updated at some | |
3320 // point in the navigation. | |
3321 if (!IsBrowserSideNavigationEnabled() && !!frame_->provisionalDataSource()) { | |
3322 DocumentState* document_state = | 3317 DocumentState* document_state = |
3323 DocumentState::FromDataSource(frame_->provisionalDataSource()); | 3318 DocumentState::FromDataSource(frame_->provisionalDataSource()); |
3324 NavigationStateImpl* navigation_state = | 3319 NavigationStateImpl* navigation_state = |
3325 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 3320 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
3326 InternalDocumentStateData* internal_data = | 3321 InternalDocumentStateData* internal_data = |
3327 InternalDocumentStateData::FromDocumentState(document_state); | 3322 InternalDocumentStateData::FromDocumentState(document_state); |
3328 | 3323 |
3329 if (ui::PageTransitionCoreTypeIs(navigation_state->GetTransitionType(), | 3324 if (ui::PageTransitionCoreTypeIs(navigation_state->GetTransitionType(), |
3330 ui::PAGE_TRANSITION_LINK)) { | 3325 ui::PAGE_TRANSITION_LINK)) { |
3331 navigation_state->set_transition_type(ui::PAGE_TRANSITION_FORM_SUBMIT); | 3326 navigation_state->set_transition_type(ui::PAGE_TRANSITION_FORM_SUBMIT); |
3332 } | 3327 } |
3333 | 3328 |
3334 // Save these to be processed when the ensuing navigation is committed. | 3329 // Save these to be processed when the ensuing navigation is committed. |
3335 WebSearchableFormData web_searchable_form_data(form); | 3330 WebSearchableFormData web_searchable_form_data(form); |
3336 internal_data->set_searchable_form_url(web_searchable_form_data.url()); | 3331 internal_data->set_searchable_form_url(web_searchable_form_data.url()); |
3337 internal_data->set_searchable_form_encoding( | 3332 internal_data->set_searchable_form_encoding( |
3338 web_searchable_form_data.encoding().utf8()); | 3333 web_searchable_form_data.encoding().utf8()); |
3339 } | |
3340 | 3334 |
3341 for (auto& observer : observers_) | 3335 for (auto& observer : observers_) |
3342 observer.WillSubmitForm(form); | 3336 observer.WillSubmitForm(form); |
3343 } | 3337 } |
3344 | 3338 |
3345 void RenderFrameImpl::didCreateDataSource(blink::WebLocalFrame* frame, | 3339 void RenderFrameImpl::didCreateDataSource(blink::WebLocalFrame* frame, |
3346 blink::WebDataSource* datasource) { | 3340 blink::WebDataSource* datasource) { |
3347 DCHECK(!frame_ || frame_ == frame); | 3341 DCHECK(!frame_ || frame_ == frame); |
3348 | 3342 |
3349 bool content_initiated = !pending_navigation_params_.get(); | 3343 bool content_initiated = !pending_navigation_params_.get(); |
(...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5215 // TODO(clamy): see if initial commits in subframes should be handled | 5209 // TODO(clamy): see if initial commits in subframes should be handled |
5216 // separately. | 5210 // separately. |
5217 bool replace = is_reload || common_params.url == GetLoadingUrl() || | 5211 bool replace = is_reload || common_params.url == GetLoadingUrl() || |
5218 common_params.should_replace_current_entry; | 5212 common_params.should_replace_current_entry; |
5219 std::unique_ptr<HistoryEntry> history_entry; | 5213 std::unique_ptr<HistoryEntry> history_entry; |
5220 if (request_params.page_state.IsValid()) | 5214 if (request_params.page_state.IsValid()) |
5221 history_entry = PageStateToHistoryEntry(request_params.page_state); | 5215 history_entry = PageStateToHistoryEntry(request_params.page_state); |
5222 | 5216 |
5223 // For renderer initiated navigations, we send out a didFailProvisionalLoad() | 5217 // For renderer initiated navigations, we send out a didFailProvisionalLoad() |
5224 // notification. | 5218 // notification. |
5225 if (request_params.nav_entry_id == 0) | 5219 bool had_provisional_data_source = frame_->provisionalDataSource(); |
5226 didFailProvisionalLoad(frame_, error, blink::WebStandardCommit); | 5220 if (request_params.nav_entry_id == 0) { |
5227 LoadNavigationErrorPage(failed_request, error, replace, history_entry.get()); | 5221 didFailProvisionalLoad( |
5222 frame_, error, | |
5223 replace ? blink::WebHistoryInertCommit : blink::WebStandardCommit); | |
5224 } | |
5225 // If we didn't call didFailProvisionalLoad or there wasn't a | |
clamy
2017/03/02 14:37:18
nit: empty line above.
Nate Chapin
2017/03/02 19:39:17
Done.
| |
5226 // provisionalDataSource(), LoadNavigationErrorPage wasn't called, so do it | |
5227 // now. | |
5228 if (request_params.nav_entry_id != 0 || !had_provisional_data_source) { | |
5229 LoadNavigationErrorPage(failed_request, error, replace, | |
5230 history_entry.get()); | |
5231 } | |
5232 | |
5228 browser_side_navigation_pending_ = false; | 5233 browser_side_navigation_pending_ = false; |
5229 } | 5234 } |
5230 | 5235 |
5231 WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation( | 5236 WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation( |
5232 const NavigationPolicyInfo& info) { | 5237 const NavigationPolicyInfo& info) { |
5233 // A content initiated navigation may have originated from a link-click, | 5238 // A content initiated navigation may have originated from a link-click, |
5234 // script, drag-n-drop operation, etc. | 5239 // script, drag-n-drop operation, etc. |
5235 // info.extraData is only non-null if this is a redirect. Use the extraData | 5240 // info.extraData is only non-null if this is a redirect. Use the extraData |
5236 // initiation information for redirects, and check pending_navigation_params_ | 5241 // initiation information for redirects, and check pending_navigation_params_ |
5237 // otherwise. | 5242 // otherwise. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5302 if (should_ask_browser) { | 5307 if (should_ask_browser) { |
5303 // Don't do this if |info| also says it is a client redirect, in which | 5308 // Don't do this if |info| also says it is a client redirect, in which |
5304 // case JavaScript on the page is trying to interrupt the history | 5309 // case JavaScript on the page is trying to interrupt the history |
5305 // navigation. | 5310 // navigation. |
5306 if (!info.isClientRedirect) { | 5311 if (!info.isClientRedirect) { |
5307 OpenURL(url, IsHttpPost(info.urlRequest), | 5312 OpenURL(url, IsHttpPost(info.urlRequest), |
5308 GetRequestBodyForWebURLRequest(info.urlRequest), | 5313 GetRequestBodyForWebURLRequest(info.urlRequest), |
5309 GetWebURLRequestHeaders(info.urlRequest), referrer, | 5314 GetWebURLRequestHeaders(info.urlRequest), referrer, |
5310 info.defaultPolicy, info.replacesCurrentHistoryItem, true); | 5315 info.defaultPolicy, info.replacesCurrentHistoryItem, true); |
5311 // Suppress the load in Blink but mark the frame as loading. | 5316 // Suppress the load in Blink but mark the frame as loading. |
5312 return blink::WebNavigationPolicyHandledByClient; | 5317 return blink::WebNavigationPolicyHandledByClientForInitialHistory; |
5313 } else { | 5318 } else { |
5314 // Client redirects during an initial history load should attempt to | 5319 // Client redirects during an initial history load should attempt to |
5315 // cancel the history navigation. They will create a provisional | 5320 // cancel the history navigation. They will create a provisional |
5316 // document loader, causing the history load to be ignored in | 5321 // document loader, causing the history load to be ignored in |
5317 // NavigateInternal, and this IPC will try to cancel any cross-process | 5322 // NavigateInternal, and this IPC will try to cancel any cross-process |
5318 // history load. | 5323 // history load. |
5319 Send(new FrameHostMsg_CancelInitialHistoryLoad(routing_id_)); | 5324 Send(new FrameHostMsg_CancelInitialHistoryLoad(routing_id_)); |
5320 } | 5325 } |
5321 } | 5326 } |
5322 } | 5327 } |
(...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6849 // event target. Potentially a Pepper plugin will receive the event. | 6854 // event target. Potentially a Pepper plugin will receive the event. |
6850 // In order to tell whether a plugin gets the last mouse event and which it | 6855 // In order to tell whether a plugin gets the last mouse event and which it |
6851 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6856 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6852 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6857 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6853 // |pepper_last_mouse_event_target_|. | 6858 // |pepper_last_mouse_event_target_|. |
6854 pepper_last_mouse_event_target_ = nullptr; | 6859 pepper_last_mouse_event_target_ = nullptr; |
6855 #endif | 6860 #endif |
6856 } | 6861 } |
6857 | 6862 |
6858 } // namespace content | 6863 } // namespace content |
OLD | NEW |