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

Unified Diff: components/subresource_filter/content/browser/content_subresource_filter_driver_factory.h

Issue 2703093002: Add metrics for tracking subresource filter activation suppression. (Closed)
Patch Set: address comments Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: components/subresource_filter/content/browser/content_subresource_filter_driver_factory.h
diff --git a/components/subresource_filter/content/browser/content_subresource_filter_driver_factory.h b/components/subresource_filter/content/browser/content_subresource_filter_driver_factory.h
index 06e8544dac0cad7cdfcb3f6d62b4a05d04e3ee60..703d7878fbc4189f62fb807d5536ed0f7e16e01c 100644
--- a/components/subresource_filter/content/browser/content_subresource_filter_driver_factory.h
+++ b/components/subresource_filter/content/browser/content_subresource_filter_driver_factory.h
@@ -46,12 +46,42 @@ class ContentSubresourceFilterDriverFactory
: public base::SupportsUserData::Data,
public content::WebContentsObserver {
public:
+ enum ActivationDecision {
Ilya Sherman 2017/02/21 22:58:24 Please document that this enum is used to back an
Bryan McQuade 2017/02/22 01:03:47 Ah, good idea, thanks! Done.
+ // The activation decision is unknown, or not known yet.
+ UNKNOWN,
+
+ // Did not activate because subresource filtering was disabled.
+ ACTIVATION_DISABLED,
+
+ // Did not activate because the main resource URL had an unsupported scheme.
+ UNSUPPORTED_SCHEME,
+
+ // Did not activate because the main resource URL was whitelisted.
+ URL_WHITELISTED,
+
+ // Did not activate because the main resource URL did not match the
+ // activation list.
+ ACTIVATION_LIST_NOT_MATCHED,
+
+ // Subresource filtering was activated.
+ ACTIVATED,
+
+ // Max value for enum.
+ ACTIVATION_DECISION_MAX
+ };
+
static void CreateForWebContents(
content::WebContents* web_contents,
std::unique_ptr<SubresourceFilterClient> client);
static ContentSubresourceFilterDriverFactory* FromWebContents(
content::WebContents* web_contents);
+ // Whether the |url|, |referrer|, and |transition| are considered to be
+ // associated with a page reload.
+ static bool NavigationIsPageReload(const GURL& url,
+ const content::Referrer& referrer,
+ ui::PageTransition transition);
+
explicit ContentSubresourceFilterDriverFactory(
content::WebContents* web_contents,
std::unique_ptr<SubresourceFilterClient> client);
@@ -75,6 +105,12 @@ class ContentSubresourceFilterDriverFactory
// Reloads the page and inserts the host of its URL to the whitelist.
void OnReloadRequested();
+ // Returns the |ActivationDecision| for the current main frame
+ // document.
+ ActivationDecision GetActivationDecisionForLastCommittedPageLoad() const {
+ return activation_decision_;
+ }
+
private:
friend class ContentSubresourceFilterDriverFactoryTest;
friend class safe_browsing::SafeBrowsingServiceTest;
@@ -99,12 +135,12 @@ class ContentSubresourceFilterDriverFactory
bool OnMessageReceived(const IPC::Message& message,
content::RenderFrameHost* render_frame_host) override;
- // Checks base on the value of |urr| and current activation scope if
+ // Checks base on the value of |url| and current activation scope if
// activation signal should be sent.
- bool ShouldActivateForMainFrameURL(const GURL& url) const;
+ ActivationDecision ComputeActivationDecisionForMainFrameURL(
+ const GURL& url) const;
void ActivateForFrameHostIfNeeded(content::RenderFrameHost* render_frame_host,
- const GURL& url,
- bool failed_navigation);
+ const GURL& url);
// Internal implementation of ReadyToCommitNavigation which doesn't use
// NavigationHandle to ease unit tests.
@@ -112,8 +148,7 @@ class ContentSubresourceFilterDriverFactory
content::RenderFrameHost* render_frame_host,
const GURL& url,
const content::Referrer& referrer,
- ui::PageTransition page_transition,
- bool failed_navigation);
+ ui::PageTransition page_transition);
bool DidURLMatchCurrentActivationList(const GURL& url) const;
@@ -125,6 +160,7 @@ class ContentSubresourceFilterDriverFactory
HostPathSet whitelisted_hosts_;
ActivationLevel activation_level_;
+ ActivationDecision activation_decision_;
bool measure_performance_;
// The URLs in the navigation chain.

Powered by Google App Engine
This is Rietveld 408576698