diff options
18 files changed, 47 insertions, 27 deletions
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 12a1d6b..7c33213 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -171,6 +171,12 @@ GURL ChromeContentBrowserClient::GetEffectiveURL(Profile* profile, return extension->GetResourceURL(url.path()); } +bool ChromeContentBrowserClient::IsURLSameAsAnySiteInstance(const GURL& url) { + return url.spec() == chrome::kAboutKillURL || + url.spec() == chrome::kAboutHangURL || + url.spec() == chrome::kAboutShorthangURL; +} + GURL ChromeContentBrowserClient::GetAlternateErrorPageURL( const TabContents* tab) { GURL url; diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h index 3a96dc2..cf203ef5 100644 --- a/chrome/browser/chrome_content_browser_client.h +++ b/chrome/browser/chrome_content_browser_client.h @@ -18,6 +18,7 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient { virtual void WorkerProcessHostCreated(WorkerProcessHost* host); virtual content::WebUIFactory* GetWebUIFactory(); virtual GURL GetEffectiveURL(Profile* profile, const GURL& url); + virtual bool IsURLSameAsAnySiteInstance(const GURL& url); virtual GURL GetAlternateErrorPageURL(const TabContents* tab); virtual std::string GetCanonicalEncodingNameByAliasName( const std::string& alias_name); diff --git a/content/browser/DEPS b/content/browser/DEPS index ab77254..11ecfed 100644 --- a/content/browser/DEPS +++ b/content/browser/DEPS @@ -101,7 +101,6 @@ include_rules = [ "+chrome/common/chrome_paths.h",
"+chrome/common/logging_chrome.h",
"+chrome/common/render_messages.h",
- "+chrome/common/url_constants.h",
"+chrome/common/net/url_fetcher.h",
@@ -121,4 +120,5 @@ include_rules = [ "+chrome/browser/ui/cocoa/find_pasteboard.h",
"+chrome/browser/ui/tab_contents/tab_contents_wrapper.h",
"+chrome/common/net/test_url_fetcher_factory.h",
+ "+chrome/common/url_constants.h",
]
diff --git a/content/browser/browsing_instance.cc b/content/browser/browsing_instance.cc index be55f5e..c440f4d 100644 --- a/content/browser/browsing_instance.cc +++ b/content/browser/browsing_instance.cc @@ -8,11 +8,11 @@ #include "base/logging.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/url_constants.h" #include "content/browser/content_browser_client.h" #include "content/browser/site_instance.h" #include "content/browser/webui/web_ui_factory.h" #include "content/common/content_client.h" +#include "content/common/url_constants.h" // static BrowsingInstance::ProfileSiteInstanceMap diff --git a/content/browser/child_process_security_policy.cc b/content/browser/child_process_security_policy.cc index eac07c4..61c2c46 100644 --- a/content/browser/child_process_security_policy.cc +++ b/content/browser/child_process_security_policy.cc @@ -9,8 +9,8 @@ #include "base/platform_file.h" #include "base/stl_util-inl.h" #include "base/string_util.h" -#include "chrome/common/url_constants.h" #include "content/common/bindings_policy.h" +#include "content/common/url_constants.h" #include "googleurl/src/gurl.h" #include "net/url_request/url_request.h" diff --git a/content/browser/content_browser_client.cc b/content/browser/content_browser_client.cc index 47d55e4..782988a 100644 --- a/content/browser/content_browser_client.cc +++ b/content/browser/content_browser_client.cc @@ -33,6 +33,10 @@ GURL ContentBrowserClient::GetEffectiveURL(Profile* profile, const GURL& url) { return url; } +bool ContentBrowserClient::IsURLSameAsAnySiteInstance(const GURL& url) { + return false; +} + GURL ContentBrowserClient::GetAlternateErrorPageURL(const TabContents* tab) { return GURL(); } diff --git a/content/browser/content_browser_client.h b/content/browser/content_browser_client.h index 70932b6..83e9c19 100644 --- a/content/browser/content_browser_client.h +++ b/content/browser/content_browser_client.h @@ -57,6 +57,10 @@ class ContentBrowserClient { // group different url schemes in the same SiteInstance. virtual GURL GetEffectiveURL(Profile* profile, const GURL& url); + // Returns whether a specified URL is to be considered the same as any + // SiteInstance. + virtual bool IsURLSameAsAnySiteInstance(const GURL& url); + // See RenderViewHostDelegate's comment. virtual GURL GetAlternateErrorPageURL(const TabContents* tab); diff --git a/content/browser/renderer_host/buffered_resource_handler.cc b/content/browser/renderer_host/buffered_resource_handler.cc index 06b78e5..64c8c6a 100644 --- a/content/browser/renderer_host/buffered_resource_handler.cc +++ b/content/browser/renderer_host/buffered_resource_handler.cc @@ -11,7 +11,6 @@ #include "base/string_util.h" #include "chrome/browser/renderer_host/download_throttling_resource_handler.h" #include "chrome/common/extensions/user_script.h" -#include "chrome/common/url_constants.h" #include "content/browser/browser_thread.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc index 361d0e9..e94b6a1 100644 --- a/content/browser/renderer_host/render_message_filter.cc +++ b/content/browser/renderer_host/render_message_filter.cc @@ -25,7 +25,6 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/render_messages.h" -#include "chrome/common/url_constants.h" #include "content/browser/browser_thread.h" #include "content/browser/child_process_security_policy.h" #include "content/browser/content_browser_client.h" @@ -40,6 +39,7 @@ #include "content/browser/user_metrics.h" #include "content/common/desktop_notification_messages.h" #include "content/common/notification_service.h" +#include "content/common/url_constants.h" #include "content/common/view_messages.h" #include "ipc/ipc_channel_handle.h" #include "net/base/cookie_monster.h" diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc index b5b5a89..8fdc0c3 100644 --- a/content/browser/renderer_host/resource_dispatcher_host.cc +++ b/content/browser/renderer_host/resource_dispatcher_host.cc @@ -35,7 +35,6 @@ #include "chrome/browser/ssl/ssl_manager.h" #include "chrome/browser/ui/login/login_prompt.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/url_constants.h" #include "content/browser/appcache/chrome_appcache_service.h" #include "content/browser/cert_store.h" #include "content/browser/child_process_security_policy.h" @@ -61,6 +60,7 @@ #include "content/browser/worker_host/worker_service.h" #include "content/common/notification_service.h" #include "content/common/resource_messages.h" +#include "content/common/url_constants.h" #include "content/common/view_messages.h" #include "net/base/auth.h" #include "net/base/cert_status_flags.h" diff --git a/content/browser/renderer_host/x509_user_cert_resource_handler.cc b/content/browser/renderer_host/x509_user_cert_resource_handler.cc index 188538d..4bd7721 100644 --- a/content/browser/renderer_host/x509_user_cert_resource_handler.cc +++ b/content/browser/renderer_host/x509_user_cert_resource_handler.cc @@ -7,7 +7,6 @@ #include "base/string_util.h" #include "chrome/browser/download/download_types.h" #include "chrome/browser/ssl/ssl_add_cert_handler.h" -#include "chrome/common/url_constants.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" #include "content/common/resource_response.h" diff --git a/content/browser/site_instance.cc b/content/browser/site_instance.cc index ed8cd9b..f96e3b2 100644 --- a/content/browser/site_instance.cc +++ b/content/browser/site_instance.cc @@ -4,25 +4,28 @@ #include "content/browser/site_instance.h" -#include "chrome/common/url_constants.h" #include "content/browser/browsing_instance.h" #include "content/browser/content_browser_client.h" #include "content/browser/renderer_host/browser_render_process_host.h" #include "content/browser/webui/web_ui_factory.h" -#include "content/common/notification_service.h" #include "content/common/content_client.h" +#include "content/common/notification_service.h" +#include "content/common/url_constants.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::kAboutKillURL || - url.spec() == chrome::kAboutHangURL || - url.spec() == chrome::kAboutShorthangURL; + + // We treat javascript: and about:crash as the same site as any URL since they + // are actually modifiers on existing pages. + if (url.SchemeIs(chrome::kJavaScriptScheme) || + url.spec() == chrome::kAboutCrashURL) { + return true; + } + + return + content::GetContentClient()->browser()->IsURLSameAsAnySiteInstance(url); } int32 SiteInstance::next_site_instance_id_ = 1; diff --git a/content/browser/site_instance_unittest.cc b/content/browser/site_instance_unittest.cc index b2cb51ca..25b9f6a 100644 --- a/content/browser/site_instance_unittest.cc +++ b/content/browser/site_instance_unittest.cc @@ -6,7 +6,6 @@ #include "base/string16.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/render_messages.h" -#include "chrome/common/url_constants.h" #include "chrome/test/testing_profile.h" #include "content/browser/browser_thread.h" #include "content/browser/browsing_instance.h" @@ -20,6 +19,7 @@ #include "content/browser/tab_contents/tab_contents.h" #include "content/browser/webui/empty_web_ui_factory.h" #include "content/common/content_client.h" +#include "content/common/url_constants.h" #include "testing/gtest/include/gtest/gtest.h" namespace { @@ -28,6 +28,7 @@ namespace { // doesn't think that the webui URLs have a host). Figure out where this is // coming from and fix it. const char kWebUIScheme[] = "chrome"; +const char kSameAsAnyInstanceURL[] = "about:internets"; class SiteInstanceTestWebUIFactory : public content::EmptyWebUIFactory { public: @@ -45,6 +46,10 @@ class SiteInstanceTestBrowserClient : public content::ContentBrowserClient { return &factory_; } + virtual bool IsURLSameAsAnySiteInstance(const GURL& url) { + return url.spec() == kSameAsAnyInstanceURL; + } + private: SiteInstanceTestWebUIFactory factory_; }; @@ -300,8 +305,7 @@ TEST_F(SiteInstanceTest, IsSameWebSite) { GURL url_foo_port = GURL("http://foo:8080/a.html"); GURL url_javascript = GURL("javascript:alert(1);"); GURL url_crash = GURL(chrome::kAboutCrashURL); - GURL url_hang = GURL(chrome::kAboutHangURL); - GURL url_shorthang = GURL(chrome::kAboutShorthangURL); + GURL url_browser_specified = GURL(kSameAsAnyInstanceURL); // Same scheme and port -> same site. EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_foo, url_foo2)); @@ -318,10 +322,11 @@ TEST_F(SiteInstanceTest, IsSameWebSite) { EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_javascript, url_foo_https)); EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_javascript, url_foo_port)); - // The crash/hang URLs should also be treated as same site. (Bug 1143809.) + // The URLs specified by the ContentBrowserClient should also be treated as + // same site. EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_crash, url_foo)); - EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_hang, url_foo)); - EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_shorthang, url_foo)); + EXPECT_TRUE( + SiteInstance::IsSameWebSite(NULL, url_browser_specified, url_foo)); } // Test to ensure that there is only one SiteInstance per site in a given diff --git a/content/browser/tab_contents/navigation_controller.cc b/content/browser/tab_contents/navigation_controller.cc index 457431d..1d3e1db 100644 --- a/content/browser/tab_contents/navigation_controller.cc +++ b/content/browser/tab_contents/navigation_controller.cc @@ -14,7 +14,6 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sessions/session_types.h" #include "chrome/common/chrome_constants.h" -#include "chrome/common/url_constants.h" #include "content/browser/child_process_security_policy.h" #include "content/browser/in_process_webkit/session_storage_namespace.h" #include "content/browser/site_instance.h" diff --git a/content/browser/tab_contents/navigation_entry.cc b/content/browser/tab_contents/navigation_entry.cc index fc4ad74..c8c81f4 100644 --- a/content/browser/tab_contents/navigation_entry.cc +++ b/content/browser/tab_contents/navigation_entry.cc @@ -8,9 +8,9 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_constants.h" -#include "chrome/common/url_constants.h" #include "content/browser/site_instance.h" #include "content/common/content_constants.h" +#include "content/common/url_constants.h" #include "grit/app_resources.h" #include "net/base/net_util.h" #include "ui/base/resource/resource_bundle.h" diff --git a/content/browser/tab_contents/render_view_host_manager.cc b/content/browser/tab_contents/render_view_host_manager.cc index 8a364a0..0226385 100644 --- a/content/browser/tab_contents/render_view_host_manager.cc +++ b/content/browser/tab_contents/render_view_host_manager.cc @@ -9,7 +9,6 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/render_messages.h" -#include "chrome/common/url_constants.h" #include "content/browser/content_browser_client.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_view_host_delegate.h" @@ -24,6 +23,7 @@ #include "content/common/content_client.h" #include "content/common/notification_service.h" #include "content/common/notification_type.h" +#include "content/common/url_constants.h" #include "content/common/view_messages.h" namespace base { diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index c4e571b..1d2c347 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -32,7 +32,6 @@ #include "chrome/common/chrome_constants.h" #include "chrome/common/pref_names.h" #include "chrome/common/render_messages.h" -#include "chrome/common/url_constants.h" #include "content/browser/child_process_security_policy.h" #include "content/browser/content_browser_client.h" #include "content/browser/host_zoom_map.h" @@ -55,6 +54,7 @@ #include "content/common/content_restriction.h" #include "content/common/navigation_types.h" #include "content/common/notification_service.h" +#include "content/common/url_constants.h" #include "content/common/view_messages.h" #include "net/base/net_util.h" #include "net/base/registry_controlled_domain.h" diff --git a/content/browser/tab_contents/tab_contents_delegate.cc b/content/browser/tab_contents/tab_contents_delegate.cc index 4d699ba..571b57e 100644 --- a/content/browser/tab_contents/tab_contents_delegate.cc +++ b/content/browser/tab_contents/tab_contents_delegate.cc @@ -4,7 +4,7 @@ #include "content/browser/tab_contents/tab_contents_delegate.h" -#include "chrome/common/url_constants.h" +#include "content/common/url_constants.h" #include "ui/gfx/rect.h" std::string TabContentsDelegate::GetNavigationHeaders(const GURL& url) { |