Commit 77eb2269 authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

OnionSoup: Remove all uses of UseCounter::Count(const LocalFrame*) in blink/renderer/core/frame

According to the plan to replace |const LocalFrame*| arguement with |const Document&|,
|ExecutionContext*|, or |DocumentLoader*| in UseCounter::Count(), this CL
replaces all uses of UseCounter::Count(const LocalFrame*) with
UseCounter::Count(const Document&) in frame directory.

Bug: 936187
Change-Id: I41f03b9908258881d4a1d932defb7e42e2deae9a
Reviewed-on: https://chromium-review.googlesource.com/c/1491060Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Cr-Commit-Position: refs/heads/master@{#636659}
parent 30351787
......@@ -467,17 +467,17 @@ void DOMWindow::DoPostMessage(scoped_refptr<SerializedScriptValue> message,
->ToString());
if (MixedContentChecker::IsMixedContent(source_document->GetSecurityOrigin(),
target_url)) {
UseCounter::Count(source->GetFrame(),
UseCounter::Count(source_document,
WebFeature::kPostMessageFromSecureToInsecure);
} else if (MixedContentChecker::IsMixedContent(
GetFrame()->GetSecurityContext()->GetSecurityOrigin(),
source_document->Url())) {
UseCounter::Count(source->GetFrame(),
UseCounter::Count(source_document,
WebFeature::kPostMessageFromInsecureToSecure);
if (MixedContentChecker::IsMixedContent(
GetFrame()->Tree().Top().GetSecurityContext()->GetSecurityOrigin(),
source_document->Url())) {
UseCounter::Count(source->GetFrame(),
UseCounter::Count(source_document,
WebFeature::kPostMessageFromInsecureToSecureToplevel);
}
}
......@@ -486,7 +486,7 @@ void DOMWindow::DoPostMessage(scoped_refptr<SerializedScriptValue> message,
target_url, RedirectStatus::kNoRedirect,
SecurityViolationReportingPolicy::kSuppressReporting)) {
UseCounter::Count(
source->GetFrame(),
source_document,
WebFeature::kPostMessageOutgoingWouldBeBlockedByConnectSrc);
}
UserActivation* user_activation = nullptr;
......
......@@ -1028,9 +1028,10 @@ bool LocalFrame::CanNavigate(const Frame& target_frame,
// Top navigation in sandbox with or w/o 'allow-top-navigation'.
if (target_frame != this && sandboxed && target_frame == Tree().Top()) {
UseCounter::Count(this, WebFeature::kTopNavInSandbox);
UseCounter::Count(GetDocument(), WebFeature::kTopNavInSandbox);
if (!has_user_gesture) {
UseCounter::Count(this, WebFeature::kTopNavInSandboxWithoutGesture);
UseCounter::Count(GetDocument(),
WebFeature::kTopNavInSandboxWithoutGesture);
}
}
......@@ -1051,11 +1052,11 @@ bool LocalFrame::CanNavigate(const Frame& target_frame,
if (IsAdSubframe())
framebust_params |= kAdBit;
UseCounter::Count(this, WebFeature::kTopNavigationFromSubFrame);
UseCounter::Count(GetDocument(), WebFeature::kTopNavigationFromSubFrame);
if (sandboxed) { // Sandboxed with 'allow-top-navigation'.
UseCounter::Count(this, WebFeature::kTopNavInSandboxWithPerm);
UseCounter::Count(GetDocument(), WebFeature::kTopNavInSandboxWithPerm);
if (!has_user_gesture) {
UseCounter::Count(this,
UseCounter::Count(GetDocument(),
WebFeature::kTopNavInSandboxWithPermButNoGesture);
}
}
......@@ -1131,7 +1132,8 @@ bool LocalFrame::CanNavigate(const Frame& target_frame,
!HasTransientUserActivation(this, false /* check_if_main_thread */) &&
!target_frame.GetSecurityContext()->GetSecurityOrigin()->CanAccess(
SecurityOrigin::Create(destination_url).get())) {
UseCounter::Count(this, WebFeature::kOpenerNavigationWithoutGesture);
UseCounter::Count(GetDocument(),
WebFeature::kOpenerNavigationWithoutGesture);
}
if (!is_allowed_navigation && !error_reason.IsNull())
......
......@@ -187,11 +187,11 @@ void LogCursorSizeCounter(LocalFrame* frame, const Cursor& cursor) {
IntSize scaled_size = image->Size();
scaled_size.Scale(1 / cursor.ImageScaleFactor());
if (scaled_size.Width() > 64 || scaled_size.Height() > 64) {
UseCounter::Count(frame, WebFeature::kCursorImageGT64x64);
UseCounter::Count(frame->GetDocument(), WebFeature::kCursorImageGT64x64);
} else if (scaled_size.Width() > 32 || scaled_size.Height() > 32) {
UseCounter::Count(frame, WebFeature::kCursorImageGT32x32);
UseCounter::Count(frame->GetDocument(), WebFeature::kCursorImageGT32x32);
} else {
UseCounter::Count(frame, WebFeature::kCursorImageLE32x32);
UseCounter::Count(frame->GetDocument(), WebFeature::kCursorImageLE32x32);
}
}
......
......@@ -1320,7 +1320,7 @@ void UseCounter::CountIfFeatureWouldBeBlockedByFeaturePolicy(
if (!frame.GetSecurityContext()->GetSecurityOrigin()->CanAccess(topOrigin)) {
// This frame is cross-origin with the top-level frame, and so would be
// blocked without a feature policy.
UseCounter::Count(&frame, blocked_cross_origin);
UseCounter::Count(frame.GetDocument(), blocked_cross_origin);
return;
}
......@@ -1330,7 +1330,7 @@ void UseCounter::CountIfFeatureWouldBeBlockedByFeaturePolicy(
const Frame* f = &frame;
while (!f->IsMainFrame()) {
if (!f->GetSecurityContext()->GetSecurityOrigin()->CanAccess(topOrigin)) {
UseCounter::Count(&frame, blocked_same_origin);
UseCounter::Count(frame.GetDocument(), blocked_same_origin);
return;
}
f = f->Tree().Parent();
......
......@@ -2216,7 +2216,8 @@ void WebLocalFrameImpl::BlinkFeatureUsageReport(const std::set<int>& features) {
DCHECK(!features.empty());
// Assimilate all features used/performed by the browser into UseCounter.
for (int feature : features) {
UseCounter::Count(GetFrame(), static_cast<WebFeature>(feature));
UseCounter::Count(GetFrame()->GetDocument(),
static_cast<WebFeature>(feature));
}
}
......@@ -2272,11 +2273,13 @@ void WebLocalFrameImpl::SendOrientationChangeEvent() {
}
void WebLocalFrameImpl::DidCallAddSearchProvider() {
UseCounter::Count(GetFrame(), WebFeature::kExternalAddSearchProvider);
UseCounter::Count(GetFrame()->GetDocument(),
WebFeature::kExternalAddSearchProvider);
}
void WebLocalFrameImpl::DidCallIsSearchProviderInstalled() {
UseCounter::Count(GetFrame(), WebFeature::kExternalIsSearchProviderInstalled);
UseCounter::Count(GetFrame()->GetDocument(),
WebFeature::kExternalIsSearchProviderInstalled);
}
void WebLocalFrameImpl::DispatchMessageEventWithOriginCheck(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment