| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/memory/ptr_util.h" | 5 #include "base/memory/ptr_util.h" |
| 6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
| 7 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 7 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 8 #include "components/crx_file/id_util.h" | 8 #include "components/crx_file/id_util.h" |
| 9 #include "content/public/browser/content_browser_client.h" | 9 #include "content/public/browser/content_browser_client.h" |
| 10 #include "content/public/browser/navigation_handle.h" | 10 #include "content/public/browser/navigation_handle.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // |expected_result|. | 69 // |expected_result|. |
| 70 void CheckTestCase(content::RenderFrameHost* host, | 70 void CheckTestCase(content::RenderFrameHost* host, |
| 71 const GURL& url, | 71 const GURL& url, |
| 72 NavigationThrottle::ThrottleCheckResult expected_result) { | 72 NavigationThrottle::ThrottleCheckResult expected_result) { |
| 73 std::unique_ptr<content::NavigationHandle> handle = | 73 std::unique_ptr<content::NavigationHandle> handle = |
| 74 content::NavigationHandle::CreateNavigationHandleForTesting(url, host); | 74 content::NavigationHandle::CreateNavigationHandleForTesting(url, host); |
| 75 EXPECT_EQ(expected_result, | 75 EXPECT_EQ(expected_result, |
| 76 handle->CallWillStartRequestForTesting( | 76 handle->CallWillStartRequestForTesting( |
| 77 /*is_post=*/false, content::Referrer(), | 77 /*is_post=*/false, content::Referrer(), |
| 78 /*has_user_gesture=*/false, ui::PAGE_TRANSITION_LINK, | 78 /*has_user_gesture=*/false, ui::PAGE_TRANSITION_LINK, |
| 79 /*is_external_protocol=*/false)) | 79 /*is_external_protocol=*/false, |
| 80 content::NavigationHandle::ThrottleChecksFinishedCallback())) |
| 80 << url; | 81 << url; |
| 81 } | 82 } |
| 82 | 83 |
| 83 const Extension* extension() { return extension_.get(); } | 84 const Extension* extension() { return extension_.get(); } |
| 84 content::WebContentsTester* web_contents_tester() { | 85 content::WebContentsTester* web_contents_tester() { |
| 85 return content::WebContentsTester::For(web_contents()); | 86 return content::WebContentsTester::For(web_contents()); |
| 86 } | 87 } |
| 87 content::RenderFrameHostTester* render_frame_host_tester( | 88 content::RenderFrameHostTester* render_frame_host_tester( |
| 88 content::RenderFrameHost* host) { | 89 content::RenderFrameHost* host) { |
| 89 return content::RenderFrameHostTester::For(host); | 90 return content::RenderFrameHostTester::For(host); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 190 |
| 190 std::string second_id = crx_file::id_util::GenerateId("bar"); | 191 std::string second_id = crx_file::id_util::GenerateId("bar"); |
| 191 ASSERT_NE(second_id, extension()->id()); | 192 ASSERT_NE(second_id, extension()->id()); |
| 192 GURL invalid_url(base::StringPrintf("chrome-extension://%s/accessible.html", | 193 GURL invalid_url(base::StringPrintf("chrome-extension://%s/accessible.html", |
| 193 second_id.c_str())); | 194 second_id.c_str())); |
| 194 // Requests to non-existent extensions should be blocked. | 195 // Requests to non-existent extensions should be blocked. |
| 195 CheckTestCase(child, invalid_url, NavigationThrottle::BLOCK_REQUEST); | 196 CheckTestCase(child, invalid_url, NavigationThrottle::BLOCK_REQUEST); |
| 196 } | 197 } |
| 197 | 198 |
| 198 } // namespace extensions | 199 } // namespace extensions |
| OLD | NEW |