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

Side by Side Diff: components/subresource_filter/content/renderer/subresource_filter_agent.cc

Issue 2814733002: Add the SocEng as a type for checking in CheckUrlForSubresourceFilter. (Closed)
Patch Set: . Created 3 years, 8 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 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 "components/subresource_filter/content/renderer/subresource_filter_agen t.h" 5 #include "components/subresource_filter/content/renderer/subresource_filter_agen t.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 const DocumentLoadStatistics& statistics) { 57 const DocumentLoadStatistics& statistics) {
58 render_frame()->Send(new SubresourceFilterHostMsg_DocumentLoadStatistics( 58 render_frame()->Send(new SubresourceFilterHostMsg_DocumentLoadStatistics(
59 render_frame()->GetRoutingID(), statistics)); 59 render_frame()->GetRoutingID(), statistics));
60 } 60 }
61 61
62 void SubresourceFilterAgent::OnActivateForNextCommittedLoad( 62 void SubresourceFilterAgent::OnActivateForNextCommittedLoad(
63 ActivationState activation_state) { 63 ActivationState activation_state) {
64 activation_state_for_next_commit_ = activation_state; 64 activation_state_for_next_commit_ = activation_state;
65 } 65 }
66 66
67 void SubresourceFilterAgent::RecordHistogramsOnLoadCommitted() { 67 void SubresourceFilterAgent::RecordedHistogramsOnLoadCommitted() {
68 // Note: ActivationLevel used to be called ActivationState, the legacy name is 68 // Note: ActivationLevel used to be called ActivationState, the legacy name is
69 // kept for the histogram. 69 // kept for the histogram.
70 ActivationLevel activation_level = 70 ActivationLevel activation_level =
71 activation_state_for_next_commit_.activation_level; 71 activation_state_for_next_commit_.activation_level;
72 UMA_HISTOGRAM_ENUMERATION("SubresourceFilter.DocumentLoad.ActivationState", 72 UMA_HISTOGRAM_ENUMERATION("SubresourceFilter.DocumentLoad.ActivationState",
73 static_cast<int>(activation_level), 73 static_cast<int>(activation_level),
74 static_cast<int>(ActivationLevel::LAST) + 1); 74 static_cast<int>(ActivationLevel::LAST) + 1);
75 75
76 if (activation_level != ActivationLevel::DISABLED) { 76 if (activation_level != ActivationLevel::DISABLED) {
77 UMA_HISTOGRAM_BOOLEAN("SubresourceFilter.DocumentLoad.RulesetIsAvailable", 77 UMA_HISTOGRAM_BOOLEAN("SubresourceFilter.DocumentLoad.RulesetIsAvailable",
78 ruleset_dealer_->IsRulesetFileAvailable()); 78 ruleset_dealer_->IsRulesetFileAvailable());
79 } 79 }
80 } 80 }
81 81
82 void SubresourceFilterAgent::RecordHistogramsOnLoadFinished() { 82 void SubresourceFilterAgent::RecordedHistogramsOnLoadFinished() {
83 DCHECK(filter_for_last_committed_load_); 83 DCHECK(filter_for_last_committed_load_);
84 const auto& statistics = 84 const auto& statistics =
85 filter_for_last_committed_load_->filter().statistics(); 85 filter_for_last_committed_load_->filter().statistics();
86 86
87 UMA_HISTOGRAM_COUNTS_1000( 87 UMA_HISTOGRAM_COUNTS_1000(
88 "SubresourceFilter.DocumentLoad.NumSubresourceLoads.Total", 88 "SubresourceFilter.DocumentLoad.NumSubresourceLoads.Total",
89 statistics.num_loads_total); 89 statistics.num_loads_total);
90 UMA_HISTOGRAM_COUNTS_1000( 90 UMA_HISTOGRAM_COUNTS_1000(
91 "SubresourceFilter.DocumentLoad.NumSubresourceLoads.Evaluated", 91 "SubresourceFilter.DocumentLoad.NumSubresourceLoads.Evaluated",
92 statistics.num_loads_evaluated); 92 statistics.num_loads_evaluated);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 bool is_same_document_navigation) { 136 bool is_same_document_navigation) {
137 if (is_same_document_navigation) 137 if (is_same_document_navigation)
138 return; 138 return;
139 139
140 filter_for_last_committed_load_.reset(); 140 filter_for_last_committed_load_.reset();
141 141
142 // TODO(csharrison): Use WebURL and WebSecurityOrigin for efficiency here, 142 // TODO(csharrison): Use WebURL and WebSecurityOrigin for efficiency here,
143 // which require changes to the unit tests. 143 // which require changes to the unit tests.
144 const GURL& url = GetDocumentURL(); 144 const GURL& url = GetDocumentURL();
145 if (url.SchemeIsHTTPOrHTTPS() || url.SchemeIsFile()) { 145 if (url.SchemeIsHTTPOrHTTPS() || url.SchemeIsFile()) {
146 RecordHistogramsOnLoadCommitted(); 146 RecordedHistogramsOnLoadCommitted();
147 if (activation_state_for_next_commit_.activation_level != 147 if (activation_state_for_next_commit_.activation_level !=
148 ActivationLevel::DISABLED && 148 ActivationLevel::DISABLED &&
149 ruleset_dealer_->IsRulesetFileAvailable()) { 149 ruleset_dealer_->IsRulesetFileAvailable()) {
150 base::OnceClosure first_disallowed_load_callback( 150 base::OnceClosure first_disallowed_load_callback(
151 base::BindOnce(&SubresourceFilterAgent:: 151 base::BindOnce(&SubresourceFilterAgent::
152 SignalFirstSubresourceDisallowedForCommittedLoad, 152 SignalFirstSubresourceDisallowedForCommittedLoad,
153 AsWeakPtr())); 153 AsWeakPtr()));
154 154
155 auto ruleset = ruleset_dealer_->GetRuleset(); 155 auto ruleset = ruleset_dealer_->GetRuleset();
156 DCHECK(ruleset); 156 DCHECK(ruleset);
(...skipping 11 matching lines...) Expand all
168 168
169 void SubresourceFilterAgent::DidFailProvisionalLoad( 169 void SubresourceFilterAgent::DidFailProvisionalLoad(
170 const blink::WebURLError& error) { 170 const blink::WebURLError& error) {
171 // TODO(engedy): Add a test with `frame-ancestor` violation to exercise this. 171 // TODO(engedy): Add a test with `frame-ancestor` violation to exercise this.
172 ResetActivatonStateForNextCommit(); 172 ResetActivatonStateForNextCommit();
173 } 173 }
174 174
175 void SubresourceFilterAgent::DidFinishLoad() { 175 void SubresourceFilterAgent::DidFinishLoad() {
176 if (!filter_for_last_committed_load_) 176 if (!filter_for_last_committed_load_)
177 return; 177 return;
178 RecordHistogramsOnLoadFinished(); 178 RecordedHistogramsOnLoadFinished();
179 } 179 }
180 180
181 bool SubresourceFilterAgent::OnMessageReceived(const IPC::Message& message) { 181 bool SubresourceFilterAgent::OnMessageReceived(const IPC::Message& message) {
182 bool handled = true; 182 bool handled = true;
183 IPC_BEGIN_MESSAGE_MAP(SubresourceFilterAgent, message) 183 IPC_BEGIN_MESSAGE_MAP(SubresourceFilterAgent, message)
184 IPC_MESSAGE_HANDLER(SubresourceFilterMsg_ActivateForNextCommittedLoad, 184 IPC_MESSAGE_HANDLER(SubresourceFilterMsg_ActivateForNextCommittedLoad,
185 OnActivateForNextCommittedLoad) 185 OnActivateForNextCommittedLoad)
186 IPC_MESSAGE_UNHANDLED(handled = false) 186 IPC_MESSAGE_UNHANDLED(handled = false)
187 IPC_END_MESSAGE_MAP() 187 IPC_END_MESSAGE_MAP()
188 return handled; 188 return handled;
189 } 189 }
190 190
191 } // namespace subresource_filter 191 } // namespace subresource_filter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698