summaryrefslogtreecommitdiff
path: root/chromium/content
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/content')
-rw-r--r--chromium/content/app/strings/translations/content_strings_es.xtb2
-rw-r--r--chromium/content/browser/accessibility/dump_accessibility_tree_browsertest.cc35
-rw-r--r--chromium/content/browser/accessibility/one_shot_accessibility_tree_search_unittest.cc2
-rw-r--r--chromium/content/browser/accessibility/web_contents_accessibility_android.cc7
-rw-r--r--chromium/content/browser/browser_main_loop.cc15
-rw-r--r--chromium/content/browser/child_process_security_policy_impl.cc35
-rw-r--r--chromium/content/browser/child_process_security_policy_impl.h21
-rw-r--r--chromium/content/browser/child_process_security_policy_unittest.cc78
-rw-r--r--chromium/content/browser/frame_host/navigation_handle_impl.cc26
-rw-r--r--chromium/content/browser/frame_host/navigation_handle_impl.h11
-rw-r--r--chromium/content/browser/frame_host/navigation_request.cc72
-rw-r--r--chromium/content/browser/indexed_db/indexed_db_factory_impl.cc8
-rw-r--r--chromium/content/browser/isolated_origin_browsertest.cc32
-rw-r--r--chromium/content/browser/renderer_host/render_process_host_unittest.cc3
-rw-r--r--chromium/content/browser/site_instance_impl.cc17
-rw-r--r--chromium/content/browser/site_instance_impl_unittest.cc17
-rw-r--r--chromium/content/common/site_isolation_policy.cc46
-rw-r--r--chromium/content/common/site_isolation_policy.h21
-rw-r--r--chromium/content/common/site_isolation_policy_unittest.cc48
-rw-r--r--chromium/content/public/browser/content_browser_client.cc3
-rw-r--r--chromium/content/public/browser/content_browser_client.h6
-rw-r--r--chromium/content/public/common/content_features.cc7
-rw-r--r--chromium/content/public/common/content_features.h2
-rw-r--r--chromium/content/test/BUILD.gn1
24 files changed, 362 insertions, 153 deletions
diff --git a/chromium/content/app/strings/translations/content_strings_es.xtb b/chromium/content/app/strings/translations/content_strings_es.xtb
index 4c364581e7a..10077278318 100644
--- a/chromium/content/app/strings/translations/content_strings_es.xtb
+++ b/chromium/content/app/strings/translations/content_strings_es.xtb
@@ -57,7 +57,7 @@
<translation id="310520048233152454">Introduce una URL</translation>
<translation id="3175736971608411871">temporizador</translation>
<translation id="3199563858620722075">cuadro combinado</translation>
-<translation id="3450233048674729344">El valor debe inferior o igual a <ph name="MAXIMUM" /></translation>
+<translation id="3450233048674729344">El valor debe ser inferior o igual a <ph name="MAXIMUM" /></translation>
<translation id="3486220673238053218">definición</translation>
<translation id="3557673793733683882">encabezado <ph name="HEADING_LEVEL" /></translation>
<translation id="3639613635497528239">número de segundos restantes de la película</translation>
diff --git a/chromium/content/browser/accessibility/dump_accessibility_tree_browsertest.cc b/chromium/content/browser/accessibility/dump_accessibility_tree_browsertest.cc
index 067d18e4356..76c2d6efd49 100644
--- a/chromium/content/browser/accessibility/dump_accessibility_tree_browsertest.cc
+++ b/chromium/content/browser/accessibility/dump_accessibility_tree_browsertest.cc
@@ -1150,13 +1150,28 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
RunHtmlTest(FILE_PATH_LITERAL("iframe-cross-process.html"));
}
+// Flaky on Mac and Win
+#if defined(OS_WIN) || defined(OS_MACOSX)
+#define MAYBE_AccessibilityIframeCoordinates \
+ DISABLED_AccessibilityIframeCoordinates
+#else
+#define MAYBE_AccessibilityIframeCoordinates AccessibilityIframeCoordinates
+#endif
IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
- AccessibilityIframeCoordinates) {
+ MAYBE_AccessibilityIframeCoordinates) {
RunHtmlTest(FILE_PATH_LITERAL("iframe-coordinates.html"));
}
+// Flaky on Mac and Win
+#if defined(OS_WIN) || defined(OS_MACOSX)
+#define MAYBE_AccessibilityIframeCoordinatesCrossProcess \
+ DISABLED_AccessibilityIframeCoordinatesCrossProcess
+#else
+#define MAYBE_AccessibilityIframeCoordinatesCrossProcess \
+ AccessibilityIframeCoordinatesCrossProcess
+#endif
IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
- AccessibilityIframeCoordinatesCrossProcess) {
+ MAYBE_AccessibilityIframeCoordinatesCrossProcess) {
RunHtmlTest(FILE_PATH_LITERAL("iframe-coordinates-cross-process.html"));
}
@@ -1182,17 +1197,18 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
}
IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
- AccessibilityIframeTransformNested) {
+ DISABLED_AccessibilityIframeTransformNested) {
RunHtmlTest(FILE_PATH_LITERAL("iframe-transform-nested.html"));
}
-IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
- AccessibilityIframeTransformNestedCrossProcess) {
+IN_PROC_BROWSER_TEST_F(
+ DumpAccessibilityTreeTest,
+ DISABLED_AccessibilityIframeTransformNestedCrossProcess) {
RunHtmlTest(FILE_PATH_LITERAL("iframe-transform-nested-cross-process.html"));
}
IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
- AccessibilityIframeTransformScrolled) {
+ DISABLED_AccessibilityIframeTransformScrolled) {
RunHtmlTest(FILE_PATH_LITERAL("iframe-transform-scrolled.html"));
}
@@ -1494,12 +1510,13 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityObject) {
RunHtmlTest(FILE_PATH_LITERAL("object.html"));
}
-IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityOffscreen) {
+IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
+ DISABLED_AccessibilityOffscreen) {
RunHtmlTest(FILE_PATH_LITERAL("offscreen.html"));
}
IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
- AccessibilityOffscreenScroll) {
+ DISABLED_AccessibilityOffscreenScroll) {
RunHtmlTest(FILE_PATH_LITERAL("offscreen-scroll.html"));
}
@@ -1677,7 +1694,7 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityWbr) {
}
IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
- AccessibilityWindowCropsItems) {
+ DISABLED_AccessibilityWindowCropsItems) {
RunHtmlTest(FILE_PATH_LITERAL("window-crops-items.html"));
}
diff --git a/chromium/content/browser/accessibility/one_shot_accessibility_tree_search_unittest.cc b/chromium/content/browser/accessibility/one_shot_accessibility_tree_search_unittest.cc
index fe3cbfe4e80..23841fbacb6 100644
--- a/chromium/content/browser/accessibility/one_shot_accessibility_tree_search_unittest.cc
+++ b/chromium/content/browser/accessibility/one_shot_accessibility_tree_search_unittest.cc
@@ -187,7 +187,7 @@ TEST_F(MAYBE_OneShotAccessibilityTreeSearchTest,
EXPECT_EQ(4, search.GetMatchAtIndex(0)->GetId());
}
-TEST_F(MAYBE_OneShotAccessibilityTreeSearchTest, VisibleOnly) {
+TEST_F(MAYBE_OneShotAccessibilityTreeSearchTest, DISABLED_VisibleOnly) {
OneShotAccessibilityTreeSearch search(tree_->GetRoot());
search.SetVisibleOnly(true);
ASSERT_EQ(5U, search.CountMatches());
diff --git a/chromium/content/browser/accessibility/web_contents_accessibility_android.cc b/chromium/content/browser/accessibility/web_contents_accessibility_android.cc
index 732e5850f84..11d16927674 100644
--- a/chromium/content/browser/accessibility/web_contents_accessibility_android.cc
+++ b/chromium/content/browser/accessibility/web_contents_accessibility_android.cc
@@ -401,13 +401,6 @@ void WebContentsAccessibilityAndroid::UpdateEnabledState(bool enabled) {
// about to be destroyed).
if (manager)
manager->set_web_contents_accessibility(nullptr);
- // Note that disabling part is not useful at this moment since the mode will
- // be enabled again almost immediately for the renderer process that just
- // got swapped in. This boolean enable/disable logic will be expanded
- // to allow for more granular accessibility. See https://crbug.com/428494.
- accessibility_state->ResetAccessibilityMode();
- web_contents_->SetAccessibilityMode(
- accessibility_state->accessibility_mode());
}
}
diff --git a/chromium/content/browser/browser_main_loop.cc b/chromium/content/browser/browser_main_loop.cc
index b408b7914c4..b0c9546fdc8 100644
--- a/chromium/content/browser/browser_main_loop.cc
+++ b/chromium/content/browser/browser_main_loop.cc
@@ -89,6 +89,7 @@
#include "content/browser/webui/url_data_manager.h"
#include "content/common/content_switches_internal.h"
#include "content/common/service_manager/service_manager_connection_impl.h"
+#include "content/common/site_isolation_policy.h"
#include "content/common/task_scheduler.h"
#include "content/public/browser/browser_main_parts.h"
#include "content/public/browser/content_browser_client.h"
@@ -767,13 +768,6 @@ void BrowserMainLoop::PostMainMessageLoopStart() {
LevelDBWrapperImpl::EnableAggressiveCommitDelay();
}
- if (parsed_command_line_.HasSwitch(switches::kIsolateOrigins)) {
- ChildProcessSecurityPolicyImpl* policy =
- ChildProcessSecurityPolicyImpl::GetInstance();
- policy->AddIsolatedOriginsFromCommandLine(
- parsed_command_line_.GetSwitchValueASCII(switches::kIsolateOrigins));
- }
-
// Enable memory-infra dump providers.
InitSkiaEventTracer();
base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
@@ -874,12 +868,11 @@ int BrowserMainLoop::PreCreateThreads() {
// Initialize origins that are whitelisted for process isolation. Must be
// done after base::FeatureList is initialized, but before any navigations
// can happen.
- std::vector<url::Origin> origins =
- GetContentClient()->browser()->GetOriginsRequiringDedicatedProcess();
ChildProcessSecurityPolicyImpl* policy =
ChildProcessSecurityPolicyImpl::GetInstance();
- for (auto origin : origins)
- policy->AddIsolatedOrigin(origin);
+ policy->AddIsolatedOrigins(SiteIsolationPolicy::GetIsolatedOrigins());
+ policy->AddIsolatedOrigins(
+ GetContentClient()->browser()->GetOriginsRequiringDedicatedProcess());
EVP_set_buggy_rsa_parser(
base::FeatureList::IsEnabled(features::kBuggyRSAParser));
diff --git a/chromium/content/browser/child_process_security_policy_impl.cc b/chromium/content/browser/child_process_security_policy_impl.cc
index f9ca00994a4..3af4399e9bf 100644
--- a/chromium/content/browser/child_process_security_policy_impl.cc
+++ b/chromium/content/browser/child_process_security_policy_impl.cc
@@ -15,7 +15,6 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
-#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "build/build_config.h"
#include "content/browser/isolated_origin_util.h"
@@ -1144,26 +1143,24 @@ bool ChildProcessSecurityPolicyImpl::CanSendMidiSysExMessage(int child_id) {
return state->second->can_send_midi_sysex();
}
-void ChildProcessSecurityPolicyImpl::AddIsolatedOrigin(
- const url::Origin& origin) {
- CHECK(IsolatedOriginUtil::IsValidIsolatedOrigin(origin));
-
- base::AutoLock lock(lock_);
- CHECK(!isolated_origins_.count(origin))
- << "Duplicate isolated origin: " << origin.Serialize();
+void ChildProcessSecurityPolicyImpl::AddIsolatedOrigins(
+ std::vector<url::Origin> origins_to_add) {
+ // Filter out origins that cannot be used as an isolated origin.
+ auto end_of_valid_origins =
+ std::remove_if(origins_to_add.begin(), origins_to_add.end(),
+ [](const url::Origin& origin) {
+ if (IsolatedOriginUtil::IsValidIsolatedOrigin(origin))
+ return false; // Don't remove.
- isolated_origins_.insert(origin);
-}
+ LOG(ERROR) << "Invalid isolated origin: " << origin;
+ return true; // Remove.
+ });
+ origins_to_add.erase(end_of_valid_origins, origins_to_add.end());
-void ChildProcessSecurityPolicyImpl::AddIsolatedOriginsFromCommandLine(
- const std::string& origin_list) {
- for (const base::StringPiece& origin_piece :
- base::SplitStringPiece(origin_list, ",", base::TRIM_WHITESPACE,
- base::SPLIT_WANT_NONEMPTY)) {
- url::Origin origin((GURL(origin_piece)));
- if (!origin.unique())
- AddIsolatedOrigin(origin);
- }
+ // Taking the lock once and doing a batch insertion via base::flat_set::insert
+ // is important because of performance characteristics of base::flat_set.
+ base::AutoLock lock(lock_);
+ isolated_origins_.insert(origins_to_add.begin(), origins_to_add.end());
}
bool ChildProcessSecurityPolicyImpl::IsIsolatedOrigin(
diff --git a/chromium/content/browser/child_process_security_policy_impl.h b/chromium/content/browser/child_process_security_policy_impl.h
index 38f161bbb2e..9f522762eec 100644
--- a/chromium/content/browser/child_process_security_policy_impl.h
+++ b/chromium/content/browser/child_process_security_policy_impl.h
@@ -12,6 +12,7 @@
#include <vector>
#include "base/compiler_specific.h"
+#include "base/containers/flat_set.h"
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
@@ -208,7 +209,7 @@ class CONTENT_EXPORT ChildProcessSecurityPolicyImpl
// Returns true if sending system exclusive messages is allowed.
bool CanSendMidiSysExMessage(int child_id);
- // Add an origin to the list of origins that require process isolation.
+ // Add |origins| to the list of origins that require process isolation.
// When making process model decisions for such origins, the full
// scheme+host+port tuple rather than scheme and eTLD+1 will be used.
// SiteInstances for these origins will also use the full origin as site URL.
@@ -218,7 +219,7 @@ class CONTENT_EXPORT ChildProcessSecurityPolicyImpl
// isolated origin, then https://bar.isolated.foo.com will be considered part
// of the site for https://isolated.foo.com.
//
- // Note that |origin| must not be unique. URLs that render with
+ // Note that origins from |origins| must not be unique - URLs that render with
// unique origins, such as data: URLs, are not supported. Suborigins (see
// https://w3c.github.io/webappsec-suborigins/ -- not to be confused with
// subdomains) and non-standard schemes are also not supported. Sandboxed
@@ -228,13 +229,10 @@ class CONTENT_EXPORT ChildProcessSecurityPolicyImpl
// origin opens an about:blank popup, it will stay in the isolated origin's
// process. Nested URLs (filesystem: and blob:) retain process isolation
// behavior of their inner origin.
- void AddIsolatedOrigin(const url::Origin& origin);
-
- // Register a set of isolated origins as specified on the command line with
- // the --isolate-origins flag. |origin_list| is the flag's value, which
- // contains the list of comma-separated scheme-host-port origins. See
- // AddIsolatedOrigin for definition of an isolated origin.
- void AddIsolatedOriginsFromCommandLine(const std::string& origin_list);
+ //
+ // Note that it is okay if |origins| contains duplicates - the set of origins
+ // will be deduplicated inside the method.
+ void AddIsolatedOrigins(std::vector<url::Origin> origins);
// Check whether |origin| requires origin-wide process isolation.
//
@@ -287,8 +285,7 @@ class CONTENT_EXPORT ChildProcessSecurityPolicyImpl
FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyInProcessBrowserTest,
NoLeak);
FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest, FilePermissions);
- FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest,
- IsolateOriginsFromCommandLine);
+ FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest, AddIsolatedOrigins);
class SecurityState;
@@ -377,7 +374,7 @@ class CONTENT_EXPORT ChildProcessSecurityPolicyImpl
// when making process model decisions, rather than the origin's scheme and
// eTLD+1. Each of these origins requires a dedicated process. This set is
// protected by |lock_|.
- std::set<url::Origin> isolated_origins_;
+ base::flat_set<url::Origin> isolated_origins_;
DISALLOW_COPY_AND_ASSIGN(ChildProcessSecurityPolicyImpl);
};
diff --git a/chromium/content/browser/child_process_security_policy_unittest.cc b/chromium/content/browser/child_process_security_policy_unittest.cc
index 6b69dd7fe38..1cf98396e0d 100644
--- a/chromium/content/browser/child_process_security_policy_unittest.cc
+++ b/chromium/content/browser/child_process_security_policy_unittest.cc
@@ -6,6 +6,8 @@
#include <string>
#include "base/files/file_path.h"
+#include "base/logging.h"
+#include "base/test/mock_log.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/public/common/url_constants.h"
#include "content/test/test_content_browser_client.h"
@@ -13,6 +15,7 @@
#include "storage/browser/fileapi/file_system_url.h"
#include "storage/browser/fileapi/isolated_context.h"
#include "storage/common/fileapi/file_system_types.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#include "url/origin.h"
@@ -973,30 +976,59 @@ TEST_F(ChildProcessSecurityPolicyTest, OriginGranting) {
p->Remove(kRendererID);
}
+// Verifies ChildProcessSecurityPolicyImpl::AddIsolatedOrigins method.
+TEST_F(ChildProcessSecurityPolicyTest, AddIsolatedOrigins) {
+ url::Origin foo = url::Origin::Create(GURL("https://foo.com/"));
+ url::Origin bar = url::Origin::Create(GURL("https://bar.com/"));
+ url::Origin baz = url::Origin::Create(GURL("https://baz.com/"));
+ url::Origin foobar = url::Origin::Create(GURL("https://foobar.com/"));
+ url::Origin baz_http_8000 = url::Origin::Create(GURL("http://baz.com:8000/"));
+ url::Origin baz_https_8000 =
+ url::Origin::Create(GURL("https://baz.com:8000/"));
+ url::Origin invalid_etld = url::Origin::Create(GURL("https://gov/"));
+ ChildProcessSecurityPolicyImpl* p =
+ ChildProcessSecurityPolicyImpl::GetInstance();
-// Verifies parsing logic that extracts origins from --isolate-origins.
-TEST_F(ChildProcessSecurityPolicyTest, IsolateOriginsFromCommandLine) {
- // Invalid and unique origins are not permitted.
- auto* policy = ChildProcessSecurityPolicyImpl::GetInstance();
- policy->AddIsolatedOriginsFromCommandLine("foo");
- policy->AddIsolatedOriginsFromCommandLine("");
- policy->AddIsolatedOriginsFromCommandLine("about:blank");
- EXPECT_EQ(0U, policy->isolated_origins_.size());
-
- policy->AddIsolatedOriginsFromCommandLine("http://isolated.foo.com");
- EXPECT_EQ(1U, policy->isolated_origins_.size());
- EXPECT_TRUE(
- policy->IsIsolatedOrigin(url::Origin(GURL("http://isolated.foo.com"))));
-
- policy->AddIsolatedOriginsFromCommandLine(
- "http://a.com,https://b.com,,https://c.com:8000");
- EXPECT_EQ(4U, policy->isolated_origins_.size());
- EXPECT_TRUE(
- policy->IsIsolatedOrigin(url::Origin(GURL("http://isolated.foo.com"))));
- EXPECT_TRUE(policy->IsIsolatedOrigin(url::Origin(GURL("http://a.com"))));
- EXPECT_TRUE(policy->IsIsolatedOrigin(url::Origin(GURL("https://b.com"))));
- EXPECT_TRUE(
- policy->IsIsolatedOrigin(url::Origin(GURL("https://c.com:8000"))));
+ // Initially there should be no isolated origins.
+ EXPECT_THAT(p->isolated_origins_, testing::IsEmpty());
+
+ // Verify deduplication of the argument.
+ p->AddIsolatedOrigins({foo, bar, bar});
+ EXPECT_THAT(p->isolated_origins_, testing::UnorderedElementsAre(foo, bar));
+
+ // Verify that the old set is extended (not replaced).
+ p->AddIsolatedOrigins({baz});
+ EXPECT_THAT(p->isolated_origins_,
+ testing::UnorderedElementsAre(foo, bar, baz));
+
+ // Verify deduplication against the old set.
+ p->AddIsolatedOrigins({foo});
+ EXPECT_THAT(p->isolated_origins_,
+ testing::UnorderedElementsAre(foo, bar, baz));
+
+ // Verify deduplication considers scheme and port differences.
+ p->AddIsolatedOrigins({baz, baz_http_8000, baz_https_8000});
+ EXPECT_THAT(p->isolated_origins_,
+ testing::UnorderedElementsAre(foo, bar, baz, baz_http_8000,
+ baz_https_8000));
+
+ // Verify that adding an origin that is invalid for isolation will 1) log a
+ // warning and 2) won't CHECK or crash the browser process, 3) will not add
+ // the invalid origin, but will add the remaining origins passed to
+ // AddIsolatedOrigins.
+ {
+ base::test::MockLog mock_log;
+ EXPECT_CALL(mock_log,
+ Log(::logging::LOG_ERROR, testing::_, testing::_, testing::_,
+ testing::HasSubstr(invalid_etld.Serialize())))
+ .Times(1);
+
+ mock_log.StartCapturingLogs();
+ p->AddIsolatedOrigins({foobar, invalid_etld});
+ EXPECT_THAT(p->isolated_origins_,
+ testing::UnorderedElementsAre(foo, bar, baz, baz_http_8000,
+ baz_https_8000, foobar));
+ }
}
} // namespace content
diff --git a/chromium/content/browser/frame_host/navigation_handle_impl.cc b/chromium/content/browser/frame_host/navigation_handle_impl.cc
index 28048bdb204..e56b81ef55e 100644
--- a/chromium/content/browser/frame_host/navigation_handle_impl.cc
+++ b/chromium/content/browser/frame_host/navigation_handle_impl.cc
@@ -605,19 +605,14 @@ void NavigationHandleImpl::WillStartRequest(
RunCompleteCallback(result);
}
-void NavigationHandleImpl::WillRedirectRequest(
+void NavigationHandleImpl::UpdateStateFollowingRedirect(
const GURL& new_url,
const std::string& new_method,
const GURL& new_referrer_url,
bool new_is_external_protocol,
scoped_refptr<net::HttpResponseHeaders> response_headers,
net::HttpResponseInfo::ConnectionInfo connection_info,
- RenderProcessHost* post_redirect_process,
const ThrottleChecksFinishedCallback& callback) {
- TRACE_EVENT_ASYNC_STEP_INTO1("navigation", "NavigationHandle", this,
- "WillRedirectRequest", "url",
- new_url.possibly_invalid_spec());
-
// |new_url| is not expected to be a "renderer debug" url. It should be
// blocked in NavigationRequest::OnRequestRedirected or in
// ResourceLoader::OnReceivedRedirect. If it is not the case,
@@ -629,7 +624,6 @@ void NavigationHandleImpl::WillRedirectRequest(
// Update the navigation parameters.
url_ = new_url;
method_ = new_method;
- UpdateSiteURL(post_redirect_process);
if (!(transition_ & ui::PAGE_TRANSITION_CLIENT_REDIRECT)) {
sanitized_referrer_.url = new_referrer_url;
@@ -647,6 +641,24 @@ void NavigationHandleImpl::WillRedirectRequest(
state_ = WILL_REDIRECT_REQUEST;
complete_callback_ = callback;
+}
+
+void NavigationHandleImpl::WillRedirectRequest(
+ const GURL& new_url,
+ const std::string& new_method,
+ const GURL& new_referrer_url,
+ bool new_is_external_protocol,
+ scoped_refptr<net::HttpResponseHeaders> response_headers,
+ net::HttpResponseInfo::ConnectionInfo connection_info,
+ RenderProcessHost* post_redirect_process,
+ const ThrottleChecksFinishedCallback& callback) {
+ TRACE_EVENT_ASYNC_STEP_INTO1("navigation", "NavigationHandle", this,
+ "WillRedirectRequest", "url",
+ new_url.possibly_invalid_spec());
+ UpdateStateFollowingRedirect(new_url, new_method, new_referrer_url,
+ new_is_external_protocol, response_headers,
+ connection_info, callback);
+ UpdateSiteURL(post_redirect_process);
if (IsSelfReferentialURL()) {
state_ = CANCELING;
diff --git a/chromium/content/browser/frame_host/navigation_handle_impl.h b/chromium/content/browser/frame_host/navigation_handle_impl.h
index c3be1f7534b..711b50c3f45 100644
--- a/chromium/content/browser/frame_host/navigation_handle_impl.h
+++ b/chromium/content/browser/frame_host/navigation_handle_impl.h
@@ -277,6 +277,17 @@ class CONTENT_EXPORT NavigationHandleImpl : public NavigationHandle {
blink::WebMixedContentContextType mixed_content_context_type,
const ThrottleChecksFinishedCallback& callback);
+ // Updates the state of the navigation handle after encountering a server
+ // redirect.
+ void UpdateStateFollowingRedirect(
+ const GURL& new_url,
+ const std::string& new_method,
+ const GURL& new_referrer_url,
+ bool new_is_external_protocol,
+ scoped_refptr<net::HttpResponseHeaders> response_headers,
+ net::HttpResponseInfo::ConnectionInfo connection_info,
+ const ThrottleChecksFinishedCallback& callback);
+
// Called when the URLRequest will be redirected in the network stack.
// |callback| will be called when all throttles check have completed. This
// will allow the caller to cancel the navigation or let it proceed.
diff --git a/chromium/content/browser/frame_host/navigation_request.cc b/chromium/content/browser/frame_host/navigation_request.cc
index 51d638924ab..66cbc43ab67 100644
--- a/chromium/content/browser/frame_host/navigation_request.cc
+++ b/chromium/content/browser/frame_host/navigation_request.cc
@@ -577,6 +577,41 @@ void NavigationRequest::TransferNavigationHandleOwnership(
void NavigationRequest::OnRequestRedirected(
const net::RedirectInfo& redirect_info,
const scoped_refptr<ResourceResponse>& response) {
+#if defined(OS_ANDROID)
+ base::WeakPtr<NavigationRequest> this_ptr(weak_factory_.GetWeakPtr());
+
+ bool should_override_url_loading =
+ GetContentClient()->browser()->ShouldOverrideUrlLoading(
+ frame_tree_node_->frame_tree_node_id(), browser_initiated_,
+ redirect_info.new_url, redirect_info.new_method,
+ // Redirects are always not counted as from user gesture.
+ false, true, frame_tree_node_->IsMainFrame(),
+ common_params_.transition);
+
+ // The content/ embedder might cause |this| to be deleted while
+ // |ShouldOverrideUrlLoading| is called.
+ // See https://crbug.com/770157.
+ if (!this_ptr)
+ return;
+
+ if (should_override_url_loading) {
+ bool is_external_protocol =
+ !GetContentClient()->browser()->IsHandledURL(common_params_.url);
+ navigation_handle_->set_net_error_code(net::ERR_ABORTED);
+ // Update the navigation handle to point to the new url to ensure
+ // AwWebContents sees the new URL and thus passes that URL to onPageFinished
+ // (rather than passing the old URL).
+ navigation_handle_->UpdateStateFollowingRedirect(
+ redirect_info.new_url, redirect_info.new_method,
+ GURL(redirect_info.new_referrer), is_external_protocol,
+ response->head.headers, response->head.connection_info,
+ base::Bind(&NavigationRequest::OnRedirectChecksComplete,
+ base::Unretained(this)));
+ frame_tree_node_->ResetNavigationRequest(false, true);
+ return;
+ }
+#endif
+
if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRedirectToURL(
redirect_info.new_url)) {
DVLOG(1) << "Denied redirect for "
@@ -606,8 +641,13 @@ void NavigationRequest::OnRequestRedirected(
// destination could change.
dest_site_instance_ = nullptr;
+ // For now, DevTools needs the POST data sent to the renderer process even if
+ // it is no longer a POST after the redirect.
+ // TODO(caseq): Send the requestWillBeSent from browser and remove the
+ // IsNetworkHandlerEnabled check here.
// If the navigation is no longer a POST, the POST data should be reset.
- if (redirect_info.new_method != "POST")
+ if (redirect_info.new_method != "POST" &&
+ !RenderFrameDevToolsAgentHost::IsNetworkHandlerEnabled(frame_tree_node_))
common_params_.post_data = nullptr;
// Mark time for the Navigation Timing API.
@@ -670,10 +710,6 @@ void NavigationRequest::OnRequestRedirected(
RenderProcessHost* expected_process =
site_instance->HasProcess() ? site_instance->GetProcess() : nullptr;
-#if defined(OS_ANDROID)
- base::WeakPtr<NavigationRequest> this_ptr(weak_factory_.GetWeakPtr());
-#endif
-
// It's safe to use base::Unretained because this NavigationRequest owns the
// NavigationHandle where the callback will be stored.
bool is_external_protocol =
@@ -684,32 +720,6 @@ void NavigationRequest::OnRequestRedirected(
response->head.connection_info, expected_process,
base::Bind(&NavigationRequest::OnRedirectChecksComplete,
base::Unretained(this)));
-// |this| may be deleted.
-
-#if defined(OS_ANDROID)
- if (!this_ptr)
- return;
-
- bool should_override_url_loading =
- GetContentClient()->browser()->ShouldOverrideUrlLoading(
- frame_tree_node_->frame_tree_node_id(), browser_initiated_,
- redirect_info.new_url, redirect_info.new_method,
- // Redirects are always not counted as from user gesture.
- false, true, frame_tree_node_->IsMainFrame(),
- common_params_.transition);
-
- // The content/ embedder might cause |this| to be deleted while
- // |ShouldOverrideUrlLoading| is called.
- // See https://crbug.com/770157.
- if (!this_ptr)
- return;
-
- if (should_override_url_loading) {
- navigation_handle_->set_net_error_code(net::ERR_ABORTED);
- frame_tree_node_->ResetNavigationRequest(false, true);
- return;
- }
-#endif
}
void NavigationRequest::OnResponseStarted(
diff --git a/chromium/content/browser/indexed_db/indexed_db_factory_impl.cc b/chromium/content/browser/indexed_db/indexed_db_factory_impl.cc
index 6e14aeec34c..22ca3685fb0 100644
--- a/chromium/content/browser/indexed_db/indexed_db_factory_impl.cc
+++ b/chromium/content/browser/indexed_db/indexed_db_factory_impl.cc
@@ -12,6 +12,7 @@
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
+#include "base/metrics/histogram_macros.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/default_clock.h"
@@ -473,8 +474,11 @@ void IndexedDBFactoryImpl::HandleBackingStoreCorruption(
// so our corruption info file will remain.
leveldb::Status s =
IndexedDBBackingStore::DestroyBackingStore(path_base, saved_origin);
- if (!s.ok())
- DLOG(ERROR) << "Unable to delete backing store: " << s.ToString();
+ DLOG_IF(ERROR, !s.ok()) << "Unable to delete backing store: " << s.ToString();
+ UMA_HISTOGRAM_ENUMERATION(
+ "WebCore.IndexedDB.DestroyCorruptBackingStoreStatus",
+ leveldb_env::GetLevelDBStatusUMAValue(s),
+ leveldb_env::LEVELDB_STATUS_MAX);
}
bool IndexedDBFactoryImpl::IsDatabaseOpen(const Origin& origin,
diff --git a/chromium/content/browser/isolated_origin_browsertest.cc b/chromium/content/browser/isolated_origin_browsertest.cc
index d441653ac6b..cef4700c066 100644
--- a/chromium/content/browser/isolated_origin_browsertest.cc
+++ b/chromium/content/browser/isolated_origin_browsertest.cc
@@ -3,12 +3,15 @@
// found in the LICENSE file.
#include "base/command_line.h"
+#include "base/macros.h"
+#include "base/test/scoped_feature_list.h"
#include "content/browser/bad_message.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/storage_partition_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/browser_side_navigation_policy.h"
+#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h"
@@ -55,6 +58,9 @@ class IsolatedOriginTest : public ContentBrowserTest {
"document.body.appendChild(link);"
"link.click();"));
}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(IsolatedOriginTest);
};
// Check that navigating a main frame from an non-isolated origin to an
@@ -896,6 +902,8 @@ class StoragePartitonInterceptor
// Keep a pointer to the original implementation of the service, so all
// calls can be forwarded to it.
mojom::StoragePartitionService* storage_partition_service_;
+
+ DISALLOW_COPY_AND_ASSIGN(StoragePartitonInterceptor);
};
void CreateTestStoragePartitionService(
@@ -929,4 +937,28 @@ IN_PROC_BROWSER_TEST_F(IsolatedOriginTest, LocalStorageOriginEnforcement) {
crash_observer.Wait();
}
+class IsolatedOriginFieldTrialTest : public ContentBrowserTest {
+ public:
+ IsolatedOriginFieldTrialTest() {
+ scoped_feature_list_.InitAndEnableFeatureWithParameters(
+ features::kIsolateOrigins,
+ {{features::kIsolateOriginsFieldTrialParamName,
+ "https://field.trial.com/,https://bar.com/"}});
+ }
+ ~IsolatedOriginFieldTrialTest() override {}
+
+ private:
+ base::test::ScopedFeatureList scoped_feature_list_;
+
+ DISALLOW_COPY_AND_ASSIGN(IsolatedOriginFieldTrialTest);
+};
+
+IN_PROC_BROWSER_TEST_F(IsolatedOriginFieldTrialTest, Test) {
+ auto* policy = ChildProcessSecurityPolicyImpl::GetInstance();
+ EXPECT_TRUE(policy->IsIsolatedOrigin(
+ url::Origin::Create(GURL("https://field.trial.com/"))));
+ EXPECT_TRUE(
+ policy->IsIsolatedOrigin(url::Origin::Create(GURL("https://bar.com/"))));
+}
+
} // namespace content
diff --git a/chromium/content/browser/renderer_host/render_process_host_unittest.cc b/chromium/content/browser/renderer_host/render_process_host_unittest.cc
index e0872a52e98..01e3171e028 100644
--- a/chromium/content/browser/renderer_host/render_process_host_unittest.cc
+++ b/chromium/content/browser/renderer_host/render_process_host_unittest.cc
@@ -604,7 +604,8 @@ class EffectiveURLContentBrowserClient : public ContentBrowserClient {
private:
GURL GetEffectiveURL(BrowserContext* browser_context,
- const GURL& url) override {
+ const GURL& url,
+ bool is_isolated_origin) override {
if (url == url_to_modify_)
return url_to_return_;
return url;
diff --git a/chromium/content/browser/site_instance_impl.cc b/chromium/content/browser/site_instance_impl.cc
index 6be22050f5c..68f9dbe8532 100644
--- a/chromium/content/browser/site_instance_impl.cc
+++ b/chromium/content/browser/site_instance_impl.cc
@@ -364,10 +364,13 @@ GURL SiteInstance::GetSiteForURL(BrowserContext* browser_context,
url::Origin origin(url);
// Isolated origins should use the full origin as their site URL. A subdomain
- // of an isolated origin should also use that isolated origin's site URL.
+ // of an isolated origin should also use that isolated origin's site URL. It
+ // is important to check |url| rather than |real_url| here, since some
+ // effective URLs (such as for NTP) need to be resolved prior to the isolated
+ // origin lookup.
auto* policy = ChildProcessSecurityPolicyImpl::GetInstance();
url::Origin isolated_origin;
- if (policy->GetMatchingIsolatedOrigin(url::Origin(real_url),
+ if (policy->GetMatchingIsolatedOrigin(url::Origin(url),
&isolated_origin)) {
return isolated_origin.GetURL();
}
@@ -397,14 +400,10 @@ GURL SiteInstance::GetSiteForURL(BrowserContext* browser_context,
// static
GURL SiteInstanceImpl::GetEffectiveURL(BrowserContext* browser_context,
const GURL& url) {
- // Don't resolve URLs corresponding to isolated origins, as isolated origins
- // take precedence over hosted apps.
auto* policy = ChildProcessSecurityPolicyImpl::GetInstance();
- if (policy->IsIsolatedOrigin(url::Origin(url)))
- return url;
-
- return GetContentClient()->browser()->
- GetEffectiveURL(browser_context, url);
+ bool is_isolated_origin = policy->IsIsolatedOrigin(url::Origin(url));
+ return GetContentClient()->browser()->GetEffectiveURL(browser_context, url,
+ is_isolated_origin);
}
// static
diff --git a/chromium/content/browser/site_instance_impl_unittest.cc b/chromium/content/browser/site_instance_impl_unittest.cc
index 2d1b28d9992..c523ca9a06b 100644
--- a/chromium/content/browser/site_instance_impl_unittest.cc
+++ b/chromium/content/browser/site_instance_impl_unittest.cc
@@ -7,6 +7,7 @@
#include <stddef.h>
#include <memory>
+#include <string>
#include <vector>
#include "base/command_line.h"
@@ -47,7 +48,7 @@ const char kPrivilegedScheme[] = "privileged";
class SiteInstanceTestBrowserClient : public TestContentBrowserClient {
public:
- explicit SiteInstanceTestBrowserClient()
+ SiteInstanceTestBrowserClient()
: privileged_process_id_(-1),
site_instance_delete_count_(0),
browsing_instance_delete_count_(0) {
@@ -896,7 +897,7 @@ TEST_F(SiteInstanceTest, IsolatedOrigins) {
EXPECT_FALSE(policy->IsIsolatedOrigin(url::Origin(isolated_foo_url)));
EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, foo_url, isolated_foo_url));
- policy->AddIsolatedOrigin(url::Origin(isolated_foo_url));
+ policy->AddIsolatedOrigins({url::Origin(isolated_foo_url)});
EXPECT_TRUE(policy->IsIsolatedOrigin(url::Origin(isolated_foo_url)));
EXPECT_FALSE(policy->IsIsolatedOrigin(url::Origin(foo_url)));
EXPECT_FALSE(policy->IsIsolatedOrigin(url::Origin(GURL("http://foo.com"))));
@@ -907,7 +908,7 @@ TEST_F(SiteInstanceTest, IsolatedOrigins) {
EXPECT_FALSE(policy->IsIsolatedOrigin(
url::Origin(GURL("http://isolated.foo.com:12345"))));
- policy->AddIsolatedOrigin(url::Origin(isolated_bar_url));
+ policy->AddIsolatedOrigins({url::Origin(isolated_bar_url)});
EXPECT_TRUE(policy->IsIsolatedOrigin(url::Origin(isolated_bar_url)));
// IsSameWebSite should compare origins rather than sites if either URL is an
@@ -997,7 +998,7 @@ TEST_F(SiteInstanceTest, SubdomainOnIsolatedSite) {
GURL foo_isolated_url("http://foo.isolated.com");
auto* policy = ChildProcessSecurityPolicyImpl::GetInstance();
- policy->AddIsolatedOrigin(url::Origin(isolated_url));
+ policy->AddIsolatedOrigins({url::Origin(isolated_url)});
EXPECT_TRUE(policy->IsIsolatedOrigin(url::Origin(isolated_url)));
EXPECT_TRUE(policy->IsIsolatedOrigin(url::Origin(foo_isolated_url)));
@@ -1031,7 +1032,7 @@ TEST_F(SiteInstanceTest, SubdomainOnIsolatedSite) {
// Don't try to match subdomains on IP addresses.
GURL isolated_ip("http://127.0.0.1");
- policy->AddIsolatedOrigin(url::Origin(isolated_ip));
+ policy->AddIsolatedOrigins({url::Origin(isolated_ip)});
EXPECT_TRUE(policy->IsIsolatedOrigin(url::Origin(isolated_ip)));
EXPECT_FALSE(
policy->IsIsolatedOrigin(url::Origin(GURL("http://42.127.0.0.1"))));
@@ -1047,7 +1048,7 @@ TEST_F(SiteInstanceTest, SubdomainOnIsolatedOrigin) {
GURL baz_isolated_foo_url("http://baz.isolated.foo.com");
auto* policy = ChildProcessSecurityPolicyImpl::GetInstance();
- policy->AddIsolatedOrigin(url::Origin(isolated_foo_url));
+ policy->AddIsolatedOrigins({url::Origin(isolated_foo_url)});
EXPECT_FALSE(policy->IsIsolatedOrigin(url::Origin(foo_url)));
EXPECT_TRUE(policy->IsIsolatedOrigin(url::Origin(isolated_foo_url)));
@@ -1099,8 +1100,8 @@ TEST_F(SiteInstanceTest, MultipleIsolatedOriginsWithCommonSite) {
GURL qux_baz_bar_foo_url("http://qux.baz.bar.foo.com");
auto* policy = ChildProcessSecurityPolicyImpl::GetInstance();
- policy->AddIsolatedOrigin(url::Origin(foo_url));
- policy->AddIsolatedOrigin(url::Origin(baz_bar_foo_url));
+ policy->AddIsolatedOrigins({url::Origin(foo_url)});
+ policy->AddIsolatedOrigins({url::Origin(baz_bar_foo_url)});
EXPECT_TRUE(policy->IsIsolatedOrigin(url::Origin(foo_url)));
EXPECT_TRUE(policy->IsIsolatedOrigin(url::Origin(bar_foo_url)));
diff --git a/chromium/content/common/site_isolation_policy.cc b/chromium/content/common/site_isolation_policy.cc
index 8ee09a9c4f8..0d277b01a89 100644
--- a/chromium/content/common/site_isolation_policy.cc
+++ b/chromium/content/common/site_isolation_policy.cc
@@ -4,10 +4,15 @@
#include "content/common/site_isolation_policy.h"
+#include <string>
+
#include "base/command_line.h"
#include "base/feature_list.h"
+#include "base/metrics/field_trial_params.h"
+#include "base/strings/string_split.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
+#include "url/gurl.h"
namespace content {
@@ -29,12 +34,43 @@ bool SiteIsolationPolicy::IsTopDocumentIsolationEnabled() {
// static
bool SiteIsolationPolicy::AreIsolatedOriginsEnabled() {
- // TODO(alexmos): This currently assumes that isolated origins are only added
- // via the command-line switch, which may not be true in the future. Remove
- // this function when AreCrossProcessFramesPossible becomes true on Android
- // above.
return base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kIsolateOrigins);
+ switches::kIsolateOrigins) ||
+ base::FeatureList::IsEnabled(features::kIsolateOrigins);
+}
+
+// static
+std::vector<url::Origin> SiteIsolationPolicy::GetIsolatedOrigins() {
+ std::string cmdline_arg =
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kIsolateOrigins);
+ if (!cmdline_arg.empty())
+ return ParseIsolatedOrigins(cmdline_arg);
+
+ if (base::FeatureList::IsEnabled(features::kIsolateOrigins)) {
+ std::string field_trial_arg = base::GetFieldTrialParamValueByFeature(
+ features::kIsolateOrigins,
+ features::kIsolateOriginsFieldTrialParamName);
+ return ParseIsolatedOrigins(field_trial_arg);
+ }
+
+ return std::vector<url::Origin>();
+}
+
+// static
+std::vector<url::Origin> SiteIsolationPolicy::ParseIsolatedOrigins(
+ base::StringPiece arg) {
+ std::vector<base::StringPiece> origin_strings = base::SplitStringPiece(
+ arg, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
+
+ std::vector<url::Origin> origins;
+ origins.reserve(origin_strings.size());
+ for (const base::StringPiece& origin_string : origin_strings) {
+ url::Origin origin = url::Origin::Create(GURL(origin_string));
+ if (!origin.unique())
+ origins.push_back(origin);
+ }
+ return origins;
}
} // namespace content
diff --git a/chromium/content/common/site_isolation_policy.h b/chromium/content/common/site_isolation_policy.h
index b097a704f60..44afe7d5c6e 100644
--- a/chromium/content/common/site_isolation_policy.h
+++ b/chromium/content/common/site_isolation_policy.h
@@ -5,9 +5,13 @@
#ifndef CONTENT_COMMON_SITE_ISOLATION_POLICY_H_
#define CONTENT_COMMON_SITE_ISOLATION_POLICY_H_
+#include <vector>
+
+#include "base/gtest_prod_util.h"
#include "base/macros.h"
+#include "base/strings/string_piece_forward.h"
#include "content/common/content_export.h"
-#include "url/gurl.h"
+#include "url/origin.h"
namespace content {
@@ -15,7 +19,7 @@ namespace content {
// site isolation, --site-per-process, and related features.
//
// This is currently static because all these modes are controlled by command-
-// line flags.
+// line flags or field trials.
//
// These methods can be called from any thread.
class CONTENT_EXPORT SiteIsolationPolicy {
@@ -27,14 +31,21 @@ class CONTENT_EXPORT SiteIsolationPolicy {
// different process from the main frame.
static bool IsTopDocumentIsolationEnabled();
- // Returns true if there exist origins that require process isolation. Such
- // origins require a dedicated process, and hence they make cross-process
- // iframes possible.
+ // Returns true if isolated origins feature is enabled.
static bool AreIsolatedOriginsEnabled();
+ // Returns the origins to isolate. See also AreIsolatedOriginsEnabled.
+ // This list applies globally to the whole browser in all profiles.
+ // TODO(lukasza): Make sure this list also includes the origins returned by
+ // ContentBrowserClient::GetOriginsRequiringDedicatedProcess.
+ static std::vector<url::Origin> GetIsolatedOrigins();
+
private:
SiteIsolationPolicy(); // Not instantiable.
+ FRIEND_TEST_ALL_PREFIXES(SiteIsolationPolicyTest, ParseIsolatedOrigins);
+ static std::vector<url::Origin> ParseIsolatedOrigins(base::StringPiece arg);
+
DISALLOW_COPY_AND_ASSIGN(SiteIsolationPolicy);
};
diff --git a/chromium/content/common/site_isolation_policy_unittest.cc b/chromium/content/common/site_isolation_policy_unittest.cc
new file mode 100644
index 00000000000..b3935e68ab7
--- /dev/null
+++ b/chromium/content/common/site_isolation_policy_unittest.cc
@@ -0,0 +1,48 @@
+// Copyright 2017 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 "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "url/gurl.h"
+#include "url/origin.h"
+
+namespace content {
+
+// Verifies parsing logic in SiteIsolationPolicy::ParseIsolatedOrigins.
+TEST(SiteIsolationPolicyTest, ParseIsolatedOrigins) {
+ // Invalid and unique origins are not permitted.
+ EXPECT_THAT(SiteIsolationPolicy::ParseIsolatedOrigins("foo"),
+ testing::IsEmpty());
+ EXPECT_THAT(SiteIsolationPolicy::ParseIsolatedOrigins(""),
+ testing::IsEmpty());
+ EXPECT_THAT(SiteIsolationPolicy::ParseIsolatedOrigins("about:blank"),
+ testing::IsEmpty());
+
+ // Single simple, valid origin.
+ EXPECT_THAT(
+ SiteIsolationPolicy::ParseIsolatedOrigins("http://isolated.foo.com"),
+ testing::ElementsAre(
+ url::Origin::Create(GURL("http://isolated.foo.com"))));
+
+ // Multiple comma-separated origins.
+ EXPECT_THAT(
+ SiteIsolationPolicy::ParseIsolatedOrigins(
+ "http://a.com,https://b.com,,https://c.com:8000"),
+ testing::ElementsAre(url::Origin::Create(GURL("http://a.com")),
+ url::Origin::Create(GURL("https://b.com")),
+ url::Origin::Create(GURL("https://c.com:8000"))));
+
+ // ParseIsolatedOrigins should not do any deduplication (that is the job of
+ // ChildProcessSecurityPolicyImpl::AddIsolatedOrigins).
+ EXPECT_THAT(
+ SiteIsolationPolicy::ParseIsolatedOrigins(
+ "https://b.com,https://b.com,https://b.com:1234"),
+ testing::ElementsAre(url::Origin::Create(GURL("https://b.com")),
+ url::Origin::Create(GURL("https://b.com")),
+ url::Origin::Create(GURL("https://b.com:1234"))));
+}
+
+} // namespace content
diff --git a/chromium/content/public/browser/content_browser_client.cc b/chromium/content/public/browser/content_browser_client.cc
index 15a13c10c68..6a264c4692f 100644
--- a/chromium/content/public/browser/content_browser_client.cc
+++ b/chromium/content/public/browser/content_browser_client.cc
@@ -57,7 +57,8 @@ WebContentsViewDelegate* ContentBrowserClient::GetWebContentsViewDelegate(
}
GURL ContentBrowserClient::GetEffectiveURL(BrowserContext* browser_context,
- const GURL& url) {
+ const GURL& url,
+ bool is_isolated_origin) {
return url;
}
diff --git a/chromium/content/public/browser/content_browser_client.h b/chromium/content/public/browser/content_browser_client.h
index f3e94fe40a6..711fa80d0ea 100644
--- a/chromium/content/public/browser/content_browser_client.h
+++ b/chromium/content/public/browser/content_browser_client.h
@@ -210,8 +210,12 @@ class CONTENT_EXPORT ContentBrowserClient {
// Get the effective URL for the given actual URL, to allow an embedder to
// group different url schemes in the same SiteInstance.
+ // |is_isolated_origin| specifies whether |url| corresponds to an origin that
+ // requires process isolation. Certain kinds of effective URLs should be
+ // ignored for such origins.
virtual GURL GetEffectiveURL(BrowserContext* browser_context,
- const GURL& url);
+ const GURL& url,
+ bool is_isolated_origin);
// Returns whether all instances of the specified effective URL should be
// rendered by the same process, rather than using process-per-site-instance.
diff --git a/chromium/content/public/common/content_features.cc b/chromium/content/public/common/content_features.cc
index 66234129de4..2b88e0c7a99 100644
--- a/chromium/content/public/common/content_features.cc
+++ b/chromium/content/public/common/content_features.cc
@@ -413,6 +413,13 @@ const base::Feature kWebUsb{"WebUSB", base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kImageCaptureAPI{"ImageCaptureAPI",
base::FEATURE_ENABLED_BY_DEFAULT};
+// Alternative to switches::kIsolateOrigins, for turning on origin isolation.
+// List of origins to isolate has to be specified via
+// kIsolateOriginsFieldTrialParamName.
+const base::Feature kIsolateOrigins{"IsolateOrigins",
+ base::FEATURE_DISABLED_BY_DEFAULT};
+const char kIsolateOriginsFieldTrialParamName[] = "OriginsList";
+
const base::Feature kKeepAliveRendererForKeepaliveRequests{
"KeepAliveRendererForKeepaliveRequests", base::FEATURE_ENABLED_BY_DEFAULT};
diff --git a/chromium/content/public/common/content_features.h b/chromium/content/public/common/content_features.h
index 3e1ebf8f7a7..470b6607c3a 100644
--- a/chromium/content/public/common/content_features.h
+++ b/chromium/content/public/common/content_features.h
@@ -42,6 +42,8 @@ CONTENT_EXPORT extern const base::Feature kGamepadExtensions;
CONTENT_EXPORT extern const base::Feature kGuestViewCrossProcessFrames;
CONTENT_EXPORT extern const base::Feature kHeapCompaction;
CONTENT_EXPORT extern const base::Feature kImageCaptureAPI;
+CONTENT_EXPORT extern const base::Feature kIsolateOrigins;
+CONTENT_EXPORT extern const char kIsolateOriginsFieldTrialParamName[];
CONTENT_EXPORT extern const base::Feature
kKeepAliveRendererForKeepaliveRequests;
CONTENT_EXPORT extern const base::Feature kLazyInitializeMediaControls;
diff --git a/chromium/content/test/BUILD.gn b/chromium/content/test/BUILD.gn
index 9cebf576e4a..2b12a2416aa 100644
--- a/chromium/content/test/BUILD.gn
+++ b/chromium/content/test/BUILD.gn
@@ -1501,6 +1501,7 @@ test("content_unittests") {
"../common/sandbox_mac_unittest_helper.mm",
"../common/service_manager/service_manager_connection_impl_unittest.cc",
"../common/service_worker/service_worker_utils_unittest.cc",
+ "../common/site_isolation_policy_unittest.cc",
"../common/throttling_url_loader_unittest.cc",
"../common/unique_name_helper_unittest.cc",
"../common/webplugininfo_unittest.cc",