| 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 <set> | 5 #include <set> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 } // namespace | 50 } // namespace |
| 51 | 51 |
| 52 class ChildProcessSecurityPolicyTest : public testing::Test { | 52 class ChildProcessSecurityPolicyTest : public testing::Test { |
| 53 public: | 53 public: |
| 54 ChildProcessSecurityPolicyTest() : old_browser_client_(NULL) { | 54 ChildProcessSecurityPolicyTest() : old_browser_client_(NULL) { |
| 55 } | 55 } |
| 56 | 56 |
| 57 virtual void SetUp() { | 57 virtual void SetUp() { |
| 58 old_browser_client_ = GetContentClient()->browser(); | 58 old_browser_client_ = SetBrowserClientForTesting(&test_browser_client_); |
| 59 GetContentClient()->set_browser_for_testing(&test_browser_client_); | |
| 60 | 59 |
| 61 // Claim to always handle chrome:// URLs because the CPSP's notion of | 60 // Claim to always handle chrome:// URLs because the CPSP's notion of |
| 62 // allowing WebUI bindings is hard-wired to this particular scheme. | 61 // allowing WebUI bindings is hard-wired to this particular scheme. |
| 63 test_browser_client_.AddScheme("chrome"); | 62 test_browser_client_.AddScheme("chrome"); |
| 64 } | 63 } |
| 65 | 64 |
| 66 virtual void TearDown() { | 65 virtual void TearDown() { |
| 67 test_browser_client_.ClearSchemes(); | 66 test_browser_client_.ClearSchemes(); |
| 68 GetContentClient()->set_browser_for_testing(old_browser_client_); | 67 SetBrowserClientForTesting(old_browser_client_); |
| 69 } | 68 } |
| 70 | 69 |
| 71 protected: | 70 protected: |
| 72 void RegisterTestScheme(const std::string& scheme) { | 71 void RegisterTestScheme(const std::string& scheme) { |
| 73 test_browser_client_.AddScheme(scheme); | 72 test_browser_client_.AddScheme(scheme); |
| 74 } | 73 } |
| 75 | 74 |
| 76 private: | 75 private: |
| 77 ChildProcessSecurityPolicyTestBrowserClient test_browser_client_; | 76 ChildProcessSecurityPolicyTestBrowserClient test_browser_client_; |
| 78 ContentBrowserClient* old_browser_client_; | 77 ContentBrowserClient* old_browser_client_; |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 // queried on the IO thread. The ChildProcessSecurityPolicy needs to be | 543 // queried on the IO thread. The ChildProcessSecurityPolicy needs to be |
| 545 // prepared to answer policy questions about renderers who no longer exist. | 544 // prepared to answer policy questions about renderers who no longer exist. |
| 546 | 545 |
| 547 // In this case, we default to secure behavior. | 546 // In this case, we default to secure behavior. |
| 548 EXPECT_FALSE(p->CanRequestURL(kRendererID, url)); | 547 EXPECT_FALSE(p->CanRequestURL(kRendererID, url)); |
| 549 EXPECT_FALSE(p->CanReadFile(kRendererID, file)); | 548 EXPECT_FALSE(p->CanReadFile(kRendererID, file)); |
| 550 EXPECT_FALSE(p->HasWebUIBindings(kRendererID)); | 549 EXPECT_FALSE(p->HasWebUIBindings(kRendererID)); |
| 551 } | 550 } |
| 552 | 551 |
| 553 } // namespace content | 552 } // namespace content |
| OLD | NEW |