| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "components/subresource_filter/content/browser/activation_state_computi
ng_navigation_throttle.h" | 5 #include "components/subresource_filter/content/browser/activation_state_computi
ng_navigation_throttle.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 parent_activation_state_.value()); | 163 parent_activation_state_.value()); |
| 164 test_throttle_ = throttle.get(); | 164 test_throttle_ = throttle.get(); |
| 165 navigation_handle->RegisterThrottleForTesting(std::move(throttle)); | 165 navigation_handle->RegisterThrottleForTesting(std::move(throttle)); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void ReadyToCommitNavigation( | 168 void ReadyToCommitNavigation( |
| 169 content::NavigationHandle* navigation_handle) override { | 169 content::NavigationHandle* navigation_handle) override { |
| 170 if (!test_throttle_) | 170 if (!test_throttle_) |
| 171 return; | 171 return; |
| 172 ASSERT_EQ(navigation_handle, test_throttle_->navigation_handle()); | 172 ASSERT_EQ(navigation_handle, test_throttle_->navigation_handle()); |
| 173 last_activation_state_ = test_throttle_->GetActivationState(); | 173 if (test_throttle_->filter()) |
| 174 if (last_activation_state_.value().activation_level == | 174 test_throttle_->WillSendActivationToRenderer(); |
| 175 ActivationLevel::DISABLED) { | 175 |
| 176 EXPECT_FALSE(test_throttle_->ReleaseFilter()); | 176 if (auto filter = test_throttle_->ReleaseFilter()) { |
| 177 EXPECT_NE(ActivationLevel::DISABLED, |
| 178 filter->activation_state().activation_level); |
| 179 last_activation_state_ = filter->activation_state(); |
| 177 } else { | 180 } else { |
| 178 EXPECT_TRUE(test_throttle_->ReleaseFilter()); | 181 last_activation_state_ = ActivationState(ActivationLevel::DISABLED); |
| 179 } | 182 } |
| 180 } | 183 } |
| 181 | 184 |
| 182 void DidFinishNavigation( | 185 void DidFinishNavigation( |
| 183 content::NavigationHandle* navigation_handle) override { | 186 content::NavigationHandle* navigation_handle) override { |
| 184 if (!test_throttle_) | 187 if (!test_throttle_) |
| 185 return; | 188 return; |
| 186 last_committed_frame_host_ = navigation_handle->GetRenderFrameHost(); | 189 last_committed_frame_host_ = navigation_handle->GetRenderFrameHost(); |
| 187 test_throttle_ = nullptr; | 190 test_throttle_ = nullptr; |
| 188 } | 191 } |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 SimulateStartAndExpectToProceed(); | 407 SimulateStartAndExpectToProceed(); |
| 405 SimulateCommitAndExpectToProceed(); | 408 SimulateCommitAndExpectToProceed(); |
| 406 | 409 |
| 407 state = last_activation_state(); | 410 state = last_activation_state(); |
| 408 EXPECT_EQ(ActivationLevel::ENABLED, state.activation_level); | 411 EXPECT_EQ(ActivationLevel::ENABLED, state.activation_level); |
| 409 EXPECT_TRUE(state.filtering_disabled_for_document); | 412 EXPECT_TRUE(state.filtering_disabled_for_document); |
| 410 EXPECT_TRUE(state.generic_blocking_rules_disabled); | 413 EXPECT_TRUE(state.generic_blocking_rules_disabled); |
| 411 } | 414 } |
| 412 | 415 |
| 413 } // namespace subresource_filter | 416 } // namespace subresource_filter |
| OLD | NEW |