| 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/testing_profile.h" | 8 #include "chrome/test/testing_profile.h" |
| 9 #include "content/browser/browser_thread.h" | 9 #include "content/browser/browser_thread.h" |
| 10 #include "content/browser/browsing_instance.h" | 10 #include "content/browser/browsing_instance.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "content/common/content_constants.h" | 21 #include "content/common/content_constants.h" |
| 22 #include "content/common/url_constants.h" | 22 #include "content/common/url_constants.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 const char kSameAsAnyInstanceURL[] = "about:internets"; | 27 const char kSameAsAnyInstanceURL[] = "about:internets"; |
| 28 | 28 |
| 29 class SiteInstanceTestWebUIFactory : public content::EmptyWebUIFactory { | 29 class SiteInstanceTestWebUIFactory : public content::EmptyWebUIFactory { |
| 30 public: | 30 public: |
| 31 virtual bool UseWebUIForURL(Profile* profile, const GURL& url) const { | 31 virtual bool UseWebUIForURL(content::BrowserContext* context, |
| 32 const GURL& url) const OVERRIDE { |
| 32 return HasWebUIScheme(url); | 33 return HasWebUIScheme(url); |
| 33 } | 34 } |
| 34 virtual bool HasWebUIScheme(const GURL& url) const { | 35 virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE { |
| 35 return url.SchemeIs(chrome::kChromeUIScheme); | 36 return url.SchemeIs(chrome::kChromeUIScheme); |
| 36 } | 37 } |
| 37 }; | 38 }; |
| 38 | 39 |
| 39 class SiteInstanceTestBrowserClient : public content::MockContentBrowserClient { | 40 class SiteInstanceTestBrowserClient : public content::MockContentBrowserClient { |
| 40 public: | 41 public: |
| 41 virtual content::WebUIFactory* GetWebUIFactory() OVERRIDE { | 42 virtual content::WebUIFactory* GetWebUIFactory() OVERRIDE { |
| 42 return &factory_; | 43 return &factory_; |
| 43 } | 44 } |
| 44 | 45 |
| 45 virtual bool ShouldUseProcessPerSite(Profile* profile, | 46 virtual bool ShouldUseProcessPerSite(content::BrowserContext* context, |
| 46 const GURL& effective_url) OVERRIDE { | 47 const GURL& effective_url) OVERRIDE { |
| 47 return false; | 48 return false; |
| 48 } | 49 } |
| 49 | 50 |
| 50 virtual bool IsURLSameAsAnySiteInstance(const GURL& url) OVERRIDE { | 51 virtual bool IsURLSameAsAnySiteInstance(const GURL& url) OVERRIDE { |
| 51 return url == GURL(kSameAsAnyInstanceURL) || | 52 return url == GURL(kSameAsAnyInstanceURL) || |
| 52 url == GURL(chrome::kAboutCrashURL); | 53 url == GURL(chrome::kAboutCrashURL); |
| 53 } | 54 } |
| 54 | 55 |
| 55 virtual GURL GetEffectiveURL(Profile* profile, const GURL& url) OVERRIDE { | 56 virtual GURL GetEffectiveURL(content::BrowserContext* context, |
| 57 const GURL& url) OVERRIDE { |
| 56 return url; | 58 return url; |
| 57 } | 59 } |
| 58 | 60 |
| 59 private: | 61 private: |
| 60 SiteInstanceTestWebUIFactory factory_; | 62 SiteInstanceTestWebUIFactory factory_; |
| 61 }; | 63 }; |
| 62 | 64 |
| 63 class SiteInstanceTest : public testing::Test { | 65 class SiteInstanceTest : public testing::Test { |
| 64 public: | 66 public: |
| 65 SiteInstanceTest() | 67 SiteInstanceTest() |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 // Make sure none of differing privilege processes are mixed. | 513 // Make sure none of differing privilege processes are mixed. |
| 512 EXPECT_NE(extension1_instance->GetProcess(), webui1_instance->GetProcess()); | 514 EXPECT_NE(extension1_instance->GetProcess(), webui1_instance->GetProcess()); |
| 513 | 515 |
| 514 for (size_t i = 0; i < content::kMaxRendererProcessCount; ++i) { | 516 for (size_t i = 0; i < content::kMaxRendererProcessCount; ++i) { |
| 515 EXPECT_NE(extension1_instance->GetProcess(), hosts[i]); | 517 EXPECT_NE(extension1_instance->GetProcess(), hosts[i]); |
| 516 EXPECT_NE(webui1_instance->GetProcess(), hosts[i]); | 518 EXPECT_NE(webui1_instance->GetProcess(), hosts[i]); |
| 517 } | 519 } |
| 518 | 520 |
| 519 STLDeleteContainerPointers(hosts.begin(), hosts.end()); | 521 STLDeleteContainerPointers(hosts.begin(), hosts.end()); |
| 520 } | 522 } |
| OLD | NEW |