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/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_ = GetContentClient()->browser(); |
59 GetContentClient()->set_browser_for_testing(&test_browser_client_); | 59 GetContentClient()->set_browser_for_testing(&test_browser_client_); |
60 | 60 |
61 // Claim to always handle chrome:// URLs because the CPSP's notion of | 61 // Claim to always handle chrome:// URLs because the CPSP's notion of |
62 // allowing WebUI bindings is hard-wired to this particular scheme. | 62 // allowing WebUI bindings is hard-wired to this particular scheme. |
63 test_browser_client_.AddScheme("chrome"); | 63 test_browser_client_.AddScheme(chrome::kChromeUIScheme); |
| 64 |
| 65 // Claim to always handle file:// URLs like the browser would. |
| 66 // net::URLRequest::IsHandledURL() no longer claims support for default |
| 67 // protocols as this is the responsibility of the browser (which is |
| 68 // responsible for adding the appropriate ProtocolHandler). |
| 69 test_browser_client_.AddScheme(chrome::kFileScheme); |
64 } | 70 } |
65 | 71 |
66 virtual void TearDown() { | 72 virtual void TearDown() { |
67 test_browser_client_.ClearSchemes(); | 73 test_browser_client_.ClearSchemes(); |
68 GetContentClient()->set_browser_for_testing(old_browser_client_); | 74 GetContentClient()->set_browser_for_testing(old_browser_client_); |
69 } | 75 } |
70 | 76 |
71 protected: | 77 protected: |
72 void RegisterTestScheme(const std::string& scheme) { | 78 void RegisterTestScheme(const std::string& scheme) { |
73 test_browser_client_.AddScheme(scheme); | 79 test_browser_client_.AddScheme(scheme); |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 // queried on the IO thread. The ChildProcessSecurityPolicy needs to be | 548 // queried on the IO thread. The ChildProcessSecurityPolicy needs to be |
543 // prepared to answer policy questions about renderers who no longer exist. | 549 // prepared to answer policy questions about renderers who no longer exist. |
544 | 550 |
545 // In this case, we default to secure behavior. | 551 // In this case, we default to secure behavior. |
546 EXPECT_FALSE(p->CanRequestURL(kRendererID, url)); | 552 EXPECT_FALSE(p->CanRequestURL(kRendererID, url)); |
547 EXPECT_FALSE(p->CanReadFile(kRendererID, file)); | 553 EXPECT_FALSE(p->CanReadFile(kRendererID, file)); |
548 EXPECT_FALSE(p->HasWebUIBindings(kRendererID)); | 554 EXPECT_FALSE(p->HasWebUIBindings(kRendererID)); |
549 } | 555 } |
550 | 556 |
551 } // namespace content | 557 } // namespace content |
OLD | NEW |