OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/renderer/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 2658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2669 DCHECK(navigation_state); | 2669 DCHECK(navigation_state); |
2670 navigation_state->set_finish_document_load_time(Time::Now()); | 2670 navigation_state->set_finish_document_load_time(Time::Now()); |
2671 | 2671 |
2672 Send(new ViewHostMsg_DocumentLoadedInFrame(routing_id_)); | 2672 Send(new ViewHostMsg_DocumentLoadedInFrame(routing_id_)); |
2673 | 2673 |
2674 // The document has now been fully loaded. Scan for forms to be sent up to | 2674 // The document has now been fully loaded. Scan for forms to be sent up to |
2675 // the browser. | 2675 // the browser. |
2676 // TODO(jhawkins): Make these use the FormManager. | 2676 // TODO(jhawkins): Make these use the FormManager. |
2677 form_manager_.ExtractForms(frame); | 2677 form_manager_.ExtractForms(frame); |
2678 SendForms(frame); | 2678 SendForms(frame); |
2679 SendPasswordForms(frame); | 2679 SendPasswordForms(frame, false); |
2680 | 2680 |
2681 // Check whether we have new encoding name. | 2681 // Check whether we have new encoding name. |
2682 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 2682 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
2683 | 2683 |
2684 if (RenderThread::current()) { // Will be NULL during unit tests. | 2684 if (RenderThread::current()) { // Will be NULL during unit tests. |
2685 RenderThread::current()->user_script_slave()->InjectScripts( | 2685 RenderThread::current()->user_script_slave()->InjectScripts( |
2686 frame, UserScript::DOCUMENT_END); | 2686 frame, UserScript::DOCUMENT_END); |
2687 } | 2687 } |
2688 | 2688 |
2689 navigation_state->user_script_idle_scheduler()->DidFinishDocumentLoad(); | 2689 navigation_state->user_script_idle_scheduler()->DidFinishDocumentLoad(); |
(...skipping 23 matching lines...) Expand all Loading... |
2713 void RenderView::didFailLoad(WebFrame* frame, const WebURLError& error) { | 2713 void RenderView::didFailLoad(WebFrame* frame, const WebURLError& error) { |
2714 // Ignore | 2714 // Ignore |
2715 } | 2715 } |
2716 | 2716 |
2717 void RenderView::didFinishLoad(WebFrame* frame) { | 2717 void RenderView::didFinishLoad(WebFrame* frame) { |
2718 WebDataSource* ds = frame->dataSource(); | 2718 WebDataSource* ds = frame->dataSource(); |
2719 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 2719 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
2720 DCHECK(navigation_state); | 2720 DCHECK(navigation_state); |
2721 navigation_state->set_finish_load_time(Time::Now()); | 2721 navigation_state->set_finish_load_time(Time::Now()); |
2722 navigation_state->user_script_idle_scheduler()->DidFinishLoad(); | 2722 navigation_state->user_script_idle_scheduler()->DidFinishLoad(); |
| 2723 |
| 2724 // Let the password manager know which password forms are actually visible. |
| 2725 SendPasswordForms(frame, true); |
2723 } | 2726 } |
2724 | 2727 |
2725 void RenderView::didNavigateWithinPage( | 2728 void RenderView::didNavigateWithinPage( |
2726 WebFrame* frame, bool is_new_navigation) { | 2729 WebFrame* frame, bool is_new_navigation) { |
2727 | 2730 |
2728 // Determine if the UserScriptIdleScheduler already ran scripts on this page, | 2731 // Determine if the UserScriptIdleScheduler already ran scripts on this page, |
2729 // since a new one gets created by didCreateDataSource. | 2732 // since a new one gets created by didCreateDataSource. |
2730 NavigationState* state = | 2733 NavigationState* state = |
2731 NavigationState::FromDataSource(frame->dataSource()); | 2734 NavigationState::FromDataSource(frame->dataSource()); |
2732 bool idle_scheduler_ran = state->user_script_idle_scheduler()->has_run(); | 2735 bool idle_scheduler_ran = state->user_script_idle_scheduler()->has_run(); |
(...skipping 1969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4702 if (acc_obj_id >= 0) | 4705 if (acc_obj_id >= 0) |
4703 Send(new ViewHostMsg_AccessibilityObjectStateChange(routing_id_, | 4706 Send(new ViewHostMsg_AccessibilityObjectStateChange(routing_id_, |
4704 acc_obj_id)); | 4707 acc_obj_id)); |
4705 | 4708 |
4706 #else // defined(OS_WIN) | 4709 #else // defined(OS_WIN) |
4707 // TODO(port): accessibility not yet implemented | 4710 // TODO(port): accessibility not yet implemented |
4708 NOTIMPLEMENTED(); | 4711 NOTIMPLEMENTED(); |
4709 #endif | 4712 #endif |
4710 } | 4713 } |
4711 | 4714 |
4712 void RenderView::SendPasswordForms(WebFrame* frame) { | 4715 void RenderView::SendPasswordForms(WebFrame* frame, bool only_visible) { |
4713 WebVector<WebFormElement> forms; | 4716 WebVector<WebFormElement> forms; |
4714 frame->forms(forms); | 4717 frame->forms(forms); |
4715 | 4718 |
4716 std::vector<PasswordForm> password_forms; | 4719 std::vector<PasswordForm> password_forms; |
4717 for (size_t i = 0; i < forms.size(); ++i) { | 4720 for (size_t i = 0; i < forms.size(); ++i) { |
4718 const WebFormElement& form = forms[i]; | 4721 const WebFormElement& form = forms[i]; |
4719 | 4722 |
4720 // Respect autocomplete=off. | 4723 // Respect autocomplete=off. |
4721 if (form.autoComplete()) { | 4724 if (!form.autoComplete()) |
4722 scoped_ptr<PasswordForm> password_form( | 4725 continue; |
4723 PasswordFormDomManager::CreatePasswordForm(form)); | 4726 if (only_visible && !form.hasNonEmptyBoundingBox()) |
4724 if (password_form.get()) | 4727 continue; |
4725 password_forms.push_back(*password_form); | 4728 scoped_ptr<PasswordForm> password_form( |
4726 } | 4729 PasswordFormDomManager::CreatePasswordForm(form)); |
| 4730 if (password_form.get()) |
| 4731 password_forms.push_back(*password_form); |
4727 } | 4732 } |
4728 | 4733 |
4729 if (!password_forms.empty()) | 4734 if (password_forms.empty()) |
4730 Send(new ViewHostMsg_PasswordFormsSeen(routing_id_, password_forms)); | 4735 return; |
| 4736 if (only_visible) |
| 4737 Send(new ViewHostMsg_PasswordFormsVisible(routing_id_, password_forms)); |
| 4738 else |
| 4739 Send(new ViewHostMsg_PasswordFormsFound(routing_id_, password_forms)); |
4731 } | 4740 } |
4732 | 4741 |
4733 void RenderView::Print(WebFrame* frame, bool script_initiated) { | 4742 void RenderView::Print(WebFrame* frame, bool script_initiated) { |
4734 DCHECK(frame); | 4743 DCHECK(frame); |
4735 if (print_helper_.get() == NULL) { | 4744 if (print_helper_.get() == NULL) { |
4736 print_helper_.reset(new PrintWebViewHelper(this)); | 4745 print_helper_.reset(new PrintWebViewHelper(this)); |
4737 } | 4746 } |
4738 print_helper_->Print(frame, script_initiated); | 4747 print_helper_->Print(frame, script_initiated); |
4739 } | 4748 } |
4740 | 4749 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4963 | 4972 |
4964 if (last_top_level_navigation_page_id_ != page_id_ && | 4973 if (last_top_level_navigation_page_id_ != page_id_ && |
4965 // Not interested in reloads. | 4974 // Not interested in reloads. |
4966 type != WebKit::WebNavigationTypeReload && | 4975 type != WebKit::WebNavigationTypeReload && |
4967 type != WebKit::WebNavigationTypeFormSubmitted) { | 4976 type != WebKit::WebNavigationTypeFormSubmitted) { |
4968 return true; | 4977 return true; |
4969 } | 4978 } |
4970 } | 4979 } |
4971 return false; | 4980 return false; |
4972 } | 4981 } |
OLD | NEW |