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