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 "components/autofill/content/renderer/password_generation_agent.h" | 5 #include "components/autofill/content/renderer/password_generation_agent.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "components/autofill/content/common/autofill_messages.h" | 10 #include "components/autofill/content/common/autofill_messages.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 content::RenderView* render_view) | 100 content::RenderView* render_view) |
101 : content::RenderViewObserver(render_view), | 101 : content::RenderViewObserver(render_view), |
102 render_view_(render_view), | 102 render_view_(render_view), |
103 password_is_generated_(false), | 103 password_is_generated_(false), |
104 password_edited_(false), | 104 password_edited_(false), |
105 enabled_(password_generation::IsPasswordGenerationEnabled()) { | 105 enabled_(password_generation::IsPasswordGenerationEnabled()) { |
106 DVLOG(2) << "Password Generation is " << (enabled_ ? "Enabled" : "Disabled"); | 106 DVLOG(2) << "Password Generation is " << (enabled_ ? "Enabled" : "Disabled"); |
107 } | 107 } |
108 PasswordGenerationAgent::~PasswordGenerationAgent() {} | 108 PasswordGenerationAgent::~PasswordGenerationAgent() {} |
109 | 109 |
110 void PasswordGenerationAgent::DidFinishDocumentLoad(blink::WebFrame* frame) { | 110 void PasswordGenerationAgent::DidFinishDocumentLoad( |
| 111 blink::WebLocalFrame* frame) { |
111 // In every navigation, the IPC message sent by the password autofill manager | 112 // In every navigation, the IPC message sent by the password autofill manager |
112 // to query whether the current form is blacklisted or not happens when the | 113 // to query whether the current form is blacklisted or not happens when the |
113 // document load finishes, so we need to clear previous states here before we | 114 // document load finishes, so we need to clear previous states here before we |
114 // hear back from the browser. We only clear this state on main frame load | 115 // hear back from the browser. We only clear this state on main frame load |
115 // as we don't want subframe loads to clear state that we have received from | 116 // as we don't want subframe loads to clear state that we have received from |
116 // the main frame. Note that we assume there is only one account creation | 117 // the main frame. Note that we assume there is only one account creation |
117 // form, but there could be multiple password forms in each frame. | 118 // form, but there could be multiple password forms in each frame. |
118 if (!frame->parent()) { | 119 if (!frame->parent()) { |
119 not_blacklisted_password_form_origins_.clear(); | 120 not_blacklisted_password_form_origins_.clear(); |
120 generation_enabled_forms_.clear(); | 121 generation_enabled_forms_.clear(); |
121 generation_element_.reset(); | 122 generation_element_.reset(); |
122 possible_account_creation_form_.reset(new PasswordForm()); | 123 possible_account_creation_form_.reset(new PasswordForm()); |
123 password_elements_.clear(); | 124 password_elements_.clear(); |
124 password_is_generated_ = false; | 125 password_is_generated_ = false; |
125 if (password_edited_) { | 126 if (password_edited_) { |
126 password_generation::LogPasswordGenerationEvent( | 127 password_generation::LogPasswordGenerationEvent( |
127 password_generation::PASSWORD_EDITED); | 128 password_generation::PASSWORD_EDITED); |
128 } | 129 } |
129 password_edited_ = false; | 130 password_edited_ = false; |
130 } | 131 } |
131 } | 132 } |
132 | 133 |
133 void PasswordGenerationAgent::DidFinishLoad(blink::WebFrame* frame) { | 134 void PasswordGenerationAgent::DidFinishLoad(blink::WebLocalFrame* frame) { |
134 if (!enabled_) | 135 if (!enabled_) |
135 return; | 136 return; |
136 | 137 |
137 // We don't want to generate passwords if the browser won't store or sync | 138 // We don't want to generate passwords if the browser won't store or sync |
138 // them. | 139 // them. |
139 if (!ShouldAnalyzeDocument(frame->document())) | 140 if (!ShouldAnalyzeDocument(frame->document())) |
140 return; | 141 return; |
141 | 142 |
142 blink::WebVector<blink::WebFormElement> forms; | 143 blink::WebVector<blink::WebFormElement> forms; |
143 frame->document().forms(forms); | 144 frame->document().forms(forms); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 | 356 |
356 password_generation::LogPasswordGenerationEvent( | 357 password_generation::LogPasswordGenerationEvent( |
357 password_generation::EDITING_POPUP_SHOWN); | 358 password_generation::EDITING_POPUP_SHOWN); |
358 } | 359 } |
359 | 360 |
360 void PasswordGenerationAgent::HidePopup() { | 361 void PasswordGenerationAgent::HidePopup() { |
361 Send(new AutofillHostMsg_HidePasswordGenerationPopup(routing_id())); | 362 Send(new AutofillHostMsg_HidePasswordGenerationPopup(routing_id())); |
362 } | 363 } |
363 | 364 |
364 } // namespace autofill | 365 } // namespace autofill |
OLD | NEW |