-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PageZoom] Add UKM for new zoom value on slider dismissal
This CL adds logging for UKM at the same point when existing UMA is logged: at dismissal of the Page Zoom slider if the user changed the slider value before dismissal. See UKM Collection in the Privacy Considerations section at go/clank-page-zoom-design for doc and UKM request. Bug: 1232536 Fixed: 1402526 Change-Id: I431d0a05efc1f841650340503f6a3c274eb75307 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4094081 Reviewed-by: Robert Kaplow <rkaplow@chromium.org> Reviewed-by: Mark Schillaci <mschillaci@google.com> Commit-Queue: Amanda Lin Dietz <aldietz@google.com> Cr-Commit-Position: refs/heads/main@{#1085286}
- Loading branch information
Showing
8 changed files
with
137 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...ty/android/java/src/org/chromium/components/browser_ui/accessibility/PageZoomMetrics.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2022 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package org.chromium.components.browser_ui.accessibility; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import org.chromium.base.annotations.JNINamespace; | ||
import org.chromium.base.annotations.NativeMethods; | ||
import org.chromium.content_public.browser.WebContents; | ||
|
||
/** | ||
* Centralizes metrics data collection for Page Zoom. | ||
*/ | ||
@JNINamespace("browser_ui") | ||
public class PageZoomMetrics { | ||
/** | ||
* Log new zoom level UKM for the given web contents. | ||
* Recorded on slider dismissal if the user chose a new value. | ||
* @param webContents WebContents for which to log value | ||
* @param newZoomLevel double - new zoom level | ||
*/ | ||
public static void logZoomLevelUKM(@NonNull WebContents webContents, double newZoomLevel) { | ||
PageZoomMetricsJni.get().logZoomLevelUKM(webContents, newZoomLevel); | ||
} | ||
|
||
@NativeMethods | ||
public interface Natives { | ||
void logZoomLevelUKM(WebContents webContents, double value); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
components/browser_ui/accessibility/android/page_zoom_metrics.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2022 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "components/browser_ui/accessibility/android/page_zoom_metrics.h" | ||
|
||
#include "base/android/scoped_java_ref.h" | ||
#include "components/browser_ui/accessibility/android/accessibility_jni_headers/PageZoomMetrics_jni.h" | ||
#include "content/public/browser/web_contents.h" | ||
#include "services/metrics/public/cpp/ukm_builders.h" | ||
#include "services/metrics/public/cpp/ukm_recorder.h" | ||
#include "services/metrics/public/cpp/ukm_source_id.h" | ||
|
||
namespace browser_ui { | ||
|
||
using base::android::JavaParamRef; | ||
using base::android::JavaRef; | ||
|
||
void JNI_PageZoomMetrics_LogZoomLevelUKM( | ||
JNIEnv* env, | ||
const base::android::JavaParamRef<jobject>& j_web_contents, | ||
jdouble newZoomLevel) { | ||
content::WebContents* web_contents = | ||
content::WebContents::FromJavaWebContents(j_web_contents); | ||
DCHECK(web_contents); | ||
|
||
ukm::SourceId ukm_source_id = | ||
web_contents->GetPrimaryMainFrame()->GetPageUkmSourceId(); | ||
|
||
ukm::builders::Accessibility_PageZoom(ukm_source_id) | ||
.SetSliderZoomValue((int)round(100 * newZoomLevel)) | ||
.Record(ukm::UkmRecorder::Get()); | ||
} | ||
|
||
} // namespace browser_ui |
28 changes: 28 additions & 0 deletions
28
components/browser_ui/accessibility/android/page_zoom_metrics.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2022 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef COMPONENTS_BROWSER_UI_ACCESSIBILITY_ANDROID_PAGE_ZOOM_METRICS_H_ | ||
#define COMPONENTS_BROWSER_UI_ACCESSIBILITY_ANDROID_PAGE_ZOOM_METRICS_H_ | ||
|
||
namespace content { | ||
class WebContents; | ||
} | ||
|
||
namespace browser_ui { | ||
|
||
/* | ||
* Native component to log metrics for Page Zoom. | ||
*/ | ||
class PageZoomMetrics { | ||
public: | ||
PageZoomMetrics(); | ||
~PageZoomMetrics(); | ||
|
||
// Logs UKM with the current zoom level for the specified WebContents. | ||
void LogZoomLevelUKM(content::WebContents* web_contents, double newZoomLevel); | ||
}; | ||
|
||
} // namespace browser_ui | ||
|
||
#endif // COMPONENTS_BROWSER_UI_ACCESSIBILITY_ANDROID_PAGE_ZOOM_METRICS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters