summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/tab_contents/site_instance.cc35
-rw-r--r--chrome/common/url_constants.cc3
-rw-r--r--chrome/common/url_constants.h5
3 files changed, 24 insertions, 19 deletions
diff --git a/chrome/browser/tab_contents/site_instance.cc b/chrome/browser/tab_contents/site_instance.cc
index 8ea7baf..a3e2f86 100644
--- a/chrome/browser/tab_contents/site_instance.cc
+++ b/chrome/browser/tab_contents/site_instance.cc
@@ -10,6 +10,17 @@
#include "chrome/common/notification_service.h"
#include "net/base/registry_controlled_domain.h"
+// We treat javascript:, about:crash, about:hang, and about:shorthang as the
+// same site as any URL since they are actually modifiers on existing pages.
+static bool IsURLSameAsAnySiteInstance(const GURL& url) {
+ if (!url.is_valid())
+ return false;
+ return url.SchemeIs(chrome::kJavaScriptScheme) ||
+ url.spec() == chrome::kAboutCrashURL ||
+ url.spec() == chrome::kAboutHangURL ||
+ url.spec() == chrome::kAboutShorthangURL;
+}
+
SiteInstance::SiteInstance(BrowsingInstance* browsing_instance)
: browsing_instance_(browsing_instance),
render_process_host_factory_(NULL),
@@ -138,31 +149,19 @@ bool SiteInstance::IsSameWebSite(const GURL& url1, const GURL& url2) {
// one is present, because pages served from different ports can still
// access each other if they change their document.domain variable.
- // We must treat javascript: URLs as part of the same site, regardless of
- // the site.
- if (url1.SchemeIs(chrome::kJavaScriptScheme) ||
- url2.SchemeIs(chrome::kJavaScriptScheme))
- return true;
-
- // We treat about:crash, about:hang, and about:shorthang as the same site as
- // any URL, since they are used as demos for crashing/hanging a process.
- GURL about_crash = GURL("about:crash");
- GURL about_hang = GURL("about:hang");
- GURL about_shorthang = GURL("about:shorthang");
- if (url1 == about_crash || url2 == about_crash ||
- url1 == about_hang || url2 == about_hang ||
- url1 == about_shorthang || url2 == about_shorthang)
+ // Some special URLs will match the site instance of any other URL. This is
+ // done before checking both of them for validity, since we want these URLs
+ // to have the same site instance as even an invalid one.
+ if (IsURLSameAsAnySiteInstance(url1) || IsURLSameAsAnySiteInstance(url2))
return true;
// If either URL is invalid, they aren't part of the same site.
- if (!url1.is_valid() || !url2.is_valid()) {
+ if (!url1.is_valid() || !url2.is_valid())
return false;
- }
// If the schemes differ, they aren't part of the same site.
- if (url1.scheme() != url2.scheme()) {
+ if (url1.scheme() != url2.scheme())
return false;
- }
return net::RegistryControlledDomainService::SameDomainOrHost(url1, url2);
}
diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc
index 0562124..1f47987 100644
--- a/chrome/common/url_constants.cc
+++ b/chrome/common/url_constants.cc
@@ -29,7 +29,10 @@ const char kStandardSchemeSeparator[] = "://";
const char kAboutBlankURL[] = "about:blank";
const char kAboutCacheURL[] = "about:cache";
+const char kAboutCrashURL[] = "about:crash";
+const char kAboutHangURL[] = "about:hang";
const char kAboutMemoryURL[] = "about:memory";
+const char kAboutShorthangURL[] = "about:shorthang";
// Use an obfuscated URL to make this nondiscoverable, we only want this
// to be used for testing.
diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h
index c058d85..69d6c54 100644
--- a/chrome/common/url_constants.h
+++ b/chrome/common/url_constants.h
@@ -31,9 +31,12 @@ extern const char kStandardSchemeSeparator[];
// About URLs (including schmes).
extern const char kAboutBlankURL[];
+extern const char kAboutBrowserCrash[];
extern const char kAboutCacheURL[];
+extern const char kAboutCrashURL[];
+extern const char kAboutHangURL[];
extern const char kAboutMemoryURL[];
-extern const char kAboutBrowserCrash[];
+extern const char kAboutShorthangURL[];
// chrome: URLs (including schemes). Should be kept in sync with the
// components below.