Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: components/subresource_filter/content/browser/subresource_filter_safe_browsing_activation_throttle_unittest.cc

Issue 2889913002: [subresource_filter] Remove Forwarding NavigationThrottles (Closed)
Patch Set: Remove silly forwarding throttles Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/subresource_filter_safe_ browsing_activation_throttle.h" 5 #include "components/subresource_filter/content/browser/subresource_filter_safe_ browsing_activation_throttle.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <tuple> 8 #include <tuple>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 MOCK_METHOD2(OnPageActivationComputed, 74 MOCK_METHOD2(OnPageActivationComputed,
75 bool(content::NavigationHandle*, bool)); 75 bool(content::NavigationHandle*, bool));
76 MOCK_METHOD1(WhitelistByContentSettings, void(const GURL&)); 76 MOCK_METHOD1(WhitelistByContentSettings, void(const GURL&));
77 MOCK_METHOD1(WhitelistInCurrentWebContents, void(const GURL&)); 77 MOCK_METHOD1(WhitelistInCurrentWebContents, void(const GURL&));
78 MOCK_METHOD0(GetRulesetDealer, VerifiedRulesetDealer::Handle*()); 78 MOCK_METHOD0(GetRulesetDealer, VerifiedRulesetDealer::Handle*());
79 79
80 private: 80 private:
81 DISALLOW_COPY_AND_ASSIGN(MockSubresourceFilterClient); 81 DISALLOW_COPY_AND_ASSIGN(MockSubresourceFilterClient);
82 }; 82 };
83 83
84 // Throttle to call WillProcessResponse on the factory, which is otherwise
85 // called by the ThrottleManager.
86 class TestForwardingNavigationThrottle : public content::NavigationThrottle {
87 public:
88 explicit TestForwardingNavigationThrottle(content::NavigationHandle* handle)
89 : content::NavigationThrottle(handle) {}
90 ~TestForwardingNavigationThrottle() override {}
91
92 // content::NavigationThrottle:
93 content::NavigationThrottle::ThrottleCheckResult WillProcessResponse()
94 override {
95 content::WebContents* web_contents = navigation_handle()->GetWebContents();
96 ContentSubresourceFilterDriverFactory* factory =
97 ContentSubresourceFilterDriverFactory::FromWebContents(web_contents);
98 factory->WillProcessResponse(navigation_handle());
99 return content::NavigationThrottle::PROCEED;
100 }
101 const char* GetNameForLogging() override {
102 return "TestForwardingNavigationThrottle";
103 }
104
105 private:
106 DISALLOW_COPY_AND_ASSIGN(TestForwardingNavigationThrottle);
107 };
108
109 std::string GetSuffixForList(const ActivationList& type) { 84 std::string GetSuffixForList(const ActivationList& type) {
110 switch (type) { 85 switch (type) {
111 case ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL: 86 case ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL:
112 return "SocialEngineeringAdsInterstitial"; 87 return "SocialEngineeringAdsInterstitial";
113 case ActivationList::PHISHING_INTERSTITIAL: 88 case ActivationList::PHISHING_INTERSTITIAL:
114 return "PhishingInterstitial"; 89 return "PhishingInterstitial";
115 case ActivationList::SUBRESOURCE_FILTER: 90 case ActivationList::SUBRESOURCE_FILTER:
116 return "SubresourceFilterOnly"; 91 return "SubresourceFilterOnly";
117 case ActivationList::NONE: 92 case ActivationList::NONE:
118 return std::string(); 93 return std::string();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 165 }
191 166
192 // content::WebContentsObserver: 167 // content::WebContentsObserver:
193 void DidStartNavigation( 168 void DidStartNavigation(
194 content::NavigationHandle* navigation_handle) override { 169 content::NavigationHandle* navigation_handle) override {
195 ASSERT_TRUE(navigation_handle->IsInMainFrame()); 170 ASSERT_TRUE(navigation_handle->IsInMainFrame());
196 navigation_handle->RegisterThrottleForTesting( 171 navigation_handle->RegisterThrottleForTesting(
197 base::MakeUnique<SubresourceFilterSafeBrowsingActivationThrottle>( 172 base::MakeUnique<SubresourceFilterSafeBrowsingActivationThrottle>(
198 navigation_handle, test_io_task_runner_, 173 navigation_handle, test_io_task_runner_,
199 fake_safe_browsing_database_)); 174 fake_safe_browsing_database_));
200 navigation_handle->RegisterThrottleForTesting(
201 base::MakeUnique<TestForwardingNavigationThrottle>(navigation_handle));
202 } 175 }
203 176
204 content::NavigationThrottle::ThrottleCheckResult SimulateStart() { 177 content::NavigationThrottle::ThrottleCheckResult SimulateStart() {
205 navigation_simulator_->Start(); 178 navigation_simulator_->Start();
206 auto result = navigation_simulator_->GetLastThrottleCheckResult(); 179 auto result = navigation_simulator_->GetLastThrottleCheckResult();
207 if (result == content::NavigationThrottle::CANCEL) 180 if (result == content::NavigationThrottle::CANCEL)
208 navigation_simulator_.reset(); 181 navigation_simulator_.reset();
209 return result; 182 return result;
210 } 183 }
211 184
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 ::testing::Values( 625 ::testing::Values(
653 content::CancellingNavigationThrottle::SYNCHRONOUS, 626 content::CancellingNavigationThrottle::SYNCHRONOUS,
654 content::CancellingNavigationThrottle::ASYNCHRONOUS))); 627 content::CancellingNavigationThrottle::ASYNCHRONOUS)));
655 628
656 INSTANTIATE_TEST_CASE_P( 629 INSTANTIATE_TEST_CASE_P(
657 ActivationLevelTest, 630 ActivationLevelTest,
658 SubresourceFilterSafeBrowsingActivationThrottleParamTest, 631 SubresourceFilterSafeBrowsingActivationThrottleParamTest,
659 ::testing::ValuesIn(kActivationListTestData)); 632 ::testing::ValuesIn(kActivationListTestData));
660 633
661 } // namespace subresource_filter 634 } // namespace subresource_filter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698