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

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

Issue 447873004: [Password Generation] Wait longer to dismiss suggestion UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
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_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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 const blink::WebInputElement* element = toWebInputElement(&web_element); 281 const blink::WebInputElement* element = toWebInputElement(&web_element);
282 if (!element || *element != generation_element_) 282 if (!element || *element != generation_element_)
283 return false; 283 return false;
284 284
285 if (password_is_generated_) { 285 if (password_is_generated_) {
286 generation_element_.setShouldRevealPassword(true); 286 generation_element_.setShouldRevealPassword(true);
287 ShowEditingPopup(); 287 ShowEditingPopup();
288 return true; 288 return true;
289 } 289 }
290 290
291 // Only trigger if the password field is empty. 291 // Assume that if the password field has less than kMaximumOfferSize
Ilya Sherman 2014/08/06 22:25:08 Optional nit: Hmm, "kMaximumOfferSize" makes me th
Garrett Casto 2014/08/08 18:19:19 Ah, there actually is an off by one error here. Th
292 // characters then the user is not finished typing their password and display
293 // the password suggestion.
Ilya Sherman 2014/08/06 22:25:08 This comment suggests that we think the user proba
Garrett Casto 2014/08/08 18:19:19 I think the idea is that they aren't finish, so it
292 if (!element->isReadOnly() && 294 if (!element->isReadOnly() &&
293 element->isEnabled() && 295 element->isEnabled() &&
294 element->value().isEmpty()) { 296 element->value().length() < kMaximumOfferSize) {
Ilya Sherman 2014/08/06 22:25:08 Optional nit: I think .size() is more commonly use
Garrett Casto 2014/08/08 18:19:19 blink::WebString doesn't have size()
295 ShowGenerationPopup(); 297 ShowGenerationPopup();
296 return true; 298 return true;
297 } 299 }
298 300
299 return false; 301 return false;
300 } 302 }
301 303
302 bool PasswordGenerationAgent::TextDidChangeInTextField( 304 bool PasswordGenerationAgent::TextDidChangeInTextField(
303 const blink::WebInputElement& element) { 305 const blink::WebInputElement& element) {
304 if (element != generation_element_) 306 if (element != generation_element_)
305 return false; 307 return false;
306 308
307 if (element.value().isEmpty()) { 309 if (element.value().isEmpty()) {
308 if (password_is_generated_) { 310 if (password_is_generated_) {
309 // User generated a password and then deleted it. 311 // User generated a password and then deleted it.
310 password_generation::LogPasswordGenerationEvent( 312 password_generation::LogPasswordGenerationEvent(
311 password_generation::PASSWORD_DELETED); 313 password_generation::PASSWORD_DELETED);
312 } 314 }
313 315
314 // Do not treat the password as generated. 316 // Do not treat the password as generated.
315 // TODO(gcasto): Set PasswordForm::type in the browser to TYPE_NORMAL. 317 // TODO(gcasto): Set PasswordForm::type in the browser to TYPE_NORMAL.
316 password_is_generated_ = false; 318 password_is_generated_ = false;
317 generation_element_.setShouldRevealPassword(false); 319 generation_element_.setShouldRevealPassword(false);
318 320
319 // Offer generation again. 321 // Offer generation again.
320 ShowGenerationPopup(); 322 ShowGenerationPopup();
321 } else if (!password_is_generated_) { 323 } else if (password_is_generated_) {
322 // User has rejected the feature and has started typing a password.
323 HidePopup();
324 } else {
325 password_edited_ = true; 324 password_edited_ = true;
326 // Mirror edits to any confirmation password fields. 325 // Mirror edits to any confirmation password fields.
327 for (std::vector<blink::WebInputElement>::iterator it = 326 for (std::vector<blink::WebInputElement>::iterator it =
328 password_elements_.begin(); 327 password_elements_.begin();
329 it != password_elements_.end(); ++it) { 328 it != password_elements_.end(); ++it) {
330 it->setValue(element.value()); 329 it->setValue(element.value());
331 } 330 }
331 } else if (element.value().length() > kMaximumOfferSize) {
Ilya Sherman 2014/08/06 22:25:08 If the comparison above is "<", then the inverse h
Garrett Casto 2014/08/08 18:19:19 This one is right, the other is wrong.
332 // User has rejected the feature and has started typing a password.
333 HidePopup();
334 } else {
335 // Password isn't generated and there is less than kMaximumOfferSize
Ilya Sherman 2014/08/06 22:25:08 nit: "is less" -> "are fewer"
Garrett Casto 2014/08/08 18:19:19 Done.
336 // characters typed, so keep offering the password.
337 ShowGenerationPopup();
Ilya Sherman 2014/08/06 22:25:08 This looks like it'll show a new popup, rather tha
Garrett Casto 2014/08/08 18:19:19 It actually just updates the bounds of the current
332 } 338 }
333 339
334 return true; 340 return true;
335 } 341 }
336 342
337 void PasswordGenerationAgent::ShowGenerationPopup() { 343 void PasswordGenerationAgent::ShowGenerationPopup() {
338 gfx::RectF bounding_box_scaled = 344 gfx::RectF bounding_box_scaled =
339 GetScaledBoundingBox(render_view_->GetWebView()->pageScaleFactor(), 345 GetScaledBoundingBox(render_view_->GetWebView()->pageScaleFactor(),
340 &generation_element_); 346 &generation_element_);
341 347
(...skipping 19 matching lines...) Expand all
361 367
362 password_generation::LogPasswordGenerationEvent( 368 password_generation::LogPasswordGenerationEvent(
363 password_generation::EDITING_POPUP_SHOWN); 369 password_generation::EDITING_POPUP_SHOWN);
364 } 370 }
365 371
366 void PasswordGenerationAgent::HidePopup() { 372 void PasswordGenerationAgent::HidePopup() {
367 Send(new AutofillHostMsg_HidePasswordGenerationPopup(routing_id())); 373 Send(new AutofillHostMsg_HidePasswordGenerationPopup(routing_id()));
368 } 374 }
369 375
370 } // namespace autofill 376 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698