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

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

Issue 147533005: [Password Generation] Update UI to match final mocks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@replace_password_generation_ui
Patch Set: Comments Created 6 years, 10 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_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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 return; 275 return;
276 } 276 }
277 277
278 DVLOG(2) << "Password generation eligible form found"; 278 DVLOG(2) << "Password generation eligible form found";
279 generation_element_ = password_elements_[0]; 279 generation_element_ = password_elements_[0];
280 password_generation::LogPasswordGenerationEvent( 280 password_generation::LogPasswordGenerationEvent(
281 password_generation::GENERATION_AVAILABLE); 281 password_generation::GENERATION_AVAILABLE);
282 } 282 }
283 283
284 void PasswordGenerationAgent::FocusedNodeChanged(const blink::WebNode& node) { 284 void PasswordGenerationAgent::FocusedNodeChanged(const blink::WebNode& node) {
285 // TODO(gcasto): Re-hide generation_element text. 285 if (!generation_element_.isNull())
286 generation_element_.setShouldRevealPassword(false);
287
286 if (node.isNull() || !node.isElementNode()) 288 if (node.isNull() || !node.isElementNode())
287 return; 289 return;
288 290
289 const blink::WebElement web_element = node.toConst<blink::WebElement>(); 291 const blink::WebElement web_element = node.toConst<blink::WebElement>();
290 if (!web_element.document().frame()) 292 if (!web_element.document().frame())
291 return; 293 return;
292 294
293 const blink::WebInputElement* element = toWebInputElement(&web_element); 295 const blink::WebInputElement* element = toWebInputElement(&web_element);
294 if (!element || *element != generation_element_) 296 if (!element || *element != generation_element_)
295 return; 297 return;
296 298
297 if (password_is_generated_) { 299 if (password_is_generated_) {
298 // TODO(gcasto): Make characters visible. 300 generation_element_.setShouldRevealPassword(true);
299 ShowEditingPopup(); 301 ShowEditingPopup();
300 } 302 }
301 303
302 // Only trigger if the password field is empty. 304 // Only trigger if the password field is empty.
303 if (!element->isReadOnly() && 305 if (!element->isReadOnly() &&
304 element->isEnabled() && 306 element->isEnabled() &&
305 element->value().isEmpty()) { 307 element->value().isEmpty()) {
306 ShowGenerationPopup(); 308 ShowGenerationPopup();
307 } 309 }
308 } 310 }
309 311
310 bool PasswordGenerationAgent::TextDidChangeInTextField( 312 bool PasswordGenerationAgent::TextDidChangeInTextField(
311 const blink::WebInputElement& element) { 313 const blink::WebInputElement& element) {
312 if (element != generation_element_) 314 if (element != generation_element_)
313 return false; 315 return false;
314 316
315 if (element.value().isEmpty()) { 317 if (element.value().isEmpty()) {
316 if (password_is_generated_) { 318 if (password_is_generated_) {
317 // User generated a password and then deleted it. 319 // User generated a password and then deleted it.
318 password_generation::LogPasswordGenerationEvent( 320 password_generation::LogPasswordGenerationEvent(
319 password_generation::PASSWORD_DELETED); 321 password_generation::PASSWORD_DELETED);
320 } 322 }
321 323
324 // Do not treat the password as generated.
322 // TODO(gcasto): Set PasswordForm::type in the browser to TYPE_NORMAL. 325 // TODO(gcasto): Set PasswordForm::type in the browser to TYPE_NORMAL.
323 password_is_generated_ = false; 326 password_is_generated_ = false;
327 generation_element_.setShouldRevealPassword(false);
328
324 // Offer generation again. 329 // Offer generation again.
325 ShowGenerationPopup(); 330 ShowGenerationPopup();
326 } else if (!password_is_generated_) { 331 } else if (!password_is_generated_) {
327 // User has rejected the feature and has started typing a password. 332 // User has rejected the feature and has started typing a password.
328 HidePopup(); 333 HidePopup();
329 } else { 334 } else {
330 password_edited_ = true; 335 password_edited_ = true;
331 // Mirror edits to any confirmation password fields. 336 // Mirror edits to any confirmation password fields.
332 for (std::vector<blink::WebInputElement>::iterator it = 337 for (std::vector<blink::WebInputElement>::iterator it =
333 password_elements_.begin(); 338 password_elements_.begin();
(...skipping 30 matching lines...) Expand all
364 369
365 password_generation::LogPasswordGenerationEvent( 370 password_generation::LogPasswordGenerationEvent(
366 password_generation::EDITING_POPUP_SHOWN); 371 password_generation::EDITING_POPUP_SHOWN);
367 } 372 }
368 373
369 void PasswordGenerationAgent::HidePopup() { 374 void PasswordGenerationAgent::HidePopup() {
370 Send(new AutofillHostMsg_HidePasswordGenerationPopup(routing_id())); 375 Send(new AutofillHostMsg_HidePasswordGenerationPopup(routing_id()));
371 } 376 }
372 377
373 } // namespace autofill 378 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698