feature_list.cc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. base::FeatureList::InitInstance(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