Chromium Code Reviews| Index: components/safe_browsing/password_protection/password_protection_request.cc |
| diff --git a/components/safe_browsing/password_protection/password_protection_request.cc b/components/safe_browsing/password_protection/password_protection_request.cc |
| index 4a1f36f352ad4ddc8bd76b7ce303a3cdcd19356d..e7367b4d196b47d018406418a11f445f7810647a 100644 |
| --- a/components/safe_browsing/password_protection/password_protection_request.cc |
| +++ b/components/safe_browsing/password_protection/password_protection_request.cc |
| @@ -21,12 +21,14 @@ PasswordProtectionRequest::PasswordProtectionRequest( |
| const GURL& main_frame_url, |
| const GURL& password_form_action, |
| const GURL& password_form_frame_url, |
| + const std::string& legitimate_domain, |
| LoginReputationClientRequest::TriggerType type, |
| PasswordProtectionService* pps, |
| int request_timeout_in_ms) |
| : main_frame_url_(main_frame_url), |
| password_form_action_(password_form_action), |
| password_form_frame_url_(password_form_frame_url), |
| + legitimate_domain_(legitimate_domain), |
| request_type_(type), |
| password_protection_service_(pps), |
| database_manager_(password_protection_service_->database_manager()), |
| @@ -96,22 +98,37 @@ void PasswordProtectionRequest::FillRequestProto() { |
| main_frame->set_frame_index(0 /* main frame */); |
| password_protection_service_->FillReferrerChain( |
| main_frame_url_, -1 /* tab id not available */, main_frame); |
| - LoginReputationClientRequest::Frame::Form* password_form; |
| - if (password_form_frame_url_ == main_frame_url_) { |
| - main_frame->set_has_password_field(true); |
| - password_form = main_frame->add_forms(); |
| - } else { |
| - LoginReputationClientRequest::Frame* password_frame = |
| - request_proto_->add_frames(); |
| - password_frame->set_url(password_form_frame_url_.spec()); |
| - password_frame->set_has_password_field(true); |
| - // TODO(jialiul): Add referrer chain for subframes later. |
| - password_form = password_frame->add_forms(); |
| + |
| + switch (request_type_) { |
| + case LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE: { |
| + LoginReputationClientRequest::Frame::Form* password_form; |
| + if (password_form_frame_url_ == main_frame_url_) { |
| + main_frame->set_has_password_field(true); |
|
Nathan Parker
2017/05/12 22:27:59
I think all this form/frame info should be filled
Jialiu Lin
2017/05/13 00:24:12
This is temporary. password form, password_form_fr
|
| + password_form = main_frame->add_forms(); |
| + } else { |
| + LoginReputationClientRequest::Frame* password_frame = |
| + request_proto_->add_frames(); |
| + password_frame->set_url(password_form_frame_url_.spec()); |
| + password_frame->set_has_password_field(true); |
|
Nathan Parker
2017/05/12 22:27:59
So do we need to set_has_password_field on both th
Jialiu Lin
2017/05/13 00:24:12
Agree. It is redundant. remove the filling of has_
|
| + // TODO(jialiul): Add referrer chain for subframes later. |
| + password_form = password_frame->add_forms(); |
| + } |
| + password_form->set_action_url(password_form_action_.spec()); |
| + password_form->set_has_password_field(true); |
| + // TODO(jialiul): Fill more frame specific info when Safe Browsing backend |
| + // is ready to handle these pieces of information. |
| + break; |
| + } |
| + case LoginReputationClientRequest::PASSWORD_REUSE_EVENT: { |
| + LoginReputationClientRequest::PasswordReuseEvent* password_reuse = |
| + request_proto_->mutable_password_reuse_event(); |
| + password_reuse->add_password_reused_original_origins(legitimate_domain_); |
|
Nathan Parker
2017/05/12 22:27:59
This one should only be filled for SBER. That's t
Jialiu Lin
2017/05/13 00:24:12
Yes, thanks for catching this.
|
| + // TODO(jialiul): Fill more password_reuse information. |
| + break; |
| + } |
| + default: |
| + NOTREACHED(); |
| } |
| - password_form->set_action_url(password_form_action_.spec()); |
| - password_form->set_has_password_field(true); |
| - // TODO(jialiul): Fill more frame specific info when Safe Browsing backend |
| - // is ready to handle these pieces of information. |
| } |
| void PasswordProtectionRequest::SendRequest() { |