feature_list.cc 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. // PlzServiceWorker breaks fetching service worker scripts for custom
  30. // protocols or chrome-extension protocols due to a change in the URL loader
  31. // used to fetch the script.
  32. // TODO(MarshallOfSound): Re-enable and fix?
  33. disable_features += std::string(",") + features::kPlzServiceWorker.name;
  34. #if !BUILDFLAG(ENABLE_PICTURE_IN_PICTURE)
  35. disable_features += std::string(",") + media::kPictureInPicture.name;
  36. #endif
  37. #if defined(OS_WIN)
  38. // Disable async spellchecker suggestions for Windows, which causes
  39. // an empty suggestions list to be returned
  40. disable_features +=
  41. std::string(",") + spellcheck::kWinRetrieveSuggestionsOnlyOnDemand.name;
  42. #endif
  43. base::FeatureList::InitializeInstance(enable_features, disable_features);
  44. }
  45. void InitializeFieldTrials() {
  46. auto* cmd_line = base::CommandLine::ForCurrentProcess();
  47. auto force_fieldtrials =
  48. cmd_line->GetSwitchValueASCII(::switches::kForceFieldTrials);
  49. base::FieldTrialList::CreateTrialsFromString(force_fieldtrials);
  50. }
  51. } // namespace electron