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

Unified Diff: third_party/WebKit/Source/core/loader/FrameFetchContext.cpp

Issue 2844913002: Drop GetFrame()->GetDocument() usage in FrameFetchContext (Closed)
Patch Set: Fix last crash 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
diff --git a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
index 2fb04743ce69654b9d7eb7c61ada4a633477fdfb..a107f503a93e64b4d77bdbf54636bf5870532e07 100644
--- a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
+++ b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
@@ -353,9 +353,9 @@ void FrameFetchContext::DispatchDidReceiveResponse(
resource_loading_policy = LinkLoader::kDoNotLoadResources;
}
LinkLoader::LoadLinksFromHeader(
- response.HttpHeaderField(HTTPNames::Link), response.Url(),
- GetFrame()->GetDocument(), NetworkHintsInterfaceImpl(),
- resource_loading_policy, LinkLoader::kLoadAll, nullptr);
+ response.HttpHeaderField(HTTPNames::Link), response.Url(), *GetFrame(),
+ GetDocument(), NetworkHintsInterfaceImpl(), resource_loading_policy,
+ LinkLoader::kLoadAll, nullptr);
if (response.HasMajorCertificateErrors()) {
MixedContentChecker::HandleCertificateError(GetFrame(), response,
@@ -570,10 +570,15 @@ void FrameFetchContext::AddConsoleMessage(const String& message,
LogMessageType message_type) const {
MessageLevel level = message_type == kLogWarningMessage ? kWarningMessageLevel
: kErrorMessageLevel;
- if (GetFrame()->GetDocument()) {
- GetFrame()->GetDocument()->AddConsoleMessage(
- ConsoleMessage::Create(kJSMessageSource, level, message));
- }
+ ConsoleMessage* console_message =
+ ConsoleMessage::Create(kJSMessageSource, level, message);
+ // Route the console message through Document if it's attached, so
+ // that script line numbers can be included. Otherwise, route directly to the
+ // FrameConsole, to ensure we never drop a message.
+ if (GetDocument() && GetDocument()->GetFrame())
+ GetDocument()->AddConsoleMessage(console_message);
+ else
+ GetFrame()->Console().AddMessage(console_message);
}
void FrameFetchContext::ModifyRequestForCSP(ResourceRequest& resource_request) {
@@ -717,9 +722,10 @@ SubresourceFilter* FrameFetchContext::GetSubresourceFilter() const {
return document_loader ? document_loader->GetSubresourceFilter() : nullptr;
}
-SecurityContext* FrameFetchContext::GetMainResourceSecurityContext() const {
- DCHECK(GetFrame()->GetDocument());
- return GetFrame()->GetDocument();
+SecurityContext* FrameFetchContext::GetParentSecurityContext() const {
+ if (Frame* parent = GetFrame()->Tree().Parent())
+ return parent->GetSecurityContext();
+ return nullptr;
}
bool FrameFetchContext::ShouldBlockRequestByInspector(
@@ -751,11 +757,11 @@ bool FrameFetchContext::IsSVGImageChromeClient() const {
}
void FrameFetchContext::CountUsage(UseCounter::Feature feature) const {
- UseCounter::Count(GetFrame()->GetDocument(), feature);
+ UseCounter::Count(GetFrame(), feature);
}
void FrameFetchContext::CountDeprecation(UseCounter::Feature feature) const {
- Deprecation::CountDeprecation(GetFrame()->GetDocument(), feature);
+ Deprecation::CountDeprecation(GetFrame(), feature);
}
bool FrameFetchContext::ShouldBlockFetchByMixedContentCheck(

Powered by Google App Engine
This is Rietveld 408576698