Commit 37e207eb authored by Eugene But's avatar Eugene But Committed by Commit Bot

Add UKM logging for Slim Navigation Manager URL mismatch.

This metric will help to diagnose possible URL spoofing bugs in Slim
Navigation feature. _documentURL is used as proxy for legacy navigation
manager URL, which is generally reliable and almost always match
last committed URL.

Collection review doc:
https://docs.google.com/document/d/14SygQ8BzLkzedTLuDfOHhakQHZOOJSU8TAJT3rxBGv4/edit#

Bug: 1182320
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I6dcf5711f0fd42063b67afb0fa0a99b77ce4c7a0
Reviewed-on: https://chromium-review.googlesource.com/1187014
Commit-Queue: Eugene But <eugenebut@chromium.org>
Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586110}
parent 19159489
......@@ -5,6 +5,7 @@ include_rules = [
"+ios/web",
"+mojo/public",
"+net",
"+services/metrics/public/cpp",
"+services/network/network_context.h",
"+services/network/public/cpp",
"+services/network/public/mojom",
......
......@@ -31,6 +31,7 @@ source_set("ui") {
"//ios/web/web_state/js",
"//ios/web/web_state/ui:wk_web_view_configuration_provider",
"//ios/web/webui:webui",
"//services/metrics/public/cpp:ukm_builders",
"//ui/base",
"//url",
]
......
......@@ -110,6 +110,7 @@
#include "net/base/net_errors.h"
#include "net/cert/x509_util_ios.h"
#include "net/ssl/ssl_info.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "ui/base/page_transition_types.h"
#include "url/gurl.h"
#include "url/url_constants.h"
......@@ -1272,13 +1273,20 @@ GURL URLEscapedForHistory(const GURL& url) {
_documentURL = newURL;
_interactionRegisteredSinceLastURLChange = NO;
}
if (web::GetWebClient()->IsSlimNavigationManagerEnabled() &&
(!context || !context->IsLoadingHtmlString()) &&
!IsWKInternalUrl(newURL) && _webView) {
if (web::GetWebClient()->IsSlimNavigationManagerEnabled() && context &&
!context->IsLoadingHtmlString() && !IsWKInternalUrl(newURL) && _webView) {
GURL documentOrigin = newURL.GetOrigin();
GURL committedOrigin = _webStateImpl->GetLastCommittedURL().GetOrigin();
DCHECK_EQ(documentOrigin, committedOrigin)
<< "Old and new URL detection system have a mismatch";
ukm::SourceId sourceID = ukm::ConvertToSourceId(
context->GetNavigationId(), ukm::SourceIdType::NAVIGATION_ID);
if (sourceID != ukm::kInvalidSourceId) {
ukm::builders::IOS_URLMismatchInLegacyAndSlimNavigationManager(sourceID)
.SetHasMismatch(documentOrigin != committedOrigin)
.Record(ukm::UkmRecorder::Get());
}
}
}
......
......@@ -4676,4 +4676,19 @@ be describing additional metrics about the same event.
</metric>
</event>
<event name="IOS.URLMismatchInLegacyAndSlimNavigationManager">
<owner>eugenebut@chromium.org</owner>
<owner>danyao@chromium.org</owner>
<summary>
Logged when LegacyNavigationManager and KWKBasedNavigationManager have
different last committed URLs. This means that either old or new navigation
system has a URL spoofing bug.
</summary>
<metric name="HasMismatch">
<summary>
True if there was a mismatch.
</summary>
</metric>
</event>
</ukm-configuration>
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