feature_list.cc 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright (c) 2019 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #include "electron/shell/browser/feature_list.h"
  5. #include <string>
  6. #include "base/base_switches.h"
  7. #include "base/command_line.h"
  8. #include "base/feature_list.h"
  9. #include "base/metrics/field_trial.h"
  10. #include "content/public/common/content_features.h"
  11. #include "electron/buildflags/buildflags.h"
  12. #include "media/base/media_switches.h"
  13. #include "net/base/features.h"
  14. #include "services/network/public/cpp/features.h"
  15. namespace electron {
  16. void InitializeFeatureList() {
  17. auto* cmd_line = base::CommandLine::ForCurrentProcess();
  18. auto enable_features =
  19. cmd_line->GetSwitchValueASCII(::switches::kEnableFeatures);
  20. auto disable_features =
  21. cmd_line->GetSwitchValueASCII(::switches::kDisableFeatures);
  22. // Disable creation of spare renderer process with site-per-process mode,
  23. // it interferes with our process preference tracking for non sandboxed mode.
  24. // Can be reenabled when our site instance policy is aligned with chromium
  25. // when node integration is enabled.
  26. disable_features +=
  27. std::string(",") + features::kSpareRendererForSitePerProcess.name +
  28. // Disable SameSite-by-default, this will be a breaking change for many
  29. // apps which cannot land in master until 11-x-y is branched out. For more
  30. // info
  31. // https://groups.google.com/a/chromium.org/g/embedder-dev/c/4yJi4Twj2NM/m/9bhpWureCAAJ
  32. std::string(",") + net::features::kSameSiteByDefaultCookies.name +
  33. std::string(",") +
  34. net::features::kCookiesWithoutSameSiteMustBeSecure.name +
  35. std::string(",") + network::features::kCertVerifierService.name;
  36. // https://www.polymer-project.org/blog/2018-10-02-webcomponents-v0-deprecations
  37. // https://chromium-review.googlesource.com/c/chromium/src/+/1869562
  38. // Any website which uses older WebComponents will fail in without this
  39. // enabled, since Electron does not support origin trials.
  40. enable_features += std::string(",") + "WebComponentsV0Enabled";
  41. #if !BUILDFLAG(ENABLE_PICTURE_IN_PICTURE)
  42. disable_features += std::string(",") + media::kPictureInPicture.name;
  43. #endif
  44. base::FeatureList::InitializeInstance(enable_features, disable_features);
  45. }
  46. void InitializeFieldTrials() {
  47. auto* cmd_line = base::CommandLine::ForCurrentProcess();
  48. auto force_fieldtrials =
  49. cmd_line->GetSwitchValueASCII(::switches::kForceFieldTrials);
  50. base::FieldTrialList::CreateTrialsFromString(force_fieldtrials);
  51. }
  52. } // namespace electron