1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
// Copyright 2019 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/variations/service/variations_service_client.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/notreached.h"
#include "base/system/sys_info.h"
#include "build/config/chromebox_for_meetings/buildflags.h"
#include "components/variations/variations_switches.h"
#include "ui/base/device_form_factor.h"
#if BUILDFLAG(IS_ANDROID)
#include "base/android/build_info.h"
#endif
namespace variations {
version_info::Channel VariationsServiceClient::GetChannelForVariations() {
const std::string forced_channel =
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kFakeVariationsChannel);
if (!forced_channel.empty()) {
if (forced_channel == "stable")
return version_info::Channel::STABLE;
if (forced_channel == "beta")
return version_info::Channel::BETA;
if (forced_channel == "dev")
return version_info::Channel::DEV;
if (forced_channel == "canary")
return version_info::Channel::CANARY;
DVLOG(1) << "Invalid channel provided: " << forced_channel;
}
auto channel = GetChannel();
#if BUILDFLAG(IS_ANDROID)
// TODO(crbug.com/389565104): Remove this if block when ready to move desktop
// to stable builds.
if (channel == version_info::Channel::STABLE &&
base::android::BuildInfo::GetInstance()->is_desktop()) {
return version_info::Channel::DEV;
}
#endif
// Return the embedder-provided channel if no forced channel is specified.
return channel;
}
Study::FormFactor VariationsServiceClient::GetCurrentFormFactor() {
// Temporary workaround to report foldable for variations without affecting
// other form factors. This will be removed and replaced with a long-term
// solution in DeviceFormFactor::GetDeviceFormFactor() after conducting an
// audit of form factor usage or exposing ui_mode.
// FormFactorMetricsProvider::GetFormFactor() also needs to be updated.
#if BUILDFLAG(IS_ANDROID)
if (base::android::BuildInfo::GetInstance()->is_foldable()) {
return Study::FOLDABLE;
}
#endif
#if BUILDFLAG(PLATFORM_CFM)
return Study::MEET_DEVICE;
#else
switch (ui::GetDeviceFormFactor()) {
case ui::DEVICE_FORM_FACTOR_PHONE:
return Study::PHONE;
case ui::DEVICE_FORM_FACTOR_TABLET:
return Study::TABLET;
case ui::DEVICE_FORM_FACTOR_DESKTOP:
return Study::DESKTOP;
case ui::DEVICE_FORM_FACTOR_TV:
return Study::TV;
case ui::DEVICE_FORM_FACTOR_AUTOMOTIVE:
return Study::AUTOMOTIVE;
case ui::DEVICE_FORM_FACTOR_FOLDABLE:
return Study::FOLDABLE;
}
NOTREACHED();
#endif // BUILDFLAG(PLATFORM_CFM)
}
base::FilePath VariationsServiceClient::GetVariationsSeedFileDir() {
return base::FilePath();
}
std::unique_ptr<SeedResponse>
VariationsServiceClient::TakeSeedFromNativeVariationsSeedStore() {
return nullptr;
}
} // namespace variations
|