Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(511)

Side by Side Diff: components/autofill/content/renderer/password_generation_manager.cc

Issue 23742004: Move PasswordForm from //content to //autofill. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_password_form_conversion_utils
Patch Set: Response to review Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/content/renderer/password_form_conversion_utils.h"
9 #include "components/autofill/core/common/autofill_messages.h" 9 #include "components/autofill/core/common/autofill_messages.h"
10 #include "components/autofill/core/common/password_generation_util.h" 10 #include "components/autofill/core/common/password_generation_util.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 return; 101 return;
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<autofill::PasswordForm> password_form(
Ilya Sherman 2013/09/05 22:53:35 nit: No need for namespace.
blundell 2013/09/06 08:36:25 Done.
112 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()))
(...skipping 25 matching lines...) Expand all
147 return false; 147 return false;
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<autofill::PasswordForm> password_form(
158 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 }
169 169
170 bool PasswordGenerationManager::OnMessageReceived(const IPC::Message& message) { 170 bool PasswordGenerationManager::OnMessageReceived(const IPC::Message& message) {
171 bool handled = true; 171 bool handled = true;
172 IPC_BEGIN_MESSAGE_MAP(PasswordGenerationManager, message) 172 IPC_BEGIN_MESSAGE_MAP(PasswordGenerationManager, message)
173 IPC_MESSAGE_HANDLER(AutofillMsg_FormNotBlacklisted, 173 IPC_MESSAGE_HANDLER(AutofillMsg_FormNotBlacklisted,
174 OnFormNotBlacklisted) 174 OnFormNotBlacklisted)
175 IPC_MESSAGE_HANDLER(AutofillMsg_GeneratedPasswordAccepted, 175 IPC_MESSAGE_HANDLER(AutofillMsg_GeneratedPasswordAccepted,
176 OnPasswordAccepted) 176 OnPasswordAccepted)
177 IPC_MESSAGE_HANDLER(AutofillMsg_PasswordGenerationEnabled, 177 IPC_MESSAGE_HANDLER(AutofillMsg_PasswordGenerationEnabled,
178 OnPasswordGenerationEnabled) 178 OnPasswordGenerationEnabled)
179 IPC_MESSAGE_UNHANDLED(handled = false) 179 IPC_MESSAGE_UNHANDLED(handled = false)
180 IPC_END_MESSAGE_MAP() 180 IPC_END_MESSAGE_MAP()
181 return handled; 181 return handled;
182 } 182 }
183 183
184 void PasswordGenerationManager::OnFormNotBlacklisted( 184 void PasswordGenerationManager::OnFormNotBlacklisted(
185 const content::PasswordForm& form) { 185 const autofill::PasswordForm& form) {
186 not_blacklisted_password_form_origins_.push_back(form.origin); 186 not_blacklisted_password_form_origins_.push_back(form.origin);
187 MaybeShowIcon(); 187 MaybeShowIcon();
188 } 188 }
189 189
190 void PasswordGenerationManager::OnPasswordAccepted( 190 void PasswordGenerationManager::OnPasswordAccepted(
191 const base::string16& password) { 191 const base::string16& password) {
192 for (std::vector<WebKit::WebInputElement>::iterator it = passwords_.begin(); 192 for (std::vector<WebKit::WebInputElement>::iterator it = passwords_.begin();
193 it != passwords_.end(); ++it) { 193 it != passwords_.end(); ++it) {
194 it->setValue(password); 194 it->setValue(password);
195 it->setAutofilled(true); 195 it->setAutofilled(true);
(...skipping 24 matching lines...) Expand all
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698