Commit c3e5b738 authored by edchin's avatar edchin Committed by Commit Bot

[ios][PhishGuard] Pass in mime type into PasswordProtectionRequest

Design doc: go/bling-phishguard

Prepares files to move to /core folder.

The WebContents is mostly a pass-through object (not including CSD)
in PasswordProtectionRequest, except for the MIME type. This CL
passes the MIME type in so that we don't need to conditionally
compile calls to WebState and WebContents for this value.

Bug: 1147967
Change-Id: Ic7ba3180af78806a90df0f776cf6d984553af3f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2553386Reviewed-by: default avatarAli Juma <ajuma@chromium.org>
Reviewed-by: default avatarBettina Dea <bdea@chromium.org>
Commit-Queue: edchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830598}
parent 86ea57b3
...@@ -331,14 +331,16 @@ class ChromePasswordProtectionServiceTest ...@@ -331,14 +331,16 @@ class ChromePasswordProtectionServiceTest
{"somedomain.com"}}; {"somedomain.com"}};
if (trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE) { if (trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE) {
request_ = new PasswordProtectionRequest( request_ = new PasswordProtectionRequest(
web_contents(), GURL(kPhishingURL), GURL(), GURL(), kUserName, web_contents(), GURL(kPhishingURL), GURL(), GURL(),
web_contents()->GetContentsMimeType(), kUserName,
PasswordType::PASSWORD_TYPE_UNKNOWN, credentials, trigger_type, true, PasswordType::PASSWORD_TYPE_UNKNOWN, credentials, trigger_type, true,
service_.get(), 0); service_.get(), 0);
} else { } else {
ASSERT_EQ(LoginReputationClientRequest::PASSWORD_REUSE_EVENT, ASSERT_EQ(LoginReputationClientRequest::PASSWORD_REUSE_EVENT,
trigger_type); trigger_type);
request_ = new PasswordProtectionRequest( request_ = new PasswordProtectionRequest(
web_contents(), GURL(kPhishingURL), GURL(), GURL(), kUserName, web_contents(), GURL(kPhishingURL), GURL(), GURL(),
web_contents()->GetContentsMimeType(), kUserName,
reused_password_type, credentials, trigger_type, reused_password_type, credentials, trigger_type,
/* password_field_exists*/ true, service_.get(), /* password_field_exists*/ true, service_.get(),
/*request_timeout_in_ms=*/0); /*request_timeout_in_ms=*/0);
......
...@@ -55,6 +55,7 @@ class PasswordProtectionNavigationThrottleTest ...@@ -55,6 +55,7 @@ class PasswordProtectionNavigationThrottleTest
scoped_refptr<PasswordProtectionRequest> request = scoped_refptr<PasswordProtectionRequest> request =
new PasswordProtectionRequest( new PasswordProtectionRequest(
RenderViewHostTestHarness::web_contents(), GURL(), GURL(), GURL(), RenderViewHostTestHarness::web_contents(), GURL(), GURL(), GURL(),
RenderViewHostTestHarness::web_contents()->GetContentsMimeType(),
"username", PasswordType::PASSWORD_TYPE_UNKNOWN, credentials, "username", PasswordType::PASSWORD_TYPE_UNKNOWN, credentials,
LoginReputationClientRequest::PASSWORD_REUSE_EVENT, LoginReputationClientRequest::PASSWORD_REUSE_EVENT,
/* password_field_exists*/ true, password_protection_service.get(), /* password_field_exists*/ true, password_protection_service.get(),
......
...@@ -103,6 +103,7 @@ PasswordProtectionRequest::PasswordProtectionRequest( ...@@ -103,6 +103,7 @@ PasswordProtectionRequest::PasswordProtectionRequest(
const GURL& main_frame_url, const GURL& main_frame_url,
const GURL& password_form_action, const GURL& password_form_action,
const GURL& password_form_frame_url, const GURL& password_form_frame_url,
const std::string& mime_type,
const std::string& username, const std::string& username,
PasswordType password_type, PasswordType password_type,
const std::vector<password_manager::MatchingReusedCredential>& const std::vector<password_manager::MatchingReusedCredential>&
...@@ -116,6 +117,7 @@ PasswordProtectionRequest::PasswordProtectionRequest( ...@@ -116,6 +117,7 @@ PasswordProtectionRequest::PasswordProtectionRequest(
main_frame_url_(main_frame_url), main_frame_url_(main_frame_url),
password_form_action_(password_form_action), password_form_action_(password_form_action),
password_form_frame_url_(password_form_frame_url), password_form_frame_url_(password_form_frame_url),
mime_type_(mime_type),
username_(username), username_(username),
password_type_(password_type), password_type_(password_type),
matching_domains_(GetMatchingDomains(matching_reused_credentials)), matching_domains_(GetMatchingDomains(matching_reused_credentials)),
...@@ -258,7 +260,7 @@ void PasswordProtectionRequest::FillRequestProto(bool is_sampled_ping) { ...@@ -258,7 +260,7 @@ void PasswordProtectionRequest::FillRequestProto(bool is_sampled_ping) {
password_protection_service_->UserClickedThroughSBInterstitial(this); password_protection_service_->UserClickedThroughSBInterstitial(this);
request_proto_->set_clicked_through_interstitial( request_proto_->set_clicked_through_interstitial(
clicked_through_interstitial); clicked_through_interstitial);
request_proto_->set_content_type(web_contents_->GetContentsMimeType()); request_proto_->set_content_type(mime_type_);
#if BUILDFLAG(FULL_SAFE_BROWSING) #if BUILDFLAG(FULL_SAFE_BROWSING)
if (password_protection_service_->IsExtendedReporting() && if (password_protection_service_->IsExtendedReporting() &&
......
...@@ -77,6 +77,7 @@ class PasswordProtectionRequest ...@@ -77,6 +77,7 @@ class PasswordProtectionRequest
const GURL& main_frame_url, const GURL& main_frame_url,
const GURL& password_form_action, const GURL& password_form_action,
const GURL& password_form_frame_url, const GURL& password_form_frame_url,
const std::string& mime_type,
const std::string& username, const std::string& username,
PasswordType password_type, PasswordType password_type,
const std::vector<password_manager::MatchingReusedCredential>& const std::vector<password_manager::MatchingReusedCredential>&
...@@ -228,6 +229,9 @@ class PasswordProtectionRequest ...@@ -228,6 +229,9 @@ class PasswordProtectionRequest
// Frame url of the detected password form. // Frame url of the detected password form.
const GURL password_form_frame_url_; const GURL password_form_frame_url_;
// The contents MIME type.
const std::string& mime_type_;
// The username of the reused password hash. The username can be an email or // The username of the reused password hash. The username can be an email or
// a username for a non-GAIA or saved-password reuse. No validation has been // a username for a non-GAIA or saved-password reuse. No validation has been
// done on it. // done on it.
......
...@@ -230,9 +230,9 @@ void PasswordProtectionService::StartRequest( ...@@ -230,9 +230,9 @@ void PasswordProtectionService::StartRequest(
scoped_refptr<PasswordProtectionRequest> request( scoped_refptr<PasswordProtectionRequest> request(
new PasswordProtectionRequest( new PasswordProtectionRequest(
web_contents, main_frame_url, password_form_action, web_contents, main_frame_url, password_form_action,
password_form_frame_url, username, password_type, password_form_frame_url, web_contents->GetContentsMimeType(),
matching_reused_credentials, trigger_type, password_field_exists, username, password_type, matching_reused_credentials, trigger_type,
this, GetRequestTimeoutInMS())); password_field_exists, this, GetRequestTimeoutInMS()));
request->Start(); request->Start();
pending_requests_.insert(std::move(request)); pending_requests_.insert(std::move(request));
} }
......
...@@ -306,7 +306,8 @@ class PasswordProtectionServiceTest : public ::testing::TestWithParam<bool> { ...@@ -306,7 +306,8 @@ class PasswordProtectionServiceTest : public ::testing::TestWithParam<bool> {
request_ = new PasswordProtectionRequest( request_ = new PasswordProtectionRequest(
web_contents, target_url, GURL(kFormActionUrl), GURL(kPasswordFrameUrl), web_contents, target_url, GURL(kFormActionUrl), GURL(kPasswordFrameUrl),
kUserName, PasswordType::PASSWORD_TYPE_UNKNOWN, {}, web_contents->GetContentsMimeType(), kUserName,
PasswordType::PASSWORD_TYPE_UNKNOWN, {},
LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, true, LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, true,
password_protection_service_.get(), timeout_in_ms); password_protection_service_.get(), timeout_in_ms);
request_->Start(); request_->Start();
...@@ -325,7 +326,8 @@ class PasswordProtectionServiceTest : public ::testing::TestWithParam<bool> { ...@@ -325,7 +326,8 @@ class PasswordProtectionServiceTest : public ::testing::TestWithParam<bool> {
Return(match_whitelist ? AsyncMatch::MATCH : AsyncMatch::NO_MATCH)); Return(match_whitelist ? AsyncMatch::MATCH : AsyncMatch::NO_MATCH));
request_ = new PasswordProtectionRequest( request_ = new PasswordProtectionRequest(
web_contents, target_url, GURL(), GURL(), kUserName, type, web_contents, target_url, GURL(), GURL(),
web_contents->GetContentsMimeType(), kUserName, type,
matching_reused_credentials, matching_reused_credentials,
LoginReputationClientRequest::PASSWORD_REUSE_EVENT, true, LoginReputationClientRequest::PASSWORD_REUSE_EVENT, true,
password_protection_service_.get(), timeout_in_ms); password_protection_service_.get(), timeout_in_ms);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment