summaryrefslogtreecommitdiff
path: root/chromium/content/common/site_isolation_policy.cc
blob: 41c3653efcf92a764cab618011f3acffb5cab5c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/common/site_isolation_policy.h"

#include "base/command_line.h"
#include "base/feature_list.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"

namespace content {

// static
bool SiteIsolationPolicy::AreCrossProcessFramesPossible() {
// Before turning this on for Android, input event routing needs to be
// completed there, and perf regressions in https://crbug.com/690229 need to be
// investigated.
#if defined(OS_ANDROID)
  return UseDedicatedProcessesForAllSites() ||
         IsTopDocumentIsolationEnabled() ||
         GetContentClient()->IsSupplementarySiteIsolationModeEnabled() ||
         base::FeatureList::IsEnabled(::features::kGuestViewCrossProcessFrames);
#else
  return true;
#endif
}

// static
bool SiteIsolationPolicy::UseDedicatedProcessesForAllSites() {
  return base::CommandLine::ForCurrentProcess()->HasSwitch(
      switches::kSitePerProcess);
}

// static
bool SiteIsolationPolicy::IsTopDocumentIsolationEnabled() {
  // --site-per-process trumps --top-document-isolation.
  if (UseDedicatedProcessesForAllSites())
    return false;

  return base::FeatureList::IsEnabled(::features::kTopDocumentIsolation);
}

}  // namespace content