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

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

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

Powered by Google App Engine
This is Rietveld 408576698