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

Side by Side Diff: third_party/WebKit/Source/core/loader/FrameLoader.cpp

Issue 2842253002: Move ReportLocalLoadFailed to ExecutionContext (Closed)
Patch Set: Revert ResourceLoader changes, handle main resource redirect in DocumentLoader Created 3 years, 6 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 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
6 * (http://www.torchmobile.com/) 6 * (http://www.torchmobile.com/)
7 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 7 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
8 * Copyright (C) Research In Motion Limited 2009. All rights reserved. 8 * Copyright (C) Research In Motion Limited 2009. All rights reserved.
9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> 9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com>
10 * Copyright (C) 2011 Google Inc. All rights reserved. 10 * Copyright (C) 2011 Google Inc. All rights reserved.
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 // If no origin Document* was specified, skip remaining security checks and 669 // If no origin Document* was specified, skip remaining security checks and
670 // assume the caller has fully initialized the FrameLoadRequest. 670 // assume the caller has fully initialized the FrameLoadRequest.
671 if (!request.OriginDocument()) 671 if (!request.OriginDocument())
672 return true; 672 return true;
673 673
674 KURL url = request.GetResourceRequest().Url(); 674 KURL url = request.GetResourceRequest().Url();
675 if (frame_->GetScriptController().ExecuteScriptIfJavaScriptURL(url, nullptr)) 675 if (frame_->GetScriptController().ExecuteScriptIfJavaScriptURL(url, nullptr))
676 return false; 676 return false;
677 677
678 if (!request.OriginDocument()->GetSecurityOrigin()->CanDisplay(url)) { 678 if (!request.OriginDocument()->GetSecurityOrigin()->CanDisplay(url)) {
679 ReportLocalLoadFailed(frame_, url.ElidedString()); 679 request.OriginDocument()->AddConsoleMessage(ConsoleMessage::Create(
680 kSecurityMessageSource, kErrorMessageLevel,
681 "Not allowed to load local resource: " + url.ElidedString()));
680 return false; 682 return false;
681 } 683 }
682 684
683 // Block renderer-initiated loads of data URLs in the top frame. If the mime 685 // Block renderer-initiated loads of data URLs in the top frame. If the mime
684 // type of the data URL is supported, the URL will eventually be rendered, so 686 // type of the data URL is supported, the URL will eventually be rendered, so
685 // block it here. Otherwise, the load might be handled by a plugin or end up 687 // block it here. Otherwise, the load might be handled by a plugin or end up
686 // as a download, so allow it to let the embedder figure out what to do with 688 // as a download, so allow it to let the embedder figure out what to do with
687 // it. 689 // it.
688 if (frame_->IsMainFrame() && 690 if (frame_->IsMainFrame() &&
689 !request.GetResourceRequest().IsSameDocumentNavigation() && 691 !request.GetResourceRequest().IsSameDocumentNavigation() &&
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 if (!ShouldTreatURLAsSrcdocDocument(url)) 914 if (!ShouldTreatURLAsSrcdocDocument(url))
913 return SubstituteData(); 915 return SubstituteData();
914 String srcdoc = frame_->DeprecatedLocalOwner()->FastGetAttribute(srcdocAttr); 916 String srcdoc = frame_->DeprecatedLocalOwner()->FastGetAttribute(srcdocAttr);
915 DCHECK(!srcdoc.IsNull()); 917 DCHECK(!srcdoc.IsNull());
916 CString encoded_srcdoc = srcdoc.Utf8(); 918 CString encoded_srcdoc = srcdoc.Utf8();
917 return SubstituteData( 919 return SubstituteData(
918 SharedBuffer::Create(encoded_srcdoc.data(), encoded_srcdoc.length()), 920 SharedBuffer::Create(encoded_srcdoc.data(), encoded_srcdoc.length()),
919 "text/html", "UTF-8", KURL()); 921 "text/html", "UTF-8", KURL());
920 } 922 }
921 923
922 void FrameLoader::ReportLocalLoadFailed(LocalFrame* frame, const String& url) {
923 DCHECK(!url.IsEmpty());
924 if (!frame)
925 return;
926
927 frame->GetDocument()->AddConsoleMessage(
928 ConsoleMessage::Create(kSecurityMessageSource, kErrorMessageLevel,
929 "Not allowed to load local resource: " + url));
930 }
931
932 void FrameLoader::StopAllLoaders() { 924 void FrameLoader::StopAllLoaders() {
933 if (frame_->GetDocument()->PageDismissalEventBeingDispatched() != 925 if (frame_->GetDocument()->PageDismissalEventBeingDispatched() !=
934 Document::kNoDismissal) 926 Document::kNoDismissal)
935 return; 927 return;
936 928
937 // If this method is called from within this method, infinite recursion can 929 // If this method is called from within this method, infinite recursion can
938 // occur (3442218). Avoid this. 930 // occur (3442218). Avoid this.
939 if (in_stop_all_loaders_) 931 if (in_stop_all_loaders_)
940 return; 932 return;
941 933
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 // TODO(japhet): This is needed because the browser process DCHECKs if the 1702 // TODO(japhet): This is needed because the browser process DCHECKs if the
1711 // first entry we commit in a new frame has replacement set. It's unclear 1703 // first entry we commit in a new frame has replacement set. It's unclear
1712 // whether the DCHECK is right, investigate removing this special case. 1704 // whether the DCHECK is right, investigate removing this special case.
1713 bool replace_current_item = load_type == kFrameLoadTypeReplaceCurrentItem && 1705 bool replace_current_item = load_type == kFrameLoadTypeReplaceCurrentItem &&
1714 (!Opener() || !request.Url().IsEmpty()); 1706 (!Opener() || !request.Url().IsEmpty());
1715 loader->SetReplacesCurrentHistoryItem(replace_current_item); 1707 loader->SetReplacesCurrentHistoryItem(replace_current_item);
1716 return loader; 1708 return loader;
1717 } 1709 }
1718 1710
1719 } // namespace blink 1711 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/FrameLoader.h ('k') | third_party/WebKit/Source/core/loader/PingLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698