| 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 "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "content/child/appcache_dispatcher.h" | 9 #include "content/child/appcache_dispatcher.h" |
| 10 #include "content/child/fileapi/file_system_dispatcher.h" | 10 #include "content/child/fileapi/file_system_dispatcher.h" |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 const WebKit::WebURLRequest& request, | 282 const WebKit::WebURLRequest& request, |
| 283 WebKit::WebNavigationType type, | 283 WebKit::WebNavigationType type, |
| 284 WebKit::WebNavigationPolicy default_policy, | 284 WebKit::WebNavigationPolicy default_policy, |
| 285 bool is_redirect) { | 285 bool is_redirect) { |
| 286 return render_view_->decidePolicyForNavigation( | 286 return render_view_->decidePolicyForNavigation( |
| 287 frame, request, type, default_policy, is_redirect); | 287 frame, request, type, default_policy, is_redirect); |
| 288 } | 288 } |
| 289 | 289 |
| 290 void RenderFrameImpl::willSendSubmitEvent(WebKit::WebFrame* frame, | 290 void RenderFrameImpl::willSendSubmitEvent(WebKit::WebFrame* frame, |
| 291 const WebKit::WebFormElement& form) { | 291 const WebKit::WebFormElement& form) { |
| 292 // Some login forms have onSubmit handlers that put a hash of the password | 292 // Call back to RenderViewImpl for observers to be notified. |
| 293 // into a hidden field and then clear the password. (Issue 28910.) | 293 // TODO(nasko): Remove once we have RenderFrameObserver. |
| 294 // This method gets called before any of those handlers run, so save away | 294 render_view_->willSendSubmitEvent(frame, form); |
| 295 // a copy of the password in case it gets lost. | |
| 296 DocumentState* document_state = | |
| 297 DocumentState::FromDataSource(frame->dataSource()); | |
| 298 document_state->set_password_form_data(CreatePasswordForm(form)); | |
| 299 } | 295 } |
| 300 | 296 |
| 301 void RenderFrameImpl::willSubmitForm(WebKit::WebFrame* frame, | 297 void RenderFrameImpl::willSubmitForm(WebKit::WebFrame* frame, |
| 302 const WebKit::WebFormElement& form) { | 298 const WebKit::WebFormElement& form) { |
| 303 DocumentState* document_state = | 299 DocumentState* document_state = |
| 304 DocumentState::FromDataSource(frame->provisionalDataSource()); | 300 DocumentState::FromDataSource(frame->provisionalDataSource()); |
| 305 NavigationState* navigation_state = document_state->navigation_state(); | 301 NavigationState* navigation_state = document_state->navigation_state(); |
| 306 InternalDocumentStateData* internal_data = | 302 InternalDocumentStateData* internal_data = |
| 307 InternalDocumentStateData::FromDocumentState(document_state); | 303 InternalDocumentStateData::FromDocumentState(document_state); |
| 308 | 304 |
| 309 if (PageTransitionCoreTypeIs(navigation_state->transition_type(), | 305 if (PageTransitionCoreTypeIs(navigation_state->transition_type(), |
| 310 PAGE_TRANSITION_LINK)) { | 306 PAGE_TRANSITION_LINK)) { |
| 311 navigation_state->set_transition_type(PAGE_TRANSITION_FORM_SUBMIT); | 307 navigation_state->set_transition_type(PAGE_TRANSITION_FORM_SUBMIT); |
| 312 } | 308 } |
| 313 | 309 |
| 314 // Save these to be processed when the ensuing navigation is committed. | 310 // Save these to be processed when the ensuing navigation is committed. |
| 315 WebSearchableFormData web_searchable_form_data(form); | 311 WebSearchableFormData web_searchable_form_data(form); |
| 316 internal_data->set_searchable_form_url(web_searchable_form_data.url()); | 312 internal_data->set_searchable_form_url(web_searchable_form_data.url()); |
| 317 internal_data->set_searchable_form_encoding( | 313 internal_data->set_searchable_form_encoding( |
| 318 web_searchable_form_data.encoding().utf8()); | 314 web_searchable_form_data.encoding().utf8()); |
| 319 scoped_ptr<PasswordForm> password_form_data = | |
| 320 CreatePasswordForm(form); | |
| 321 | |
| 322 // In order to save the password that the user actually typed and not one | |
| 323 // that may have gotten transformed by the site prior to submit, recover it | |
| 324 // from the form contents already stored by |willSendSubmitEvent| into the | |
| 325 // dataSource's NavigationState (as opposed to the provisionalDataSource's, | |
| 326 // which is what we're storing into now.) | |
| 327 if (password_form_data) { | |
| 328 DocumentState* old_document_state = | |
| 329 DocumentState::FromDataSource(frame->dataSource()); | |
| 330 if (old_document_state) { | |
| 331 PasswordForm* old_form_data = old_document_state->password_form_data(); | |
| 332 if (old_form_data && old_form_data->action == password_form_data->action) | |
| 333 password_form_data->password_value = old_form_data->password_value; | |
| 334 } | |
| 335 } | |
| 336 | |
| 337 document_state->set_password_form_data(password_form_data.Pass()); | |
| 338 | 315 |
| 339 // Call back to RenderViewImpl for observers to be notified. | 316 // Call back to RenderViewImpl for observers to be notified. |
| 340 // TODO(nasko): Remove once we have RenderFrameObserver. | 317 // TODO(nasko): Remove once we have RenderFrameObserver. |
| 341 render_view_->willSubmitForm(frame, form); | 318 render_view_->willSubmitForm(frame, form); |
| 342 } | 319 } |
| 343 | 320 |
| 344 void RenderFrameImpl::willPerformClientRedirect(WebKit::WebFrame* frame, | 321 void RenderFrameImpl::willPerformClientRedirect(WebKit::WebFrame* frame, |
| 345 const WebKit::WebURL& from, | 322 const WebKit::WebURL& from, |
| 346 const WebKit::WebURL& to, | 323 const WebKit::WebURL& to, |
| 347 double interval, | 324 double interval, |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 | 881 |
| 905 void RenderFrameImpl::didLoseWebGLContext(WebKit::WebFrame* frame, | 882 void RenderFrameImpl::didLoseWebGLContext(WebKit::WebFrame* frame, |
| 906 int arb_robustness_status_code) { | 883 int arb_robustness_status_code) { |
| 907 Send(new ViewHostMsg_DidLose3DContext( | 884 Send(new ViewHostMsg_DidLose3DContext( |
| 908 GURL(frame->top()->document().securityOrigin().toString()), | 885 GURL(frame->top()->document().securityOrigin().toString()), |
| 909 THREE_D_API_TYPE_WEBGL, | 886 THREE_D_API_TYPE_WEBGL, |
| 910 arb_robustness_status_code)); | 887 arb_robustness_status_code)); |
| 911 } | 888 } |
| 912 | 889 |
| 913 } // namespace content | 890 } // namespace content |
| OLD | NEW |