feature_list.cc 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #include "third_party/blink/public/common/features.h"
  17. #if BUILDFLAG(IS_MAC)
  18. #include "device/base/features.h" // nogncheck
  19. #endif
  20. namespace electron {
  21. void InitializeFeatureList() {
  22. auto* cmd_line = base::CommandLine::ForCurrentProcess();
  23. auto enable_features =
  24. cmd_line->GetSwitchValueASCII(::switches::kEnableFeatures);
  25. auto disable_features =
  26. cmd_line->GetSwitchValueASCII(::switches::kDisableFeatures);
  27. // Disable creation of spare renderer process with site-per-process mode,
  28. // it interferes with our process preference tracking for non sandboxed mode.
  29. // Can be reenabled when our site instance policy is aligned with chromium
  30. // when node integration is enabled.
  31. disable_features +=
  32. std::string(",") + features::kSpareRendererForSitePerProcess.name;
  33. #if BUILDFLAG(IS_WIN)
  34. disable_features +=
  35. // Disable async spellchecker suggestions for Windows, which causes
  36. // an empty suggestions list to be returned
  37. std::string(",") + spellcheck::kWinRetrieveSuggestionsOnlyOnDemand.name +
  38. // Delayed spellcheck initialization is causing the
  39. // 'custom dictionary word list API' spec to crash.
  40. std::string(",") + spellcheck::kWinDelaySpellcheckServiceInit.name;
  41. #endif
  42. std::string platform_specific_enable_features =
  43. EnablePlatformSpecificFeatures();
  44. if (platform_specific_enable_features.size() > 0) {
  45. enable_features += std::string(",") + platform_specific_enable_features;
  46. }
  47. base::FeatureList::InitInstance(enable_features, disable_features);
  48. }
  49. void InitializeFieldTrials() {
  50. auto* cmd_line = base::CommandLine::ForCurrentProcess();
  51. auto force_fieldtrials =
  52. cmd_line->GetSwitchValueASCII(::switches::kForceFieldTrials);
  53. base::FieldTrialList::CreateTrialsFromString(force_fieldtrials);
  54. }
  55. #if !BUILDFLAG(IS_MAC)
  56. std::string EnablePlatformSpecificFeatures() {
  57. return "";
  58. }
  59. #endif
  60. } // namespace electron