Commit 55593427 authored by Jan Wilken Dörrie's avatar Jan Wilken Dörrie Committed by Commit Bot

[Passwords] Disable WellKnownChangePasswordTabHelper for ...

...PAGE_TRANSITION_LINK. The WellKnownChangePasswordTabHelper should
only be active if triggered from within the PasswordCheck, which has
a ui::PageTransition of PAGE_TRANSITION_TYPED.

Fixed: 1133795
Change-Id: I2d66be7c7236a050c8532835f401a94cd94d4b0d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2440892Reviewed-by: default avatarIoana Pandele <ioanap@chromium.org>
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812634}
parent f670a222
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "services/metrics/public/cpp/ukm_builders.h" #include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h" #include "services/metrics/public/cpp/ukm_recorder.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
#include "ui/base/page_transition_types.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
...@@ -59,6 +60,8 @@ WellKnownChangePasswordTabHelper::ShouldAllowRequest( ...@@ -59,6 +60,8 @@ WellKnownChangePasswordTabHelper::ShouldAllowRequest(
// Boolean order important, feature flag last. Otherwise it messes // Boolean order important, feature flag last. Otherwise it messes
// with usage statistics of control and experimental group (UMA). // with usage statistics of control and experimental group (UMA).
if (request_info.target_frame_is_main && if (request_info.target_frame_is_main &&
ui::PageTransitionCoreTypeIs(request_info.transition_type,
ui::PAGE_TRANSITION_TYPED) &&
web_state_->GetLastCommittedURL().is_empty() && // empty tab history web_state_->GetLastCommittedURL().is_empty() && // empty tab history
IsWellKnownChangePasswordUrl(request_url) && IsWellKnownChangePasswordUrl(request_url) &&
base::FeatureList::IsEnabled( base::FeatureList::IsEnabled(
......
...@@ -53,6 +53,18 @@ struct ServerResponse { ...@@ -53,6 +53,18 @@ struct ServerResponse {
constexpr char kMockChangePasswordPath[] = "/change-password-override"; constexpr char kMockChangePasswordPath[] = "/change-password-override";
// Re-implementation of web::LoadUrl() that allows specifying a custom page
// transition.
void LoadUrlWithTransition(web::WebState* web_state,
const GURL& url,
ui::PageTransition transition) {
web::NavigationManager* navigation_manager =
web_state->GetNavigationManager();
web::NavigationManager::WebLoadParams params(url);
params.transition_type = transition;
navigation_manager->LoadURLWithParams(params);
}
} // namespace } // namespace
class TestChangePasswordUrlService class TestChangePasswordUrlService
...@@ -271,3 +283,17 @@ TEST_F(WellKnownChangePasswordTabHelperTest, ...@@ -271,3 +283,17 @@ TEST_F(WellKnownChangePasswordTabHelperTest,
EXPECT_EQ(GetNavigatedUrl().path(), kMockChangePasswordPath); EXPECT_EQ(GetNavigatedUrl().path(), kMockChangePasswordPath);
ExpectUkmMetric(WellKnownChangePasswordResult::kFallbackToOverrideUrl); ExpectUkmMetric(WellKnownChangePasswordResult::kFallbackToOverrideUrl);
} }
TEST_F(WellKnownChangePasswordTabHelperTest,
NoSupportForChangePasswordForLinks) {
path_response_map_[kWellKnownChangePasswordPath] = {net::HTTP_OK, {}};
LoadUrlWithTransition(web_state(),
test_server_->GetURL(kWellKnownChangePasswordPath),
ui::PAGE_TRANSITION_LINK);
ASSERT_TRUE(WaitUntilLoaded());
EXPECT_EQ(GetNavigatedUrl().path(), kWellKnownChangePasswordPath);
// In the case of PAGE_TRANSITION_LINK the tab helper should not be active and
// no metrics should be recorded.
EXPECT_TRUE(test_recorder_->GetEntriesByName(UkmBuilder::kEntryName).empty());
}
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