features.cc 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/site_isolation/features.h"
  5. #include "build/build_config.h"
  6. namespace site_isolation {
  7. namespace features {
  8. const base::Feature kCacheSiteIsolationMemoryThreshold{
  9. "CacheSiteIsolationMemoryThreshold", base::FEATURE_DISABLED_BY_DEFAULT};
  10. // Controls a mode for dynamically process-isolating sites where the user has
  11. // entered a password. This is intended to be used primarily when full site
  12. // isolation is turned off. To check whether this mode is enabled, use
  13. // SiteIsolationPolicy::IsIsolationForPasswordSitesEnabled() rather than
  14. // checking the feature directly, since that decision is influenced by other
  15. // factors as well.
  16. const base::Feature kSiteIsolationForPasswordSites {
  17. "site-isolation-for-password-sites",
  18. // Enabled by default on Android; see https://crbug.com/849815. Note that this
  19. // should not affect Android Webview, which does not include this code.
  20. #if BUILDFLAG(IS_ANDROID)
  21. base::FEATURE_ENABLED_BY_DEFAULT
  22. #else
  23. base::FEATURE_DISABLED_BY_DEFAULT
  24. #endif
  25. };
  26. // Controls a mode for dynamically process-isolating sites where the user has
  27. // logged in via OAuth. These sites are determined by runtime heuristics.
  28. //
  29. // This is intended to be used primarily when full site isolation is turned
  30. // off. To check whether this mode is enabled, use
  31. // SiteIsolationPolicy::IsIsolationForOAuthSitesEnabled() rather than
  32. // checking the feature directly, since that decision is influenced by other
  33. // factors as well.
  34. //
  35. // This feature does not affect Android Webview, which does not include this
  36. // code.
  37. const base::Feature kSiteIsolationForOAuthSites{
  38. "SiteIsolationForOAuthSites",
  39. // Enabled by default on Android only; see https://crbug.com/1206770.
  40. #if BUILDFLAG(IS_ANDROID)
  41. base::FEATURE_ENABLED_BY_DEFAULT
  42. #else
  43. base::FEATURE_DISABLED_BY_DEFAULT
  44. #endif
  45. };
  46. // kSiteIsolationMemoryThresholds is checked before individual site isolation
  47. // mode base::Features (such as kSitePerProcess or
  48. // kSiteIsolationForPasswordSites), and (if enabled) can restrict those modes
  49. // to not apply to low-memory devices below a certain memory threshold. The
  50. // threshold for what is considered a "low memory" device can be set (in MB)
  51. // via field trial params with the names defined below, with independent params
  52. // for strict site isolation (kSitePerProcess) and partial site isolation modes
  53. // (kSiteIsolationForPasswordSites, kSiteIsolationForOAuthSites, etc). These
  54. // thresholds are compared against base::SysInfo::AmountOfPhysicalMemoryMB().
  55. // On devices below the memory threshold, the site isolation features such as
  56. // kSitePerProcess won't be checked at all, and field trials won't activate
  57. // either the control or the experiment group.
  58. const base::Feature kSiteIsolationMemoryThresholds{
  59. "SiteIsolationMemoryThresholds", base::FEATURE_DISABLED_BY_DEFAULT};
  60. const char kStrictSiteIsolationMemoryThresholdParamName[] =
  61. "strict_site_isolation_threshold_mb";
  62. const char kPartialSiteIsolationMemoryThresholdParamName[] =
  63. "partial_site_isolation_threshold_mb";
  64. } // namespace features
  65. } // namespace site_isolation