| 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 "content/browser/child_process_security_policy_impl.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 std::set<std::string> schemes_; | 50 std::set<std::string> schemes_; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 } // namespace | 53 } // namespace |
| 54 | 54 |
| 55 class ChildProcessSecurityPolicyTest : public testing::Test { | 55 class ChildProcessSecurityPolicyTest : public testing::Test { |
| 56 public: | 56 public: |
| 57 ChildProcessSecurityPolicyTest() : old_browser_client_(NULL) { | 57 ChildProcessSecurityPolicyTest() : old_browser_client_(NULL) { |
| 58 } | 58 } |
| 59 | 59 |
| 60 virtual void SetUp() { | 60 void SetUp() override { |
| 61 old_browser_client_ = SetBrowserClientForTesting(&test_browser_client_); | 61 old_browser_client_ = SetBrowserClientForTesting(&test_browser_client_); |
| 62 | 62 |
| 63 // Claim to always handle chrome:// URLs because the CPSP's notion of | 63 // Claim to always handle chrome:// URLs because the CPSP's notion of |
| 64 // allowing WebUI bindings is hard-wired to this particular scheme. | 64 // allowing WebUI bindings is hard-wired to this particular scheme. |
| 65 test_browser_client_.AddScheme(kChromeUIScheme); | 65 test_browser_client_.AddScheme(kChromeUIScheme); |
| 66 | 66 |
| 67 // Claim to always handle file:// URLs like the browser would. | 67 // Claim to always handle file:// URLs like the browser would. |
| 68 // net::URLRequest::IsHandledURL() no longer claims support for default | 68 // net::URLRequest::IsHandledURL() no longer claims support for default |
| 69 // protocols as this is the responsibility of the browser (which is | 69 // protocols as this is the responsibility of the browser (which is |
| 70 // responsible for adding the appropriate ProtocolHandler). | 70 // responsible for adding the appropriate ProtocolHandler). |
| 71 test_browser_client_.AddScheme(url::kFileScheme); | 71 test_browser_client_.AddScheme(url::kFileScheme); |
| 72 } | 72 } |
| 73 | 73 |
| 74 virtual void TearDown() { | 74 void TearDown() override { |
| 75 test_browser_client_.ClearSchemes(); | 75 test_browser_client_.ClearSchemes(); |
| 76 SetBrowserClientForTesting(old_browser_client_); | 76 SetBrowserClientForTesting(old_browser_client_); |
| 77 } | 77 } |
| 78 | 78 |
| 79 protected: | 79 protected: |
| 80 void RegisterTestScheme(const std::string& scheme) { | 80 void RegisterTestScheme(const std::string& scheme) { |
| 81 test_browser_client_.AddScheme(scheme); | 81 test_browser_client_.AddScheme(scheme); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void GrantPermissionsForFile(ChildProcessSecurityPolicyImpl* p, | 84 void GrantPermissionsForFile(ChildProcessSecurityPolicyImpl* p, |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 // queried on the IO thread. The ChildProcessSecurityPolicy needs to be | 635 // queried on the IO thread. The ChildProcessSecurityPolicy needs to be |
| 636 // prepared to answer policy questions about renderers who no longer exist. | 636 // prepared to answer policy questions about renderers who no longer exist. |
| 637 | 637 |
| 638 // In this case, we default to secure behavior. | 638 // In this case, we default to secure behavior. |
| 639 EXPECT_FALSE(p->CanRequestURL(kRendererID, url)); | 639 EXPECT_FALSE(p->CanRequestURL(kRendererID, url)); |
| 640 EXPECT_FALSE(p->CanReadFile(kRendererID, file)); | 640 EXPECT_FALSE(p->CanReadFile(kRendererID, file)); |
| 641 EXPECT_FALSE(p->HasWebUIBindings(kRendererID)); | 641 EXPECT_FALSE(p->HasWebUIBindings(kRendererID)); |
| 642 } | 642 } |
| 643 | 643 |
| 644 } // namespace content | 644 } // namespace content |
| OLD | NEW |