| 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/appcache_dispatcher.h" | 9 #include "content/child/appcache/appcache_dispatcher.h" |
| 10 #include "content/child/fileapi/file_system_dispatcher.h" | 10 #include "content/child/fileapi/file_system_dispatcher.h" |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 const WebKit::WebURLRequest& request, | 277 const WebKit::WebURLRequest& request, |
| 278 WebKit::WebNavigationType type, | 278 WebKit::WebNavigationType type, |
| 279 WebKit::WebNavigationPolicy default_policy, | 279 WebKit::WebNavigationPolicy default_policy, |
| 280 bool is_redirect) { | 280 bool is_redirect) { |
| 281 return render_view_->decidePolicyForNavigation( | 281 return render_view_->decidePolicyForNavigation( |
| 282 frame, request, type, default_policy, is_redirect); | 282 frame, request, type, default_policy, is_redirect); |
| 283 } | 283 } |
| 284 | 284 |
| 285 void RenderFrameImpl::willSendSubmitEvent(WebKit::WebFrame* frame, | 285 void RenderFrameImpl::willSendSubmitEvent(WebKit::WebFrame* frame, |
| 286 const WebKit::WebFormElement& form) { | 286 const WebKit::WebFormElement& form) { |
| 287 // Some login forms have onSubmit handlers that put a hash of the password | 287 // Call back to RenderViewImpl for observers to be notified. |
| 288 // into a hidden field and then clear the password. (Issue 28910.) | 288 // TODO(nasko): Remove once we have RenderFrameObserver. |
| 289 // This method gets called before any of those handlers run, so save away | 289 render_view_->willSendSubmitEvent(frame, form); |
| 290 // a copy of the password in case it gets lost. | |
| 291 DocumentState* document_state = | |
| 292 DocumentState::FromDataSource(frame->dataSource()); | |
| 293 document_state->set_password_form_data(CreatePasswordForm(form)); | |
| 294 } | 290 } |
| 295 | 291 |
| 296 void RenderFrameImpl::willSubmitForm(WebKit::WebFrame* frame, | 292 void RenderFrameImpl::willSubmitForm(WebKit::WebFrame* frame, |
| 297 const WebKit::WebFormElement& form) { | 293 const WebKit::WebFormElement& form) { |
| 298 DocumentState* document_state = | 294 DocumentState* document_state = |
| 299 DocumentState::FromDataSource(frame->provisionalDataSource()); | 295 DocumentState::FromDataSource(frame->provisionalDataSource()); |
| 300 NavigationState* navigation_state = document_state->navigation_state(); | 296 NavigationState* navigation_state = document_state->navigation_state(); |
| 301 InternalDocumentStateData* internal_data = | 297 InternalDocumentStateData* internal_data = |
| 302 InternalDocumentStateData::FromDocumentState(document_state); | 298 InternalDocumentStateData::FromDocumentState(document_state); |
| 303 | 299 |
| 304 if (PageTransitionCoreTypeIs(navigation_state->transition_type(), | 300 if (PageTransitionCoreTypeIs(navigation_state->transition_type(), |
| 305 PAGE_TRANSITION_LINK)) { | 301 PAGE_TRANSITION_LINK)) { |
| 306 navigation_state->set_transition_type(PAGE_TRANSITION_FORM_SUBMIT); | 302 navigation_state->set_transition_type(PAGE_TRANSITION_FORM_SUBMIT); |
| 307 } | 303 } |
| 308 | 304 |
| 309 // Save these to be processed when the ensuing navigation is committed. | 305 // Save these to be processed when the ensuing navigation is committed. |
| 310 WebSearchableFormData web_searchable_form_data(form); | 306 WebSearchableFormData web_searchable_form_data(form); |
| 311 internal_data->set_searchable_form_url(web_searchable_form_data.url()); | 307 internal_data->set_searchable_form_url(web_searchable_form_data.url()); |
| 312 internal_data->set_searchable_form_encoding( | 308 internal_data->set_searchable_form_encoding( |
| 313 web_searchable_form_data.encoding().utf8()); | 309 web_searchable_form_data.encoding().utf8()); |
| 314 scoped_ptr<PasswordForm> password_form_data = | |
| 315 CreatePasswordForm(form); | |
| 316 | |
| 317 // In order to save the password that the user actually typed and not one | |
| 318 // that may have gotten transformed by the site prior to submit, recover it | |
| 319 // from the form contents already stored by |willSendSubmitEvent| into the | |
| 320 // dataSource's NavigationState (as opposed to the provisionalDataSource's, | |
| 321 // which is what we're storing into now.) | |
| 322 if (password_form_data) { | |
| 323 DocumentState* old_document_state = | |
| 324 DocumentState::FromDataSource(frame->dataSource()); | |
| 325 if (old_document_state) { | |
| 326 PasswordForm* old_form_data = old_document_state->password_form_data(); | |
| 327 if (old_form_data && old_form_data->action == password_form_data->action) | |
| 328 password_form_data->password_value = old_form_data->password_value; | |
| 329 } | |
| 330 } | |
| 331 | |
| 332 document_state->set_password_form_data(password_form_data.Pass()); | |
| 333 | 310 |
| 334 // Call back to RenderViewImpl for observers to be notified. | 311 // Call back to RenderViewImpl for observers to be notified. |
| 335 // TODO(nasko): Remove once we have RenderFrameObserver. | 312 // TODO(nasko): Remove once we have RenderFrameObserver. |
| 336 render_view_->willSubmitForm(frame, form); | 313 render_view_->willSubmitForm(frame, form); |
| 337 } | 314 } |
| 338 | 315 |
| 339 void RenderFrameImpl::didCreateDataSource(WebKit::WebFrame* frame, | 316 void RenderFrameImpl::didCreateDataSource(WebKit::WebFrame* frame, |
| 340 WebKit::WebDataSource* datasource) { | 317 WebKit::WebDataSource* datasource) { |
| 341 // TODO(nasko): Move implementation here. Needed state: | 318 // TODO(nasko): Move implementation here. Needed state: |
| 342 // * pending_navigation_params_ | 319 // * pending_navigation_params_ |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 | 868 |
| 892 void RenderFrameImpl::didLoseWebGLContext(WebKit::WebFrame* frame, | 869 void RenderFrameImpl::didLoseWebGLContext(WebKit::WebFrame* frame, |
| 893 int arb_robustness_status_code) { | 870 int arb_robustness_status_code) { |
| 894 Send(new ViewHostMsg_DidLose3DContext( | 871 Send(new ViewHostMsg_DidLose3DContext( |
| 895 GURL(frame->top()->document().securityOrigin().toString()), | 872 GURL(frame->top()->document().securityOrigin().toString()), |
| 896 THREE_D_API_TYPE_WEBGL, | 873 THREE_D_API_TYPE_WEBGL, |
| 897 arb_robustness_status_code)); | 874 arb_robustness_status_code)); |
| 898 } | 875 } |
| 899 | 876 |
| 900 } // namespace content | 877 } // namespace content |
| OLD | NEW |