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

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

Issue 339593005: Set the target type when creating the request for main resource (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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 reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2009. All rights reserved.
7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> 7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com>
8 * Copyright (C) 2011 Google Inc. All rights reserved. 8 * Copyright (C) 2011 Google Inc. All rights reserved.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 762
763 void FrameLoader::reportLocalLoadFailed(LocalFrame* frame, const String& url) 763 void FrameLoader::reportLocalLoadFailed(LocalFrame* frame, const String& url)
764 { 764 {
765 ASSERT(!url.isEmpty()); 765 ASSERT(!url.isEmpty());
766 if (!frame) 766 if (!frame)
767 return; 767 return;
768 768
769 frame->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLeve l, "Not allowed to load local resource: " + url); 769 frame->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLeve l, "Not allowed to load local resource: " + url);
770 } 770 }
771 771
772 static ResourceRequest requestFromHistoryItem(HistoryItem* item, ResourceRequest CachePolicy cachePolicy) 772 static ResourceRequest requestFromHistoryItem(HistoryItem* item, ResourceRequest CachePolicy cachePolicy, Frame* frame)
773 { 773 {
774 RefPtr<FormData> formData = item->formData(); 774 RefPtr<FormData> formData = item->formData();
775 ResourceRequest request(item->url(), item->referrer()); 775 ResourceRequest request(item->url(), item->referrer());
776 request.initializeForMainResource(frame->isMainFrame());
776 request.setCachePolicy(cachePolicy); 777 request.setCachePolicy(cachePolicy);
777 if (formData) { 778 if (formData) {
778 request.setHTTPMethod("POST"); 779 request.setHTTPMethod("POST");
779 request.setHTTPBody(formData); 780 request.setHTTPBody(formData);
780 request.setHTTPContentType(item->formContentType()); 781 request.setHTTPContentType(item->formContentType());
781 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString (item->referrer().referrer); 782 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString (item->referrer().referrer);
782 FrameLoader::addHTTPOriginIfNeeded(request, securityOrigin->toAtomicStri ng()); 783 FrameLoader::addHTTPOriginIfNeeded(request, securityOrigin->toAtomicStri ng());
783 } 784 }
784 return request; 785 return request;
785 } 786 }
786 787
787 void FrameLoader::reload(ReloadPolicy reloadPolicy, const KURL& overrideURL, con st AtomicString& overrideEncoding) 788 void FrameLoader::reload(ReloadPolicy reloadPolicy, const KURL& overrideURL, con st AtomicString& overrideEncoding)
788 { 789 {
789 if (!m_currentItem) 790 if (!m_currentItem)
790 return; 791 return;
791 792
792 ResourceRequestCachePolicy cachePolicy = reloadPolicy == EndToEndReload ? Re loadBypassingCache : ReloadIgnoringCacheData; 793 ResourceRequestCachePolicy cachePolicy = reloadPolicy == EndToEndReload ? Re loadBypassingCache : ReloadIgnoringCacheData;
793 ResourceRequest request = requestFromHistoryItem(m_currentItem.get(), cacheP olicy); 794 ResourceRequest request = requestFromHistoryItem(m_currentItem.get(), cacheP olicy, m_frame);
795 request.initializeForMainResource(m_frame->isMainFrame());
794 if (!overrideURL.isEmpty()) { 796 if (!overrideURL.isEmpty()) {
795 request.setURL(overrideURL); 797 request.setURL(overrideURL);
796 request.clearHTTPReferrer(); 798 request.clearHTTPReferrer();
797 } 799 }
798 800
799 FrameLoadType type = reloadPolicy == EndToEndReload ? FrameLoadTypeReloadFro mOrigin : FrameLoadTypeReload; 801 FrameLoadType type = reloadPolicy == EndToEndReload ? FrameLoadTypeReloadFro mOrigin : FrameLoadTypeReload;
800 loadWithNavigationAction(NavigationAction(request, type), type, nullptr, Sub stituteData(), NotClientRedirect, overrideEncoding); 802 loadWithNavigationAction(NavigationAction(request, type), type, nullptr, Sub stituteData(), NotClientRedirect, overrideEncoding);
801 } 803 }
802 804
803 void FrameLoader::stopAllLoaders() 805 void FrameLoader::stopAllLoaders()
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 return; 1433 return;
1432 } 1434 }
1433 1435
1434 m_provisionalItem = item; 1436 m_provisionalItem = item;
1435 if (historyLoadType == HistorySameDocumentLoad) { 1437 if (historyLoadType == HistorySameDocumentLoad) {
1436 m_loadType = FrameLoadTypeBackForward; 1438 m_loadType = FrameLoadTypeBackForward;
1437 loadInSameDocument(item->url(), item->stateObject(), FrameLoadTypeBackFo rward, NotClientRedirect); 1439 loadInSameDocument(item->url(), item->stateObject(), FrameLoadTypeBackFo rward, NotClientRedirect);
1438 restoreScrollPositionAndViewState(); 1440 restoreScrollPositionAndViewState();
1439 return; 1441 return;
1440 } 1442 }
1441 loadWithNavigationAction(NavigationAction(requestFromHistoryItem(item, cache Policy), FrameLoadTypeBackForward), FrameLoadTypeBackForward, nullptr, Substitut eData()); 1443 loadWithNavigationAction(NavigationAction(requestFromHistoryItem(item, cache Policy, m_frame), FrameLoadTypeBackForward), FrameLoadTypeBackForward, nullptr, SubstituteData());
1442 } 1444 }
1443 1445
1444 void FrameLoader::dispatchDocumentElementAvailable() 1446 void FrameLoader::dispatchDocumentElementAvailable()
1445 { 1447 {
1446 client()->documentElementAvailable(); 1448 client()->documentElementAvailable();
1447 } 1449 }
1448 1450
1449 void FrameLoader::dispatchDidClearDocumentOfWindowObject() 1451 void FrameLoader::dispatchDidClearDocumentOfWindowObject()
1450 { 1452 {
1451 if (!m_frame->script().canExecuteScripts(NotAboutToExecuteScript)) 1453 if (!m_frame->script().canExecuteScripts(NotAboutToExecuteScript))
(...skipping 22 matching lines...) Expand all
1474 // FIXME: We need a way to propagate sandbox flags to out-of-process frames. 1476 // FIXME: We need a way to propagate sandbox flags to out-of-process frames.
1475 Frame* parentFrame = m_frame->tree().parent(); 1477 Frame* parentFrame = m_frame->tree().parent();
1476 if (parentFrame && parentFrame->isLocalFrame()) 1478 if (parentFrame && parentFrame->isLocalFrame())
1477 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags(); 1479 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags();
1478 if (FrameOwner* frameOwner = m_frame->owner()) 1480 if (FrameOwner* frameOwner = m_frame->owner())
1479 flags |= frameOwner->sandboxFlags(); 1481 flags |= frameOwner->sandboxFlags();
1480 return flags; 1482 return flags;
1481 } 1483 }
1482 1484
1483 } // namespace WebCore 1485 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698