12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- // Copyright 2019 The Chromium Authors. All rights reserved.
- // 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/logging.h"
- #include "base/notreached.h"
- #include "base/system/sys_info.h"
- #include "components/variations/variations_switches.h"
- #include "ui/base/device_form_factor.h"
- 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;
- }
- // Return the embedder-provided channel if no forced channel is specified.
- return GetChannel();
- }
- Study::FormFactor VariationsServiceClient::GetCurrentFormFactor() {
- 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;
- }
- NOTREACHED();
- return Study::DESKTOP;
- }
- } // namespace variations
|