OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "components/navigation_interception/intercept_navigation_throttle.h" | 8 #include "components/navigation_interception/intercept_navigation_throttle.h" |
9 #include "components/navigation_interception/navigation_params.h" | 9 #include "components/navigation_interception/navigation_params.h" |
10 #include "content/public/browser/navigation_handle.h" | 10 #include "content/public/browser/navigation_handle.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 SimulateWillStart(const GURL& url, const GURL& sanitized_url, bool is_post) { | 60 SimulateWillStart(const GURL& url, const GURL& sanitized_url, bool is_post) { |
61 scoped_ptr<content::NavigationHandle> test_handle = | 61 scoped_ptr<content::NavigationHandle> test_handle = |
62 content::NavigationHandle::CreateNavigationHandleForTesting( | 62 content::NavigationHandle::CreateNavigationHandleForTesting( |
63 url, main_rfh()); | 63 url, main_rfh()); |
64 test_handle->RegisterThrottleForTesting( | 64 test_handle->RegisterThrottleForTesting( |
65 scoped_ptr<NavigationThrottle>( | 65 scoped_ptr<NavigationThrottle>( |
66 new InterceptNavigationThrottle( | 66 new InterceptNavigationThrottle( |
67 test_handle.get(), | 67 test_handle.get(), |
68 base::Bind( | 68 base::Bind( |
69 &MockInterceptCallbackReceiver::ShouldIgnoreNavigation, | 69 &MockInterceptCallbackReceiver::ShouldIgnoreNavigation, |
70 base::Unretained(mock_callback_receiver_.get())))) | 70 base::Unretained(mock_callback_receiver_.get())), |
| 71 true)) |
71 .Pass()); | 72 .Pass()); |
72 return test_handle->CallWillStartRequestForTesting( | 73 return test_handle->CallWillStartRequestForTesting( |
73 is_post, content::Referrer(), false, ui::PAGE_TRANSITION_LINK, false); | 74 is_post, content::Referrer(), false, ui::PAGE_TRANSITION_LINK, false); |
74 } | 75 } |
75 | 76 |
76 NavigationThrottle::ThrottleCheckResult Simulate302() { | 77 NavigationThrottle::ThrottleCheckResult Simulate302() { |
77 scoped_ptr<content::NavigationHandle> test_handle = | 78 scoped_ptr<content::NavigationHandle> test_handle = |
78 content::NavigationHandle::CreateNavigationHandleForTesting( | 79 content::NavigationHandle::CreateNavigationHandleForTesting( |
79 GURL(kTestUrl), main_rfh()); | 80 GURL(kTestUrl), main_rfh()); |
80 test_handle->RegisterThrottleForTesting( | 81 test_handle->RegisterThrottleForTesting( |
81 scoped_ptr<NavigationThrottle>( | 82 scoped_ptr<NavigationThrottle>( |
82 new InterceptNavigationThrottle( | 83 new InterceptNavigationThrottle( |
83 test_handle.get(), | 84 test_handle.get(), |
84 base::Bind( | 85 base::Bind( |
85 &MockInterceptCallbackReceiver::ShouldIgnoreNavigation, | 86 &MockInterceptCallbackReceiver::ShouldIgnoreNavigation, |
86 base::Unretained(mock_callback_receiver_.get())))) | 87 base::Unretained(mock_callback_receiver_.get())), |
| 88 true)) |
87 .Pass()); | 89 .Pass()); |
88 test_handle->CallWillStartRequestForTesting( | 90 test_handle->CallWillStartRequestForTesting( |
89 true, content::Referrer(), false, ui::PAGE_TRANSITION_LINK, false); | 91 true, content::Referrer(), false, ui::PAGE_TRANSITION_LINK, false); |
90 return test_handle->CallWillRedirectRequestForTesting(GURL(kTestUrl), false, | 92 return test_handle->CallWillRedirectRequestForTesting(GURL(kTestUrl), false, |
91 GURL(), false); | 93 GURL(), false); |
92 } | 94 } |
93 | 95 |
94 scoped_ptr<MockInterceptCallbackReceiver> mock_callback_receiver_; | 96 scoped_ptr<MockInterceptCallbackReceiver> mock_callback_receiver_; |
95 }; | 97 }; |
96 | 98 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 ShouldIgnoreNavigation( | 158 ShouldIgnoreNavigation( |
157 _, AllOf(NavigationParamsUrlIsTest(), | 159 _, AllOf(NavigationParamsUrlIsTest(), |
158 Property(&NavigationParams::is_post, Eq(false))))) | 160 Property(&NavigationParams::is_post, Eq(false))))) |
159 .WillOnce(Return(false)); | 161 .WillOnce(Return(false)); |
160 NavigationThrottle::ThrottleCheckResult result = Simulate302(); | 162 NavigationThrottle::ThrottleCheckResult result = Simulate302(); |
161 | 163 |
162 EXPECT_EQ(NavigationThrottle::PROCEED, result); | 164 EXPECT_EQ(NavigationThrottle::PROCEED, result); |
163 } | 165 } |
164 | 166 |
165 } // namespace navigation_interception | 167 } // namespace navigation_interception |
OLD | NEW |