Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: content/browser/site_instance_impl_unittest.cc

Issue 10479023: Simplify how Content*Client interfaces are created. Instead of depending on the embedder to know wh… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: remove unused function declaration Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_impl.h" 10 #include "content/browser/child_process_security_policy_impl.h"
11 #include "content/browser/mock_content_browser_client.h"
12 #include "content/browser/renderer_host/render_process_host_impl.h" 11 #include "content/browser/renderer_host/render_process_host_impl.h"
13 #include "content/browser/renderer_host/render_view_host_impl.h" 12 #include "content/browser/renderer_host/render_view_host_impl.h"
14 #include "content/browser/renderer_host/test_render_view_host.h" 13 #include "content/browser/renderer_host/test_render_view_host.h"
15 #include "content/browser/site_instance_impl.h" 14 #include "content/browser/site_instance_impl.h"
16 #include "content/browser/web_contents/navigation_entry_impl.h" 15 #include "content/browser/web_contents/navigation_entry_impl.h"
17 #include "content/browser/web_contents/web_contents_impl.h" 16 #include "content/browser/web_contents/web_contents_impl.h"
18 #include "content/public/browser/web_ui_controller_factory.h" 17 #include "content/public/browser/web_ui_controller_factory.h"
19 #include "content/public/common/content_client.h" 18 #include "content/public/common/content_client.h"
20 #include "content/public/common/content_constants.h" 19 #include "content/public/common/content_constants.h"
21 #include "content/public/common/url_constants.h" 20 #include "content/public/common/url_constants.h"
22 #include "content/public/test/mock_render_process_host.h" 21 #include "content/public/test/mock_render_process_host.h"
23 #include "content/public/test/test_browser_context.h" 22 #include "content/public/test/test_browser_context.h"
24 #include "content/public/test/test_browser_thread.h" 23 #include "content/public/test/test_browser_thread.h"
24 #include "content/test/test_content_browser_client.h"
25 #include "content/test/test_content_client.h" 25 #include "content/test/test_content_client.h"
26 #include "googleurl/src/url_util.h" 26 #include "googleurl/src/url_util.h"
27 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
28 28
29 using content::BrowserContext; 29 using content::BrowserContext;
30 using content::BrowserThread; 30 using content::BrowserThread;
31 using content::BrowserThreadImpl; 31 using content::BrowserThreadImpl;
32 using content::MockRenderProcessHost; 32 using content::MockRenderProcessHost;
33 using content::MockRenderProcessHostFactory; 33 using content::MockRenderProcessHostFactory;
34 using content::NavigationEntry; 34 using content::NavigationEntry;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 public: 74 public:
75 SiteInstanceTestClient() { 75 SiteInstanceTestClient() {
76 } 76 }
77 77
78 virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE { 78 virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE {
79 return url.SchemeIs(chrome::kChromeUIScheme); 79 return url.SchemeIs(chrome::kChromeUIScheme);
80 } 80 }
81 }; 81 };
82 82
83 class SiteInstanceTestBrowserClient : 83 class SiteInstanceTestBrowserClient :
84 public content::MockContentBrowserClient { 84 public content::TestContentBrowserClient {
85 public: 85 public:
86 SiteInstanceTestBrowserClient() 86 SiteInstanceTestBrowserClient()
87 : privileged_process_id_(-1) { 87 : privileged_process_id_(-1) {
88 } 88 }
89 89
90 virtual content::WebUIControllerFactory* 90 virtual content::WebUIControllerFactory*
91 GetWebUIControllerFactory() OVERRIDE { 91 GetWebUIControllerFactory() OVERRIDE {
92 return &factory_; 92 return &factory_;
93 } 93 }
94 94
(...skipping 25 matching lines...) Expand all
120 &message_loop_), 120 &message_loop_),
121 io_thread_(content::BrowserThread::IO, &message_loop_), 121 io_thread_(content::BrowserThread::IO, &message_loop_),
122 old_client_(NULL), 122 old_client_(NULL),
123 old_browser_client_(NULL) { 123 old_browser_client_(NULL) {
124 } 124 }
125 125
126 virtual void SetUp() { 126 virtual void SetUp() {
127 old_client_ = content::GetContentClient(); 127 old_client_ = content::GetContentClient();
128 old_browser_client_ = content::GetContentClient()->browser(); 128 old_browser_client_ = content::GetContentClient()->browser();
129 content::SetContentClient(&client_); 129 content::SetContentClient(&client_);
130 content::GetContentClient()->set_browser(&browser_client_); 130 content::GetContentClient()->set_browser_for_testing(&browser_client_);
131 url_util::AddStandardScheme(kPrivilegedScheme); 131 url_util::AddStandardScheme(kPrivilegedScheme);
132 url_util::AddStandardScheme(chrome::kChromeUIScheme); 132 url_util::AddStandardScheme(chrome::kChromeUIScheme);
133 } 133 }
134 134
135 virtual void TearDown() { 135 virtual void TearDown() {
136 content::GetContentClient()->set_browser(old_browser_client_); 136 content::GetContentClient()->set_browser_for_testing(old_browser_client_);
137 content::SetContentClient(old_client_); 137 content::SetContentClient(old_client_);
138 MessageLoop::current()->RunAllPending(); 138 MessageLoop::current()->RunAllPending();
139 message_loop_.RunAllPending(); 139 message_loop_.RunAllPending();
140 } 140 }
141 141
142 void set_privileged_process_id(int process_id) { 142 void set_privileged_process_id(int process_id) {
143 browser_client_.set_privileged_process_id(process_id); 143 browser_client_.set_privileged_process_id(process_id);
144 } 144 }
145 145
146 private: 146 private:
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 host.reset(instance->GetProcess()); 629 host.reset(instance->GetProcess());
630 EXPECT_TRUE(host.get() != NULL); 630 EXPECT_TRUE(host.get() != NULL);
631 EXPECT_TRUE(instance->HasProcess()); 631 EXPECT_TRUE(instance->HasProcess());
632 632
633 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://evernote.com"))); 633 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://evernote.com")));
634 EXPECT_FALSE(instance->HasWrongProcessForURL( 634 EXPECT_FALSE(instance->HasWrongProcessForURL(
635 GURL("javascript:alert(document.location.href);"))); 635 GURL("javascript:alert(document.location.href);")));
636 636
637 EXPECT_TRUE(instance->HasWrongProcessForURL(GURL("chrome://settings"))); 637 EXPECT_TRUE(instance->HasWrongProcessForURL(GURL("chrome://settings")));
638 } 638 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698