feature_list.cc 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. // TODO(codebytere): Remove WebSQL support per crbug.com/695592.
  34. enable_features += std::string(",") + blink::features::kWebSQLAccess.name;
  35. #if BUILDFLAG(IS_WIN)
  36. disable_features +=
  37. // Disable async spellchecker suggestions for Windows, which causes
  38. // an empty suggestions list to be returned
  39. std::string(",") + spellcheck::kWinRetrieveSuggestionsOnlyOnDemand.name +
  40. // Delayed spellcheck initialization is causing the
  41. // 'custom dictionary word list API' spec to crash.
  42. std::string(",") + spellcheck::kWinDelaySpellcheckServiceInit.name;
  43. #endif
  44. std::string platform_specific_enable_features =
  45. EnablePlatformSpecificFeatures();
  46. if (platform_specific_enable_features.size() > 0) {
  47. enable_features += std::string(",") + platform_specific_enable_features;
  48. }
  49. base::FeatureList::InitInstance(enable_features, disable_features);
  50. }
  51. void InitializeFieldTrials() {
  52. auto* cmd_line = base::CommandLine::ForCurrentProcess();
  53. auto force_fieldtrials =
  54. cmd_line->GetSwitchValueASCII(::switches::kForceFieldTrials);
  55. base::FieldTrialList::CreateTrialsFromString(force_fieldtrials);
  56. }
  57. #if !BUILDFLAG(IS_MAC)
  58. std::string EnablePlatformSpecificFeatures() {
  59. return "";
  60. }
  61. #endif
  62. } // namespace electron