From 7755ef2a9ab4b372f200d4466b1c95498b2fe07e Mon Sep 17 00:00:00 2001 From: ahmedmoussa Date: Fri, 22 Mar 2024 17:05:17 +0000 Subject: [PATCH] [live-preview] Add a new enum case to PreviewType of value kCameraAndMic This is needed for a dependant CL --> https://crrev.com/c/5379350 Bug: b:329311590 Change-Id: I2830571bae34eea77f41364c2ca46277da07d5aa Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5384605 Commit-Queue: Ahmed Moussa Reviewed-by: Bryant Chandler Cr-Commit-Position: refs/heads/main@{#1276940} --- .../ui/views/media_preview/media_coordinator.cc | 17 ++++++++++++++++- .../ui/views/media_preview/media_coordinator.h | 12 ++++++++---- .../media_preview/media_preview_metrics.cc | 2 ++ .../views/media_preview/media_preview_metrics.h | 3 ++- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/chrome/browser/ui/views/media_preview/media_coordinator.cc b/chrome/browser/ui/views/media_preview/media_coordinator.cc index 7f5a865b0e17c6..1f1656e3ecacc5 100644 --- a/chrome/browser/ui/views/media_preview/media_coordinator.cc +++ b/chrome/browser/ui/views/media_preview/media_coordinator.cc @@ -7,7 +7,6 @@ #include #include "chrome/browser/ui/views/chrome_layout_provider.h" -#include "chrome/browser/ui/views/media_preview/media_preview_metrics.h" #include "chrome/browser/ui/views/media_preview/media_view.h" #include "ui/color/color_id.h" #include "ui/views/background.h" @@ -82,3 +81,19 @@ void MediaCoordinator::UpdateDevicePreferenceRanking() { mic_coordinator_->UpdateDevicePreferenceRanking(); } } + +namespace media_coordinator { + +media_preview_metrics::PreviewType GetPreviewTypeFromMediaCoordinatorViewType( + MediaCoordinator::ViewType view_type) { + switch (view_type) { + case MediaCoordinator::ViewType::kBoth: + return media_preview_metrics::PreviewType::kCameraAndMic; + case MediaCoordinator::ViewType::kCameraOnly: + return media_preview_metrics::PreviewType::kCamera; + case MediaCoordinator::ViewType::kMicOnly: + return media_preview_metrics::PreviewType::kMic; + } +} + +} // namespace media_coordinator diff --git a/chrome/browser/ui/views/media_preview/media_coordinator.h b/chrome/browser/ui/views/media_preview/media_coordinator.h index c573ddd34b9648..99b7a336c3d2bd 100644 --- a/chrome/browser/ui/views/media_preview/media_coordinator.h +++ b/chrome/browser/ui/views/media_preview/media_coordinator.h @@ -11,13 +11,10 @@ #include #include "chrome/browser/ui/views/media_preview/camera_preview/camera_coordinator.h" +#include "chrome/browser/ui/views/media_preview/media_preview_metrics.h" #include "chrome/browser/ui/views/media_preview/mic_preview/mic_coordinator.h" #include "components/prefs/pref_service.h" -namespace media_preview_metrics { -struct Context; -} // namespace media_preview_metrics - namespace views { class View; } // namespace views @@ -59,4 +56,11 @@ class MediaCoordinator { std::optional mic_coordinator_; }; +namespace media_coordinator { + +media_preview_metrics::PreviewType GetPreviewTypeFromMediaCoordinatorViewType( + MediaCoordinator::ViewType view_type); + +} // namespace media_coordinator + #endif // CHROME_BROWSER_UI_VIEWS_MEDIA_PREVIEW_MEDIA_COORDINATOR_H_ diff --git a/chrome/browser/ui/views/media_preview/media_preview_metrics.cc b/chrome/browser/ui/views/media_preview/media_preview_metrics.cc index e23b5e4f4949ef..d42eb8cac7c4c0 100644 --- a/chrome/browser/ui/views/media_preview/media_preview_metrics.cc +++ b/chrome/browser/ui/views/media_preview/media_preview_metrics.cc @@ -56,6 +56,8 @@ std::optional MapContextToString( namespace media_preview_metrics { Context::Context(UiLocation ui_location) : ui_location(ui_location) {} +Context::Context(UiLocation ui_location, PreviewType preview_type) + : ui_location(ui_location), preview_type(preview_type) {} Context::~Context() = default; void RecordPageInfoCameraNumInUseDevices(int devices) { diff --git a/chrome/browser/ui/views/media_preview/media_preview_metrics.h b/chrome/browser/ui/views/media_preview/media_preview_metrics.h index 402524472e6e69..ae6df1f3d69b2b 100644 --- a/chrome/browser/ui/views/media_preview/media_preview_metrics.h +++ b/chrome/browser/ui/views/media_preview/media_preview_metrics.h @@ -8,10 +8,11 @@ namespace media_preview_metrics { enum class UiLocation { kPermissionPrompt, kPageInfo }; -enum class PreviewType { kUnknown, kCamera, kMic }; +enum class PreviewType { kUnknown, kCamera, kMic, kCameraAndMic }; struct Context { explicit Context(UiLocation ui_location); + Context(UiLocation ui_location, PreviewType preview_type); ~Context(); const UiLocation ui_location;