| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/test/base/testing_browser_process_test.h" | 8 #include "chrome/test/base/testing_browser_process_test.h" |
| 9 #include "chrome/test/base/testing_profile.h" | 9 #include "chrome/test/base/testing_profile.h" |
| 10 #include "content/browser/browser_thread.h" | 10 #include "content/browser/browser_thread.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 const GURL& url) const OVERRIDE { | 33 const GURL& url) const OVERRIDE { |
| 34 return HasWebUIScheme(url); | 34 return HasWebUIScheme(url); |
| 35 } | 35 } |
| 36 virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE { | 36 virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE { |
| 37 return url.SchemeIs(chrome::kChromeUIScheme); | 37 return url.SchemeIs(chrome::kChromeUIScheme); |
| 38 } | 38 } |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 class SiteInstanceTestBrowserClient : public content::MockContentBrowserClient { | 41 class SiteInstanceTestBrowserClient : public content::MockContentBrowserClient { |
| 42 public: | 42 public: |
| 43 SiteInstanceTestBrowserClient() : old_browser_client_(NULL) { |
| 44 } |
| 45 |
| 46 virtual TabContentsView* CreateTabContentsView(TabContents* tab_contents) { |
| 47 return old_browser_client_->CreateTabContentsView(tab_contents); |
| 48 } |
| 49 |
| 43 virtual content::WebUIFactory* GetWebUIFactory() OVERRIDE { | 50 virtual content::WebUIFactory* GetWebUIFactory() OVERRIDE { |
| 44 return &factory_; | 51 return &factory_; |
| 45 } | 52 } |
| 46 | 53 |
| 47 virtual bool ShouldUseProcessPerSite(content::BrowserContext* browser_context, | 54 virtual bool ShouldUseProcessPerSite(content::BrowserContext* browser_context, |
| 48 const GURL& effective_url) OVERRIDE { | 55 const GURL& effective_url) OVERRIDE { |
| 49 return false; | 56 return false; |
| 50 } | 57 } |
| 51 | 58 |
| 52 virtual bool IsURLSameAsAnySiteInstance(const GURL& url) OVERRIDE { | 59 virtual bool IsURLSameAsAnySiteInstance(const GURL& url) OVERRIDE { |
| 53 return url == GURL(kSameAsAnyInstanceURL) || | 60 return url == GURL(kSameAsAnyInstanceURL) || |
| 54 url == GURL(chrome::kAboutCrashURL); | 61 url == GURL(chrome::kAboutCrashURL); |
| 55 } | 62 } |
| 56 | 63 |
| 57 virtual GURL GetEffectiveURL(content::BrowserContext* browser_context, | 64 virtual GURL GetEffectiveURL(content::BrowserContext* browser_context, |
| 58 const GURL& url) OVERRIDE { | 65 const GURL& url) OVERRIDE { |
| 59 return url; | 66 return url; |
| 60 } | 67 } |
| 61 | 68 |
| 69 void SetOriginalClient(content::ContentBrowserClient* old_browser_client) { |
| 70 old_browser_client_ = old_browser_client; |
| 71 } |
| 72 |
| 62 private: | 73 private: |
| 63 SiteInstanceTestWebUIFactory factory_; | 74 SiteInstanceTestWebUIFactory factory_; |
| 75 content::ContentBrowserClient* old_browser_client_; |
| 64 }; | 76 }; |
| 65 | 77 |
| 66 class SiteInstanceTest : public TestingBrowserProcessTest { | 78 class SiteInstanceTest : public TestingBrowserProcessTest { |
| 67 public: | 79 public: |
| 68 SiteInstanceTest() | 80 SiteInstanceTest() |
| 69 : ui_thread_(BrowserThread::UI, &message_loop_), | 81 : ui_thread_(BrowserThread::UI, &message_loop_), |
| 70 old_browser_client_(NULL) { | 82 old_browser_client_(NULL) { |
| 71 } | 83 } |
| 72 | 84 |
| 73 virtual void SetUp() { | 85 virtual void SetUp() { |
| 74 old_browser_client_ = content::GetContentClient()->browser(); | 86 old_browser_client_ = content::GetContentClient()->browser(); |
| 87 browser_client_.SetOriginalClient(old_browser_client_); |
| 75 content::GetContentClient()->set_browser(&browser_client_); | 88 content::GetContentClient()->set_browser(&browser_client_); |
| 76 } | 89 } |
| 77 | 90 |
| 78 virtual void TearDown() { | 91 virtual void TearDown() { |
| 79 content::GetContentClient()->set_browser(old_browser_client_); | 92 content::GetContentClient()->set_browser(old_browser_client_); |
| 80 } | 93 } |
| 81 | 94 |
| 82 private: | 95 private: |
| 83 MessageLoopForUI message_loop_; | 96 MessageLoopForUI message_loop_; |
| 84 BrowserThread ui_thread_; | 97 BrowserThread ui_thread_; |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 // Make sure none of differing privilege processes are mixed. | 527 // Make sure none of differing privilege processes are mixed. |
| 515 EXPECT_NE(extension1_instance->GetProcess(), webui1_instance->GetProcess()); | 528 EXPECT_NE(extension1_instance->GetProcess(), webui1_instance->GetProcess()); |
| 516 | 529 |
| 517 for (size_t i = 0; i < content::kMaxRendererProcessCount; ++i) { | 530 for (size_t i = 0; i < content::kMaxRendererProcessCount; ++i) { |
| 518 EXPECT_NE(extension1_instance->GetProcess(), hosts[i]); | 531 EXPECT_NE(extension1_instance->GetProcess(), hosts[i]); |
| 519 EXPECT_NE(webui1_instance->GetProcess(), hosts[i]); | 532 EXPECT_NE(webui1_instance->GetProcess(), hosts[i]); |
| 520 } | 533 } |
| 521 | 534 |
| 522 STLDeleteContainerPointers(hosts.begin(), hosts.end()); | 535 STLDeleteContainerPointers(hosts.begin(), hosts.end()); |
| 523 } | 536 } |
| OLD | NEW |