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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "content/browser/browser_thread_impl.h" | 9 #include "content/browser/browser_thread_impl.h" |
10 #include "content/browser/browsing_instance.h" | 10 #include "content/browser/browsing_instance.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "url/url_util.h" | 30 #include "url/url_util.h" |
31 | 31 |
32 namespace content { | 32 namespace content { |
33 namespace { | 33 namespace { |
34 | 34 |
35 const char kPrivilegedScheme[] = "privileged"; | 35 const char kPrivilegedScheme[] = "privileged"; |
36 | 36 |
37 class SiteInstanceTestWebUIControllerFactory : public WebUIControllerFactory { | 37 class SiteInstanceTestWebUIControllerFactory : public WebUIControllerFactory { |
38 public: | 38 public: |
39 virtual WebUIController* CreateWebUIControllerForURL( | 39 virtual WebUIController* CreateWebUIControllerForURL( |
40 WebUI* web_ui, const GURL& url) const OVERRIDE { | 40 WebUI* web_ui, const GURL& url) const override { |
41 return NULL; | 41 return NULL; |
42 } | 42 } |
43 virtual WebUI::TypeID GetWebUIType(BrowserContext* browser_context, | 43 virtual WebUI::TypeID GetWebUIType(BrowserContext* browser_context, |
44 const GURL& url) const OVERRIDE { | 44 const GURL& url) const override { |
45 return WebUI::kNoWebUI; | 45 return WebUI::kNoWebUI; |
46 } | 46 } |
47 virtual bool UseWebUIForURL(BrowserContext* browser_context, | 47 virtual bool UseWebUIForURL(BrowserContext* browser_context, |
48 const GURL& url) const OVERRIDE { | 48 const GURL& url) const override { |
49 return HasWebUIScheme(url); | 49 return HasWebUIScheme(url); |
50 } | 50 } |
51 virtual bool UseWebUIBindingsForURL(BrowserContext* browser_context, | 51 virtual bool UseWebUIBindingsForURL(BrowserContext* browser_context, |
52 const GURL& url) const OVERRIDE { | 52 const GURL& url) const override { |
53 return HasWebUIScheme(url); | 53 return HasWebUIScheme(url); |
54 } | 54 } |
55 }; | 55 }; |
56 | 56 |
57 class SiteInstanceTestBrowserClient : public TestContentBrowserClient { | 57 class SiteInstanceTestBrowserClient : public TestContentBrowserClient { |
58 public: | 58 public: |
59 SiteInstanceTestBrowserClient() | 59 SiteInstanceTestBrowserClient() |
60 : privileged_process_id_(-1) { | 60 : privileged_process_id_(-1) { |
61 WebUIControllerFactory::RegisterFactory(&factory_); | 61 WebUIControllerFactory::RegisterFactory(&factory_); |
62 } | 62 } |
63 | 63 |
64 virtual ~SiteInstanceTestBrowserClient() { | 64 virtual ~SiteInstanceTestBrowserClient() { |
65 WebUIControllerFactory::UnregisterFactoryForTesting(&factory_); | 65 WebUIControllerFactory::UnregisterFactoryForTesting(&factory_); |
66 } | 66 } |
67 | 67 |
68 virtual bool IsSuitableHost(RenderProcessHost* process_host, | 68 virtual bool IsSuitableHost(RenderProcessHost* process_host, |
69 const GURL& site_url) OVERRIDE { | 69 const GURL& site_url) override { |
70 return (privileged_process_id_ == process_host->GetID()) == | 70 return (privileged_process_id_ == process_host->GetID()) == |
71 site_url.SchemeIs(kPrivilegedScheme); | 71 site_url.SchemeIs(kPrivilegedScheme); |
72 } | 72 } |
73 | 73 |
74 void set_privileged_process_id(int process_id) { | 74 void set_privileged_process_id(int process_id) { |
75 privileged_process_id_ = process_id; | 75 privileged_process_id_ = process_id; |
76 } | 76 } |
77 | 77 |
78 private: | 78 private: |
79 SiteInstanceTestWebUIControllerFactory factory_; | 79 SiteInstanceTestWebUIControllerFactory factory_; |
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 EXPECT_TRUE(instance->GetSiteURL().is_empty()); | 780 EXPECT_TRUE(instance->GetSiteURL().is_empty()); |
781 host.reset(instance->GetProcess()); | 781 host.reset(instance->GetProcess()); |
782 | 782 |
783 EXPECT_FALSE(RenderProcessHostImpl::GetProcessHostForSite( | 783 EXPECT_FALSE(RenderProcessHostImpl::GetProcessHostForSite( |
784 browser_context.get(), GURL())); | 784 browser_context.get(), GURL())); |
785 | 785 |
786 DrainMessageLoops(); | 786 DrainMessageLoops(); |
787 } | 787 } |
788 | 788 |
789 } // namespace content | 789 } // namespace content |
OLD | NEW |