| 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 "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
| 6 #include "base/stl_util.h" | 6 #include "base/stl_util.h" |
| 7 #include "base/string16.h" | 7 #include "base/string16.h" |
| 8 #include "content/browser/browser_thread_impl.h" | 8 #include "content/browser/browser_thread_impl.h" |
| 9 #include "content/browser/browsing_instance.h" | 9 #include "content/browser/browsing_instance.h" |
| 10 #include "content/browser/child_process_security_policy.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
| 11 #include "content/browser/mock_content_browser_client.h" | 11 #include "content/browser/mock_content_browser_client.h" |
| 12 #include "content/browser/renderer_host/render_process_host_impl.h" | 12 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 13 #include "content/browser/renderer_host/render_view_host.h" | 13 #include "content/browser/renderer_host/render_view_host.h" |
| 14 #include "content/browser/renderer_host/test_render_view_host.h" | 14 #include "content/browser/renderer_host/test_render_view_host.h" |
| 15 #include "content/browser/site_instance_impl.h" | 15 #include "content/browser/site_instance_impl.h" |
| 16 #include "content/browser/tab_contents/navigation_entry_impl.h" | 16 #include "content/browser/tab_contents/navigation_entry_impl.h" |
| 17 #include "content/browser/tab_contents/tab_contents.h" | 17 #include "content/browser/tab_contents/tab_contents.h" |
| 18 #include "content/public/browser/web_ui_controller_factory.h" | 18 #include "content/public/browser/web_ui_controller_factory.h" |
| 19 #include "content/public/common/content_client.h" | 19 #include "content/public/common/content_client.h" |
| 20 #include "content/public/common/content_constants.h" | 20 #include "content/public/common/content_constants.h" |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 reinterpret_cast<SiteInstanceImpl*>( | 533 reinterpret_cast<SiteInstanceImpl*>( |
| 534 SiteInstance::CreateForURL(NULL, url)); | 534 SiteInstance::CreateForURL(NULL, url)); |
| 535 instance->set_render_process_host_factory(factory); | 535 instance->set_render_process_host_factory(factory); |
| 536 return instance; | 536 return instance; |
| 537 } | 537 } |
| 538 | 538 |
| 539 // Test to ensure that pages that require certain privileges are grouped | 539 // Test to ensure that pages that require certain privileges are grouped |
| 540 // in processes with similar pages. | 540 // in processes with similar pages. |
| 541 TEST_F(SiteInstanceTest, ProcessSharingByType) { | 541 TEST_F(SiteInstanceTest, ProcessSharingByType) { |
| 542 MockRenderProcessHostFactory rph_factory; | 542 MockRenderProcessHostFactory rph_factory; |
| 543 ChildProcessSecurityPolicy* policy = | 543 ChildProcessSecurityPolicyImpl* policy = |
| 544 ChildProcessSecurityPolicy::GetInstance(); | 544 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 545 | 545 |
| 546 // Make a bunch of mock renderers so that we hit the limit. | 546 // Make a bunch of mock renderers so that we hit the limit. |
| 547 std::vector<MockRenderProcessHost*> hosts; | 547 std::vector<MockRenderProcessHost*> hosts; |
| 548 for (size_t i = 0; i < content::kMaxRendererProcessCount; ++i) | 548 for (size_t i = 0; i < content::kMaxRendererProcessCount; ++i) |
| 549 hosts.push_back(new MockRenderProcessHost(NULL)); | 549 hosts.push_back(new MockRenderProcessHost(NULL)); |
| 550 | 550 |
| 551 // Create some extension instances and make sure they share a process. | 551 // Create some extension instances and make sure they share a process. |
| 552 scoped_refptr<SiteInstanceImpl> extension1_instance( | 552 scoped_refptr<SiteInstanceImpl> extension1_instance( |
| 553 CreateSiteInstance(&rph_factory, | 553 CreateSiteInstance(&rph_factory, |
| 554 GURL(kPrivilegedScheme + std::string("://foo/bar")))); | 554 GURL(kPrivilegedScheme + std::string("://foo/bar")))); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 host.reset(instance->GetProcess()); | 611 host.reset(instance->GetProcess()); |
| 612 EXPECT_TRUE(host.get() != NULL); | 612 EXPECT_TRUE(host.get() != NULL); |
| 613 EXPECT_TRUE(instance->HasProcess()); | 613 EXPECT_TRUE(instance->HasProcess()); |
| 614 | 614 |
| 615 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://evernote.com"))); | 615 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://evernote.com"))); |
| 616 EXPECT_FALSE(instance->HasWrongProcessForURL( | 616 EXPECT_FALSE(instance->HasWrongProcessForURL( |
| 617 GURL("javascript:alert(document.location.href);"))); | 617 GURL("javascript:alert(document.location.href);"))); |
| 618 | 618 |
| 619 EXPECT_TRUE(instance->HasWrongProcessForURL(GURL("chrome://settings"))); | 619 EXPECT_TRUE(instance->HasWrongProcessForURL(GURL("chrome://settings"))); |
| 620 } | 620 } |
| OLD | NEW |