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

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

Issue 2871013002: [subresource_filter] Refactor activation suppression (Closed)
Patch Set: just remove the suppression call 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/content_subresource_filt er_throttle_manager.h" 5 #include "components/subresource_filter/content/browser/content_subresource_filt er_throttle_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "components/subresource_filter/content/browser/activation_state_computi ng_navigation_throttle.h" 10 #include "components/subresource_filter/content/browser/activation_state_computi ng_navigation_throttle.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 } 44 }
45 45
46 private: 46 private:
47 ContentSubresourceFilterThrottleManager::Delegate* delegate_; 47 ContentSubresourceFilterThrottleManager::Delegate* delegate_;
48 48
49 DISALLOW_COPY_AND_ASSIGN(ForwardingNavigationThrottle); 49 DISALLOW_COPY_AND_ASSIGN(ForwardingNavigationThrottle);
50 }; 50 };
51 51
52 } // namespace 52 } // namespace
53 53
54 bool ContentSubresourceFilterThrottleManager::Delegate::
55 ShouldSuppressActivation(content::NavigationHandle* navigation_handle) {
56 return false;
57 }
58
59 ContentSubresourceFilterThrottleManager:: 54 ContentSubresourceFilterThrottleManager::
60 ContentSubresourceFilterThrottleManager( 55 ContentSubresourceFilterThrottleManager(
61 Delegate* delegate, 56 Delegate* delegate,
62 VerifiedRulesetDealer::Handle* dealer_handle, 57 VerifiedRulesetDealer::Handle* dealer_handle,
63 content::WebContents* web_contents) 58 content::WebContents* web_contents)
64 : content::WebContentsObserver(web_contents), 59 : content::WebContentsObserver(web_contents),
65 dealer_handle_(dealer_handle), 60 dealer_handle_(dealer_handle),
66 delegate_(delegate), 61 delegate_(delegate),
67 weak_ptr_factory_(this) {} 62 weak_ptr_factory_(this) {}
68 63
69 ContentSubresourceFilterThrottleManager:: 64 ContentSubresourceFilterThrottleManager::
70 ~ContentSubresourceFilterThrottleManager() {} 65 ~ContentSubresourceFilterThrottleManager() {}
71 66
72 void ContentSubresourceFilterThrottleManager::NotifyPageActivationComputed( 67 void ContentSubresourceFilterThrottleManager::NotifyPageActivationComputed(
73 content::NavigationHandle* navigation_handle, 68 content::NavigationHandle* navigation_handle,
74 const ActivationState& activation_state) { 69 const ActivationState& activation_state) {
75 DCHECK(navigation_handle->IsInMainFrame()); 70 DCHECK(navigation_handle->IsInMainFrame());
76 DCHECK(!navigation_handle->HasCommitted()); 71 DCHECK(!navigation_handle->HasCommitted());
77 auto it = ongoing_activation_throttles_.find(navigation_handle); 72 auto it = ongoing_activation_throttles_.find(navigation_handle);
78 if (it != ongoing_activation_throttles_.end()) { 73 if (it != ongoing_activation_throttles_.end()) {
79 it->second->NotifyPageActivationWithRuleset(EnsureRulesetHandle(), 74 it->second->NotifyPageActivationWithRuleset(EnsureRulesetHandle(),
engedy 2017/05/09 22:13:35 Unrelated question: after https://codereview.chrom
Charlie Harrison 2017/05/09 22:27:17 Ah, it isn't great. We don't want to call EnsureRu
Charlie Harrison 2017/05/09 22:33:58 Will it actually be called like this actually? I s
engedy 2017/05/09 22:55:48 Ahh, that's right. Crisis averted!
80 activation_state); 75 activation_state);
81 } 76 }
82 } 77 }
83 78
84 void ContentSubresourceFilterThrottleManager::RenderFrameDeleted( 79 void ContentSubresourceFilterThrottleManager::RenderFrameDeleted(
85 content::RenderFrameHost* frame_host) { 80 content::RenderFrameHost* frame_host) {
86 activated_frame_hosts_.erase(frame_host); 81 activated_frame_hosts_.erase(frame_host);
87 DestroyRulesetHandleIfNoLongerUsed(); 82 DestroyRulesetHandleIfNoLongerUsed();
88 } 83 }
89 84
90 // Pull the AsyncDocumentSubresourceFilter and its associated ActivationState 85 // Pull the AsyncDocumentSubresourceFilter and its associated ActivationState
91 // out of the activation state computing throttle. Store it for later filtering 86 // out of the activation state computing throttle. Store it for later filtering
92 // of subframe navigations. 87 // of subframe navigations.
93 void ContentSubresourceFilterThrottleManager::ReadyToCommitNavigation( 88 void ContentSubresourceFilterThrottleManager::ReadyToCommitNavigation(
94 content::NavigationHandle* navigation_handle) { 89 content::NavigationHandle* navigation_handle) {
95 auto throttle = ongoing_activation_throttles_.find(navigation_handle); 90 auto throttle = ongoing_activation_throttles_.find(navigation_handle);
96 if (throttle == ongoing_activation_throttles_.end()) 91 if (throttle == ongoing_activation_throttles_.end())
97 return; 92 return;
98 93
99 // A filter with DISABLED activation indicates a corrupted ruleset. 94 // A filter with DISABLED activation indicates a corrupted ruleset.
100 AsyncDocumentSubresourceFilter* filter = throttle->second->filter(); 95 AsyncDocumentSubresourceFilter* filter = throttle->second->filter();
101 if (!filter || navigation_handle->GetNetErrorCode() != net::OK || 96 if (!filter || navigation_handle->GetNetErrorCode() != net::OK ||
102 filter->activation_state().activation_level == 97 filter->activation_state().activation_level ==
103 ActivationLevel::DISABLED || 98 ActivationLevel::DISABLED) {
104 delegate_->ShouldSuppressActivation(navigation_handle)) {
105 return; 99 return;
106 } 100 }
107 101
108 throttle->second->WillSendActivationToRenderer(); 102 throttle->second->WillSendActivationToRenderer();
109 103
110 content::RenderFrameHost* frame_host = 104 content::RenderFrameHost* frame_host =
111 navigation_handle->GetRenderFrameHost(); 105 navigation_handle->GetRenderFrameHost();
112 frame_host->Send(new SubresourceFilterMsg_ActivateForNextCommittedLoad( 106 frame_host->Send(new SubresourceFilterMsg_ActivateForNextCommittedLoad(
113 frame_host->GetRoutingID(), filter->activation_state())); 107 frame_host->GetRoutingID(), filter->activation_state()));
114 } 108 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } 270 }
277 } 271 }
278 272
279 void ContentSubresourceFilterThrottleManager::OnDocumentLoadStatistics( 273 void ContentSubresourceFilterThrottleManager::OnDocumentLoadStatistics(
280 const DocumentLoadStatistics& statistics) { 274 const DocumentLoadStatistics& statistics) {
281 if (statistics_) 275 if (statistics_)
282 statistics_->OnDocumentLoadStatistics(statistics); 276 statistics_->OnDocumentLoadStatistics(statistics);
283 } 277 }
284 278
285 } // namespace subresource_filter 279 } // namespace subresource_filter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698