Chromium Code Reviews| 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 <string> | |
| 6 #include <vector> | |
| 7 | |
| 5 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 6 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 7 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 8 #include "base/string16.h" | 11 #include "base/string16.h" |
| 9 #include "content/browser/browser_thread_impl.h" | 12 #include "content/browser/browser_thread_impl.h" |
| 10 #include "content/browser/browsing_instance.h" | 13 #include "content/browser/browsing_instance.h" |
| 11 #include "content/browser/child_process_security_policy_impl.h" | 14 #include "content/browser/child_process_security_policy_impl.h" |
| 12 #include "content/browser/renderer_host/render_process_host_impl.h" | 15 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 13 #include "content/browser/renderer_host/render_view_host_impl.h" | 16 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 14 #include "content/browser/renderer_host/test_render_view_host.h" | 17 #include "content/browser/renderer_host/test_render_view_host.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 class SiteInstanceTestClient : public TestContentClient { | 78 class SiteInstanceTestClient : public TestContentClient { |
| 76 public: | 79 public: |
| 77 SiteInstanceTestClient() { | 80 SiteInstanceTestClient() { |
| 78 } | 81 } |
| 79 | 82 |
| 80 virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE { | 83 virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE { |
| 81 return url.SchemeIs(chrome::kChromeUIScheme); | 84 return url.SchemeIs(chrome::kChromeUIScheme); |
| 82 } | 85 } |
| 83 }; | 86 }; |
| 84 | 87 |
| 85 class SiteInstanceTestBrowserClient : | 88 class SiteInstanceTestBrowserClient : public content::TestContentBrowserClient { |
| 86 public content::TestContentBrowserClient { | |
| 87 public: | 89 public: |
| 88 SiteInstanceTestBrowserClient() | 90 SiteInstanceTestBrowserClient() |
| 89 : privileged_process_id_(-1) { | 91 : privileged_process_id_(-1) { |
| 90 } | 92 } |
| 91 | 93 |
| 92 virtual content::WebUIControllerFactory* | 94 virtual content::WebUIControllerFactory* |
| 93 GetWebUIControllerFactory() OVERRIDE { | 95 GetWebUIControllerFactory() OVERRIDE { |
| 94 return &factory_; | 96 return &factory_; |
| 95 } | 97 } |
| 96 | 98 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 url_util::AddStandardScheme(kPrivilegedScheme); | 130 url_util::AddStandardScheme(kPrivilegedScheme); |
| 129 url_util::AddStandardScheme(chrome::kChromeUIScheme); | 131 url_util::AddStandardScheme(chrome::kChromeUIScheme); |
| 130 } | 132 } |
| 131 | 133 |
| 132 virtual void TearDown() { | 134 virtual void TearDown() { |
| 133 // Ensure that no RenderProcessHosts are left over after the tests. | 135 // Ensure that no RenderProcessHosts are left over after the tests. |
| 134 EXPECT_TRUE(content::RenderProcessHost::AllHostsIterator().IsAtEnd()); | 136 EXPECT_TRUE(content::RenderProcessHost::AllHostsIterator().IsAtEnd()); |
| 135 | 137 |
| 136 content::GetContentClient()->set_browser_for_testing(old_browser_client_); | 138 content::GetContentClient()->set_browser_for_testing(old_browser_client_); |
| 137 content::SetContentClient(old_client_); | 139 content::SetContentClient(old_client_); |
| 140 | |
| 141 DrainMessageLoops(); | |
|
awong
2012/09/05 21:30:09
This previously wasn't in TearDown() because the B
Lei Zhang
2012/09/06 00:29:43
I can tell you with this cl, there are no valgrind
| |
| 138 } | 142 } |
| 139 | 143 |
| 140 void set_privileged_process_id(int process_id) { | 144 void set_privileged_process_id(int process_id) { |
| 141 browser_client_.set_privileged_process_id(process_id); | 145 browser_client_.set_privileged_process_id(process_id); |
| 142 } | 146 } |
| 143 | 147 |
| 144 void DrainMessageLoops() { | 148 void DrainMessageLoops() { |
| 145 // We don't just do this in TearDown() because we create TestBrowserContext | 149 // We don't just do this in TearDown() because we create TestBrowserContext |
| 146 // objects in each test, which will be destructed before | 150 // objects in each test, which will be destructed before |
| 147 // TearDown() is called. | 151 // TearDown() is called. |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 668 EXPECT_TRUE(instance->HasProcess()); | 672 EXPECT_TRUE(instance->HasProcess()); |
| 669 | 673 |
| 670 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://evernote.com"))); | 674 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://evernote.com"))); |
| 671 EXPECT_FALSE(instance->HasWrongProcessForURL( | 675 EXPECT_FALSE(instance->HasWrongProcessForURL( |
| 672 GURL("javascript:alert(document.location.href);"))); | 676 GURL("javascript:alert(document.location.href);"))); |
| 673 | 677 |
| 674 EXPECT_TRUE(instance->HasWrongProcessForURL(GURL("chrome://settings"))); | 678 EXPECT_TRUE(instance->HasWrongProcessForURL(GURL("chrome://settings"))); |
| 675 | 679 |
| 676 DrainMessageLoops(); | 680 DrainMessageLoops(); |
| 677 } | 681 } |
| OLD | NEW |