| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/site_instance_impl.h" | 5 #include "content/browser/site_instance_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "content/browser/browsing_instance.h" | 8 #include "content/browser/browsing_instance.h" |
| 9 #include "content/browser/child_process_security_policy.h" | 9 #include "content/browser/child_process_security_policy.h" |
| 10 #include "content/browser/renderer_host/render_process_host_impl.h" | 10 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 11 #include "content/public/browser/content_browser_client.h" | 11 #include "content/public/browser/content_browser_client.h" |
| 12 #include "content/public/browser/notification_service.h" | 12 #include "content/public/browser/notification_service.h" |
| 13 #include "content/public/browser/notification_types.h" | 13 #include "content/public/browser/notification_types.h" |
| 14 #include "content/public/browser/render_process_host_factory.h" | 14 #include "content/public/browser/render_process_host_factory.h" |
| 15 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
| 16 #include "content/public/common/url_constants.h" | 16 #include "content/public/common/url_constants.h" |
| 17 #include "net/base/registry_controlled_domain.h" | 17 #include "net/base/registry_controlled_domain.h" |
| 18 | 18 |
| 19 using content::SiteInstance; | 19 using content::SiteInstance; |
| 20 | 20 |
| 21 static bool IsURLSameAsAnySiteInstance(const GURL& url) { | 21 static bool IsURLSameAsAnySiteInstance(const GURL& url) { |
| 22 if (!url.is_valid()) | 22 if (!url.is_valid()) |
| 23 return false; | 23 return false; |
| 24 | 24 |
| 25 // We treat javascript: as the same site as any URL since it is actually | 25 // We treat javascript: as the same site as any URL since it is actually |
| 26 // a modifier on existing pages. | 26 // a modifier on existing pages. |
| 27 if (url.SchemeIs(chrome::kJavaScriptScheme)) | 27 if (url.SchemeIs(chrome::kJavaScriptScheme)) |
| 28 return true; | 28 return true; |
| 29 | 29 |
| 30 return | 30 return url == GURL(chrome::kChromeUICrashURL) || |
| 31 content::GetContentClient()->browser()->IsURLSameAsAnySiteInstance(url); | 31 url == GURL(chrome::kChromeUIKillURL) || |
| 32 url == GURL(chrome::kChromeUIHangURL) || |
| 33 url == GURL(chrome::kChromeUIShorthangURL); |
| 32 } | 34 } |
| 33 | 35 |
| 34 int32 SiteInstanceImpl::next_site_instance_id_ = 1; | 36 int32 SiteInstanceImpl::next_site_instance_id_ = 1; |
| 35 | 37 |
| 36 SiteInstanceImpl::SiteInstanceImpl(BrowsingInstance* browsing_instance) | 38 SiteInstanceImpl::SiteInstanceImpl(BrowsingInstance* browsing_instance) |
| 37 : id_(next_site_instance_id_++), | 39 : id_(next_site_instance_id_++), |
| 38 browsing_instance_(browsing_instance), | 40 browsing_instance_(browsing_instance), |
| 39 render_process_host_factory_(NULL), | 41 render_process_host_factory_(NULL), |
| 40 process_(NULL), | 42 process_(NULL), |
| 41 has_site_(false) { | 43 has_site_(false) { |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 | 262 |
| 261 void SiteInstanceImpl::LockToOrigin() { | 263 void SiteInstanceImpl::LockToOrigin() { |
| 262 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 264 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 263 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation)) { | 265 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation)) { |
| 264 ChildProcessSecurityPolicy* policy = | 266 ChildProcessSecurityPolicy* policy = |
| 265 ChildProcessSecurityPolicy::GetInstance(); | 267 ChildProcessSecurityPolicy::GetInstance(); |
| 266 policy->LockToOrigin(process_->GetID(), site_); | 268 policy->LockToOrigin(process_->GetID(), site_); |
| 267 } | 269 } |
| 268 } | 270 } |
| 269 | 271 |
| OLD | NEW |