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

Unified Diff: Source/core/loader/MixedContentChecker.cpp

Issue 785133004: Mixed Content: Add use counters for content types. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « Source/core/loader/MixedContentChecker.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/loader/MixedContentChecker.cpp
diff --git a/Source/core/loader/MixedContentChecker.cpp b/Source/core/loader/MixedContentChecker.cpp
index a95506608316f069b44f0143160f2e87ba232705..00e80ada96be37a798c2b94e938c83ae22280f4a 100644
--- a/Source/core/loader/MixedContentChecker.cpp
+++ b/Source/core/loader/MixedContentChecker.cpp
@@ -45,9 +45,6 @@
namespace blink {
-namespace {
-} // namespace
-
MixedContentChecker::MixedContentChecker(LocalFrame* frame)
: m_frame(frame)
{
@@ -213,6 +210,53 @@ void MixedContentChecker::logToConsole(LocalFrame* frame, const KURL& url, WebUR
}
// static
+void MixedContentChecker::count(LocalFrame* frame, WebURLRequest::RequestContext requestContext)
+{
+ UseCounter::count(frame, UseCounter::MixedContentPresent);
+
+ // Roll blockable content up into a single counter, count unblocked types individually so we
+ // can determine when they can be safely moved to the blockable category:
+ ContextType contextType = contextTypeFromContext(requestContext);
+ if (contextType == ContextTypeBlockable || contextType == ContextTypeBlockableUnlessLax) {
+ UseCounter::count(frame, UseCounter::MixedContentBlockable);
+ return;
+ }
+
+ UseCounter::Feature feature;
+ switch (requestContext) {
+ case WebURLRequest::RequestContextAudio:
+ feature = UseCounter::MixedContentAudio;
+ break;
+ case WebURLRequest::RequestContextDownload:
+ feature = UseCounter::MixedContentDownload;
+ break;
+ case WebURLRequest::RequestContextFavicon:
+ feature = UseCounter::MixedContentFavicon;
+ break;
+ case WebURLRequest::RequestContextImage:
+ feature = UseCounter::MixedContentImage;
+ break;
+ case WebURLRequest::RequestContextInternal:
+ feature = UseCounter::MixedContentInternal;
+ break;
+ case WebURLRequest::RequestContextPlugin:
+ feature = UseCounter::MixedContentPlugin;
+ break;
+ case WebURLRequest::RequestContextPrefetch:
+ feature = UseCounter::MixedContentPrefetch;
+ break;
+ case WebURLRequest::RequestContextVideo:
+ feature = UseCounter::MixedContentVideo;
+ break;
+
+ default:
+ ASSERT_NOT_REACHED();
+ return;
+ }
+ UseCounter::count(frame, feature);
+}
+
+// static
bool MixedContentChecker::shouldBlockFetch(LocalFrame* frame, const ResourceRequest& resourceRequest, const KURL& url, MixedContentChecker::ReportingStatus reportingStatus)
{
// No frame, no mixed content:
@@ -240,6 +284,8 @@ bool MixedContentChecker::shouldBlockFetch(LocalFrame* frame, const ResourceRequ
if (!isMixedContent(frame->document()->securityOrigin(), url))
return false;
+ MixedContentChecker::count(frame, resourceRequest.requestContext());
+
Settings* settings = frame->settings();
FrameLoaderClient* client = frame->loader().client();
SecurityOrigin* securityOrigin = frame->document()->securityOrigin();
« no previous file with comments | « Source/core/loader/MixedContentChecker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698