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 "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" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 public: | 112 public: |
| 113 SiteInstanceTest() | 113 SiteInstanceTest() |
| 114 : ui_thread_(BrowserThread::UI, &message_loop_), | 114 : ui_thread_(BrowserThread::UI, &message_loop_), |
| 115 old_client_(NULL), | 115 old_client_(NULL), |
| 116 old_browser_client_(NULL) { | 116 old_browser_client_(NULL) { |
| 117 } | 117 } |
| 118 | 118 |
| 119 virtual void SetUp() { | 119 virtual void SetUp() { |
| 120 old_client_ = content::GetContentClient(); | 120 old_client_ = content::GetContentClient(); |
| 121 old_browser_client_ = content::GetContentClient()->browser(); | 121 old_browser_client_ = content::GetContentClient()->browser(); |
| 122 content::SetContentClient(&client_); | 122 old_user_agent_ = content::GetUserAgent(GURL()); |
| 123 content::Initialize(&client_, "SiteInstanceTest"); | |
|
scherkus (not reviewing)
2012/04/05 23:20:45
is this ContentClient swapping necessary? :(
Dirk Pranke
2012/04/05 23:35:54
I don't know this code; looks like it was added in
| |
| 123 content::GetContentClient()->set_browser(&browser_client_); | 124 content::GetContentClient()->set_browser(&browser_client_); |
| 124 url_util::AddStandardScheme(kPrivilegedScheme); | 125 url_util::AddStandardScheme(kPrivilegedScheme); |
| 125 url_util::AddStandardScheme(chrome::kChromeUIScheme); | 126 url_util::AddStandardScheme(chrome::kChromeUIScheme); |
| 126 } | 127 } |
| 127 | 128 |
| 128 virtual void TearDown() { | 129 virtual void TearDown() { |
| 129 content::GetContentClient()->set_browser(old_browser_client_); | 130 content::GetContentClient()->set_browser(old_browser_client_); |
|
scherkus (not reviewing)
2012/04/05 23:20:45
is this line actually needed?
I don't believe we
| |
| 130 content::SetContentClient(old_client_); | 131 content::Initialize(old_client_, old_user_agent_); |
| 131 } | 132 } |
| 132 | 133 |
| 133 void set_privileged_process_id(int process_id) { | 134 void set_privileged_process_id(int process_id) { |
| 134 browser_client_.set_privileged_process_id(process_id); | 135 browser_client_.set_privileged_process_id(process_id); |
| 135 } | 136 } |
| 136 | 137 |
| 137 private: | 138 private: |
| 138 MessageLoopForUI message_loop_; | 139 MessageLoopForUI message_loop_; |
| 139 BrowserThreadImpl ui_thread_; | 140 BrowserThreadImpl ui_thread_; |
| 140 | 141 |
| 141 SiteInstanceTestClient client_; | 142 SiteInstanceTestClient client_; |
| 142 SiteInstanceTestBrowserClient browser_client_; | 143 SiteInstanceTestBrowserClient browser_client_; |
| 143 content::ContentClient* old_client_; | 144 content::ContentClient* old_client_; |
| 144 content::ContentBrowserClient* old_browser_client_; | 145 content::ContentBrowserClient* old_browser_client_; |
| 146 std::string old_user_agent_; | |
| 145 }; | 147 }; |
| 146 | 148 |
| 147 class TestBrowsingInstance : public BrowsingInstance { | 149 class TestBrowsingInstance : public BrowsingInstance { |
| 148 public: | 150 public: |
| 149 TestBrowsingInstance(BrowserContext* browser_context, int* delete_counter) | 151 TestBrowsingInstance(BrowserContext* browser_context, int* delete_counter) |
| 150 : BrowsingInstance(browser_context), | 152 : BrowsingInstance(browser_context), |
| 151 use_process_per_site_(false), | 153 use_process_per_site_(false), |
| 152 delete_counter_(delete_counter) { | 154 delete_counter_(delete_counter) { |
| 153 } | 155 } |
| 154 | 156 |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 614 host.reset(instance->GetProcess()); | 616 host.reset(instance->GetProcess()); |
| 615 EXPECT_TRUE(host.get() != NULL); | 617 EXPECT_TRUE(host.get() != NULL); |
| 616 EXPECT_TRUE(instance->HasProcess()); | 618 EXPECT_TRUE(instance->HasProcess()); |
| 617 | 619 |
| 618 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://evernote.com"))); | 620 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://evernote.com"))); |
| 619 EXPECT_FALSE(instance->HasWrongProcessForURL( | 621 EXPECT_FALSE(instance->HasWrongProcessForURL( |
| 620 GURL("javascript:alert(document.location.href);"))); | 622 GURL("javascript:alert(document.location.href);"))); |
| 621 | 623 |
| 622 EXPECT_TRUE(instance->HasWrongProcessForURL(GURL("chrome://settings"))); | 624 EXPECT_TRUE(instance->HasWrongProcessForURL(GURL("chrome://settings"))); |
| 623 } | 625 } |
| OLD | NEW |