feature_list.cc 2.7 KB

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