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

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

Issue 2352533003: [Autofill] Migrate ChromePasswordManagerClient<-->PasswordGenerationAgent IPCs to mojo. (Closed)
Patch Set: browser_tests partly Created 4 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_agent.h" 5 #include "components/autofill/content/renderer/password_generation_agent.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "components/autofill/content/common/autofill_messages.h"
12 #include "components/autofill/content/renderer/form_autofill_util.h" 11 #include "components/autofill/content/renderer/form_autofill_util.h"
13 #include "components/autofill/content/renderer/form_classifier.h" 12 #include "components/autofill/content/renderer/form_classifier.h"
14 #include "components/autofill/content/renderer/password_autofill_agent.h" 13 #include "components/autofill/content/renderer/password_autofill_agent.h"
15 #include "components/autofill/content/renderer/password_form_conversion_utils.h" 14 #include "components/autofill/content/renderer/password_form_conversion_utils.h"
16 #include "components/autofill/core/common/autofill_switches.h" 15 #include "components/autofill/core/common/autofill_switches.h"
17 #include "components/autofill/core/common/form_data.h" 16 #include "components/autofill/core/common/form_data.h"
18 #include "components/autofill/core/common/password_form.h" 17 #include "components/autofill/core/common/password_form.h"
19 #include "components/autofill/core/common/password_form_generation_data.h" 18 #include "components/autofill/core/common/password_form_generation_data.h"
20 #include "components/autofill/core/common/password_generation_util.h" 19 #include "components/autofill/core/common/password_generation_util.h"
20 #include "content/public/common/associated_interface_provider.h"
21 #include "content/public/renderer/render_frame.h" 21 #include "content/public/renderer/render_frame.h"
22 #include "content/public/renderer/render_view.h" 22 #include "content/public/renderer/render_view.h"
23 #include "google_apis/gaia/gaia_urls.h" 23 #include "google_apis/gaia/gaia_urls.h"
24 #include "services/shell/public/cpp/interface_registry.h" 24 #include "services/shell/public/cpp/interface_registry.h"
25 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 25 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
26 #include "third_party/WebKit/public/platform/WebVector.h" 26 #include "third_party/WebKit/public/platform/WebVector.h"
27 #include "third_party/WebKit/public/web/WebDocument.h" 27 #include "third_party/WebKit/public/web/WebDocument.h"
28 #include "third_party/WebKit/public/web/WebFormElement.h" 28 #include "third_party/WebKit/public/web/WebFormElement.h"
29 #include "third_party/WebKit/public/web/WebInputElement.h" 29 #include "third_party/WebKit/public/web/WebInputElement.h"
30 #include "third_party/WebKit/public/web/WebLocalFrame.h" 30 #include "third_party/WebKit/public/web/WebLocalFrame.h"
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 VLOG(2) << "Fields for generation are not found"; 410 VLOG(2) << "Fields for generation are not found";
411 return; 411 return;
412 } 412 }
413 generation_form_data_.reset(new AccountCreationFormData( 413 generation_form_data_.reset(new AccountCreationFormData(
414 possible_form_data.form, std::move(password_elements))); 414 possible_form_data.form, std::move(password_elements)));
415 generation_element_ = generation_form_data_->password_elements[0]; 415 generation_element_ = generation_form_data_->password_elements[0];
416 generation_element_.setAttribute("aria-autocomplete", "list"); 416 generation_element_.setAttribute("aria-autocomplete", "list");
417 password_generation::LogPasswordGenerationEvent( 417 password_generation::LogPasswordGenerationEvent(
418 password_generation::GENERATION_AVAILABLE); 418 password_generation::GENERATION_AVAILABLE);
419 possible_account_creation_forms_.clear(); 419 possible_account_creation_forms_.clear();
420 Send(new AutofillHostMsg_GenerationAvailableForForm( 420 GetPasswordManagerClient()->GenerationAvailableForForm(
421 routing_id(), 421 *generation_form_data_->form);
422 *generation_form_data_->form));
423 return; 422 return;
424 } 423 }
425 } 424 }
426 425
427 bool PasswordGenerationAgent::FocusedNodeHasChanged( 426 bool PasswordGenerationAgent::FocusedNodeHasChanged(
428 const blink::WebNode& node) { 427 const blink::WebNode& node) {
429 if (!generation_element_.isNull()) 428 if (!generation_element_.isNull())
430 generation_element_.setShouldRevealPassword(false); 429 generation_element_.setShouldRevealPassword(false);
431 430
432 if (node.isNull() || !node.isElementNode()) 431 if (node.isNull() || !node.isElementNode())
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 // will just keep the previous popup if one is already showing. 503 // will just keep the previous popup if one is already showing.
505 ShowGenerationPopup(); 504 ShowGenerationPopup();
506 } 505 }
507 506
508 return true; 507 return true;
509 } 508 }
510 509
511 void PasswordGenerationAgent::ShowGenerationPopup() { 510 void PasswordGenerationAgent::ShowGenerationPopup() {
512 if (!render_frame()) 511 if (!render_frame())
513 return; 512 return;
514 Send(new AutofillHostMsg_ShowPasswordGenerationPopup( 513 GetPasswordManagerClient()->ShowPasswordGenerationPopup(
515 routing_id(),
516 render_frame()->GetRenderView()->ElementBoundsInWindow( 514 render_frame()->GetRenderView()->ElementBoundsInWindow(
517 generation_element_), 515 generation_element_),
518 generation_element_.maxLength(), 516 generation_element_.maxLength(), generation_element_.nameForAutofill(),
519 generation_element_.nameForAutofill(), 517 is_manually_triggered_, *generation_form_data_->form);
520 is_manually_triggered_,
521 *generation_form_data_->form));
522 generation_popup_shown_ = true; 518 generation_popup_shown_ = true;
523 } 519 }
524 520
525 void PasswordGenerationAgent::ShowEditingPopup() { 521 void PasswordGenerationAgent::ShowEditingPopup() {
526 if (!render_frame()) 522 if (!render_frame())
527 return; 523 return;
528 Send(new AutofillHostMsg_ShowPasswordEditingPopup( 524 GetPasswordManagerClient()->ShowPasswordEditingPopup(
529 routing_id(), 525 render_frame()->GetRenderView()->ElementBoundsInWindow(
530 render_frame()->GetRenderView()->ElementBoundsInWindow( 526 generation_element_),
531 generation_element_), 527 *generation_form_data_->form);
532 *generation_form_data_->form));
533 editing_popup_shown_ = true; 528 editing_popup_shown_ = true;
534 } 529 }
535 530
536 void PasswordGenerationAgent::HidePopup() { 531 void PasswordGenerationAgent::HidePopup() {
537 Send(new AutofillHostMsg_HidePasswordGenerationPopup(routing_id())); 532 GetPasswordManagerClient()->HidePasswordGenerationPopup();
538 } 533 }
539 534
540 void PasswordGenerationAgent::UserTriggeredGeneratePassword() { 535 void PasswordGenerationAgent::UserTriggeredGeneratePassword() {
541 if (last_focused_password_element_.isNull() || !render_frame()) 536 if (last_focused_password_element_.isNull() || !render_frame())
542 return; 537 return;
543 538
544 blink::WebFormElement form = last_focused_password_element_.form(); 539 blink::WebFormElement form = last_focused_password_element_.form();
545 std::unique_ptr<PasswordForm> password_form; 540 std::unique_ptr<PasswordForm> password_form;
546 std::vector<blink::WebFormControlElement> control_elements; 541 std::vector<blink::WebFormControlElement> control_elements;
547 if (!form.isNull()) { 542 if (!form.isNull()) {
(...skipping 23 matching lines...) Expand all
571 is_manually_triggered_ = true; 566 is_manually_triggered_ = true;
572 ShowGenerationPopup(); 567 ShowGenerationPopup();
573 } 568 }
574 569
575 const mojom::PasswordManagerDriverPtr& 570 const mojom::PasswordManagerDriverPtr&
576 PasswordGenerationAgent::GetPasswordManagerDriver() { 571 PasswordGenerationAgent::GetPasswordManagerDriver() {
577 DCHECK(password_agent_); 572 DCHECK(password_agent_);
578 return password_agent_->GetPasswordManagerDriver(); 573 return password_agent_->GetPasswordManagerDriver();
579 } 574 }
580 575
576 const mojom::PasswordManagerClientAssociatedPtr&
577 PasswordGenerationAgent::GetPasswordManagerClient() {
578 if (!password_manager_client_) {
579 render_frame()->GetRemoteAssociatedInterfaces()->GetInterface(
580 &password_manager_client_);
581 }
582
583 return password_manager_client_;
584 }
585
581 } // namespace autofill 586 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698