1 // Copyright 2022 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "components/metrics/ui/form_factor_metrics_provider.h" 6 #include "build/config/chromebox_for_meetings/buildflags.h" // PLATFORM_CFM 7 8 #include "build/build_config.h" 9 #include "ui/base/device_form_factor.h" 10 11 #if BUILDFLAG(IS_ANDROID) 12 #include "base/android/build_info.h" 13 #endif // BUILDFLAG(IS_ANDROID) 14 15 namespace metrics { 16 ProvideSystemProfileMetrics(SystemProfileProto * system_profile_proto)17void FormFactorMetricsProvider::ProvideSystemProfileMetrics( 18 SystemProfileProto* system_profile_proto) { 19 system_profile_proto->mutable_hardware()->set_form_factor(GetFormFactor()); 20 } 21 22 SystemProfileProto::Hardware::FormFactor GetFormFactor() const23FormFactorMetricsProvider::GetFormFactor() const { 24 #if BUILDFLAG(IS_ANDROID) 25 // TODO(crbug.com/1300338): Move the TV form factor logic to 26 // ui/base/device_form_factor_android.cc. 27 if (base::android::BuildInfo::GetInstance()->is_tv()) 28 return SystemProfileProto::Hardware::FORM_FACTOR_TV; 29 if (base::android::BuildInfo::GetInstance()->is_automotive()) { 30 return SystemProfileProto::Hardware::FORM_FACTOR_AUTOMOTIVE; 31 } 32 #endif // BUILDFLAG(IS_ANDROID) 33 34 #if BUILDFLAG(PLATFORM_CFM) 35 return SystemProfileProto::Hardware::FORM_FACTOR_MEET_DEVICE; 36 #else 37 switch (ui::GetDeviceFormFactor()) { 38 case ui::DEVICE_FORM_FACTOR_DESKTOP: 39 return SystemProfileProto::Hardware::FORM_FACTOR_DESKTOP; 40 case ui::DEVICE_FORM_FACTOR_PHONE: 41 return SystemProfileProto::Hardware::FORM_FACTOR_PHONE; 42 case ui::DEVICE_FORM_FACTOR_TABLET: 43 return SystemProfileProto::Hardware::FORM_FACTOR_TABLET; 44 default: 45 return SystemProfileProto::Hardware::FORM_FACTOR_UNKNOWN; 46 } 47 #endif // BUILDFLAG(PLATFORM_CFM) 48 } 49 50 } // namespace metrics 51