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_manager.h" | 5 #include "components/autofill/content/renderer/password_generation_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "components/autofill/content/renderer/password_form_conversion_utils.h" |
8 #include "components/autofill/core/common/autofill_messages.h" | 9 #include "components/autofill/core/common/autofill_messages.h" |
9 #include "components/autofill/core/common/password_generation_util.h" | 10 #include "components/autofill/core/common/password_generation_util.h" |
10 #include "content/public/renderer/password_form_conversion_utils.h" | |
11 #include "content/public/renderer/render_view.h" | 11 #include "content/public/renderer/render_view.h" |
12 #include "google_apis/gaia/gaia_urls.h" | 12 #include "google_apis/gaia/gaia_urls.h" |
13 #include "third_party/WebKit/public/platform/WebCString.h" | 13 #include "third_party/WebKit/public/platform/WebCString.h" |
14 #include "third_party/WebKit/public/platform/WebRect.h" | 14 #include "third_party/WebKit/public/platform/WebRect.h" |
15 #include "third_party/WebKit/public/platform/WebVector.h" | 15 #include "third_party/WebKit/public/platform/WebVector.h" |
16 #include "third_party/WebKit/public/web/WebDocument.h" | 16 #include "third_party/WebKit/public/web/WebDocument.h" |
17 #include "third_party/WebKit/public/web/WebFormElement.h" | 17 #include "third_party/WebKit/public/web/WebFormElement.h" |
18 #include "third_party/WebKit/public/web/WebFrame.h" | 18 #include "third_party/WebKit/public/web/WebFrame.h" |
19 #include "third_party/WebKit/public/web/WebInputElement.h" | 19 #include "third_party/WebKit/public/web/WebInputElement.h" |
20 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 20 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 102 |
103 WebKit::WebVector<WebKit::WebFormElement> forms; | 103 WebKit::WebVector<WebKit::WebFormElement> forms; |
104 frame->document().forms(forms); | 104 frame->document().forms(forms); |
105 for (size_t i = 0; i < forms.size(); ++i) { | 105 for (size_t i = 0; i < forms.size(); ++i) { |
106 if (forms[i].isNull()) | 106 if (forms[i].isNull()) |
107 continue; | 107 continue; |
108 | 108 |
109 // If we can't get a valid PasswordForm, we skip this form because the | 109 // If we can't get a valid PasswordForm, we skip this form because the |
110 // the password won't get saved even if we generate it. | 110 // the password won't get saved even if we generate it. |
111 scoped_ptr<content::PasswordForm> password_form( | 111 scoped_ptr<content::PasswordForm> password_form( |
112 content::CreatePasswordForm(forms[i])); | 112 CreatePasswordForm(forms[i])); |
113 if (!password_form.get()) { | 113 if (!password_form.get()) { |
114 DVLOG(2) << "Skipping form as it would not be saved"; | 114 DVLOG(2) << "Skipping form as it would not be saved"; |
115 continue; | 115 continue; |
116 } | 116 } |
117 | 117 |
118 // Do not generate password for GAIA since it is used to retrieve the | 118 // Do not generate password for GAIA since it is used to retrieve the |
119 // generated paswords. | 119 // generated paswords. |
120 GURL realm(password_form->signon_realm); | 120 GURL realm(password_form->signon_realm); |
121 if (realm == GURL(GaiaUrls::GetInstance()->gaia_login_form_realm())) | 121 if (realm == GURL(GaiaUrls::GetInstance()->gaia_login_form_realm())) |
122 continue; | 122 continue; |
(...skipping 25 matching lines...) Expand all Loading... |
148 } | 148 } |
149 | 149 |
150 return true; | 150 return true; |
151 } | 151 } |
152 | 152 |
153 void PasswordGenerationManager::openPasswordGenerator( | 153 void PasswordGenerationManager::openPasswordGenerator( |
154 WebKit::WebInputElement& element) { | 154 WebKit::WebInputElement& element) { |
155 WebKit::WebElement button(element.passwordGeneratorButtonElement()); | 155 WebKit::WebElement button(element.passwordGeneratorButtonElement()); |
156 gfx::Rect rect(button.boundsInViewportSpace()); | 156 gfx::Rect rect(button.boundsInViewportSpace()); |
157 scoped_ptr<content::PasswordForm> password_form( | 157 scoped_ptr<content::PasswordForm> password_form( |
158 content::CreatePasswordForm(element.form())); | 158 CreatePasswordForm(element.form())); |
159 // We should not have shown the icon we can't create a valid PasswordForm. | 159 // We should not have shown the icon we can't create a valid PasswordForm. |
160 DCHECK(password_form.get()); | 160 DCHECK(password_form.get()); |
161 | 161 |
162 Send(new AutofillHostMsg_ShowPasswordGenerationPopup(routing_id(), | 162 Send(new AutofillHostMsg_ShowPasswordGenerationPopup(routing_id(), |
163 rect, | 163 rect, |
164 element.maxLength(), | 164 element.maxLength(), |
165 *password_form)); | 165 *password_form)); |
166 password_generation::LogPasswordGenerationEvent( | 166 password_generation::LogPasswordGenerationEvent( |
167 password_generation::BUBBLE_SHOWN); | 167 password_generation::BUBBLE_SHOWN); |
168 } | 168 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 passwords_[0].passwordGeneratorButtonElement().setAttribute("style", | 220 passwords_[0].passwordGeneratorButtonElement().setAttribute("style", |
221 "display:block"); | 221 "display:block"); |
222 password_generation::LogPasswordGenerationEvent( | 222 password_generation::LogPasswordGenerationEvent( |
223 password_generation::ICON_SHOWN); | 223 password_generation::ICON_SHOWN); |
224 return; | 224 return; |
225 } | 225 } |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
229 } // namespace autofill | 229 } // namespace autofill |
OLD | NEW |