variations_service_client.cc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/variations/service/variations_service_client.h"
  5. #include "base/command_line.h"
  6. #include "base/logging.h"
  7. #include "base/notreached.h"
  8. #include "base/system/sys_info.h"
  9. #include "components/variations/variations_switches.h"
  10. #include "ui/base/device_form_factor.h"
  11. namespace variations {
  12. version_info::Channel VariationsServiceClient::GetChannelForVariations() {
  13. const std::string forced_channel =
  14. base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
  15. switches::kFakeVariationsChannel);
  16. if (!forced_channel.empty()) {
  17. if (forced_channel == "stable")
  18. return version_info::Channel::STABLE;
  19. if (forced_channel == "beta")
  20. return version_info::Channel::BETA;
  21. if (forced_channel == "dev")
  22. return version_info::Channel::DEV;
  23. if (forced_channel == "canary")
  24. return version_info::Channel::CANARY;
  25. DVLOG(1) << "Invalid channel provided: " << forced_channel;
  26. }
  27. // Return the embedder-provided channel if no forced channel is specified.
  28. return GetChannel();
  29. }
  30. Study::FormFactor VariationsServiceClient::GetCurrentFormFactor() {
  31. switch (ui::GetDeviceFormFactor()) {
  32. case ui::DEVICE_FORM_FACTOR_PHONE:
  33. return Study::PHONE;
  34. case ui::DEVICE_FORM_FACTOR_TABLET:
  35. return Study::TABLET;
  36. case ui::DEVICE_FORM_FACTOR_DESKTOP:
  37. return Study::DESKTOP;
  38. }
  39. NOTREACHED();
  40. return Study::DESKTOP;
  41. }
  42. } // namespace variations