feature_list.cc 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 "components/spellcheck/common/spellcheck_features.h"
  11. #include "content/public/common/content_features.h"
  12. #include "electron/buildflags/buildflags.h"
  13. #include "media/base/media_switches.h"
  14. #include "net/base/features.h"
  15. #include "services/network/public/cpp/features.h"
  16. namespace electron {
  17. void InitializeFeatureList() {
  18. auto* cmd_line = base::CommandLine::ForCurrentProcess();
  19. auto enable_features =
  20. cmd_line->GetSwitchValueASCII(::switches::kEnableFeatures);
  21. auto disable_features =
  22. cmd_line->GetSwitchValueASCII(::switches::kDisableFeatures);
  23. // Disable creation of spare renderer process with site-per-process mode,
  24. // it interferes with our process preference tracking for non sandboxed mode.
  25. // Can be reenabled when our site instance policy is aligned with chromium
  26. // when node integration is enabled.
  27. disable_features +=
  28. std::string(",") + features::kSpareRendererForSitePerProcess.name;
  29. #if !BUILDFLAG(ENABLE_PICTURE_IN_PICTURE)
  30. disable_features += std::string(",") + media::kPictureInPicture.name;
  31. #endif
  32. #if BUILDFLAG(IS_WIN)
  33. // Disable async spellchecker suggestions for Windows, which causes
  34. // an empty suggestions list to be returned
  35. disable_features +=
  36. std::string(",") + spellcheck::kWinRetrieveSuggestionsOnlyOnDemand.name;
  37. #endif
  38. base::FeatureList::InitializeInstance(enable_features, disable_features);
  39. }
  40. void InitializeFieldTrials() {
  41. auto* cmd_line = base::CommandLine::ForCurrentProcess();
  42. auto force_fieldtrials =
  43. cmd_line->GetSwitchValueASCII(::switches::kForceFieldTrials);
  44. base::FieldTrialList::CreateTrialsFromString(force_fieldtrials);
  45. }
  46. } // namespace electron