Commit eefc25d1 authored by weinig@apple.com's avatar weinig@apple.com

Modernize FrameLoader a bit

https://bugs.webkit.org/show_bug.cgi?id=124073

Reviewed by Anders Carlsson.

* loader/FrameLoader.cpp:
* loader/FrameLoader.h:
Use std::unique_ptrs rather than OwnPtrs.

* loader/MixedContentChecker.cpp:
* loader/MixedContentChecker.h:
Switch to hold a Frame& rather than Frame*.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158958 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5cfefe0b
2013-11-08 Sam Weinig <sam@webkit.org>
Modernize FrameLoader a bit
https://bugs.webkit.org/show_bug.cgi?id=124073
Reviewed by Anders Carlsson.
* loader/FrameLoader.cpp:
* loader/FrameLoader.h:
Use std::unique_ptrs rather than OwnPtrs.
* loader/MixedContentChecker.cpp:
* loader/MixedContentChecker.h:
Switch to hold a Frame& rather than Frame*.
2013-11-08 Zan Dobersek <zdobersek@igalia.com>
Remove code guarded with ENABLE(STREAM)
......
......@@ -176,7 +176,12 @@ static bool isDocumentSandboxed(Frame* frame, SandboxFlags mask)
class FrameLoader::FrameProgressTracker {
public:
static PassOwnPtr<FrameProgressTracker> create(Frame& frame) { return adoptPtr(new FrameProgressTracker(frame)); }
explicit FrameProgressTracker(Frame& frame)
: m_frame(frame)
, m_inProgress(false)
{
}
~FrameProgressTracker()
{
ASSERT(!m_inProgress || m_frame.page());
......@@ -201,12 +206,6 @@ public:
}
private:
FrameProgressTracker(Frame& frame)
: m_frame(frame)
, m_inProgress(false)
{
}
Frame& m_frame;
bool m_inProgress;
};
......@@ -214,12 +213,12 @@ private:
FrameLoader::FrameLoader(Frame& frame, FrameLoaderClient& client)
: m_frame(frame)
, m_client(client)
, m_policyChecker(adoptPtr(new PolicyChecker(frame)))
, m_history(adoptPtr(new HistoryController(frame)))
, m_policyChecker(std::make_unique<PolicyChecker>(frame))
, m_history(std::make_unique<HistoryController>(frame))
, m_notifier(frame)
, m_subframeLoader(adoptPtr(new SubframeLoader(frame)))
, m_icon(adoptPtr(new IconController(frame)))
, m_mixedContentChecker(&frame)
, m_subframeLoader(std::make_unique<SubframeLoader>(frame))
, m_icon(std::make_unique<IconController>(frame))
, m_mixedContentChecker(frame)
, m_state(FrameStateProvisional)
, m_loadType(FrameLoadTypeStandard)
, m_delegateIsHandlingProvisionalLoadError(false)
......@@ -235,7 +234,7 @@ FrameLoader::FrameLoader(Frame& frame, FrameLoaderClient& client)
, m_checkTimer(this, &FrameLoader::checkTimerFired)
, m_shouldCallCheckCompleted(false)
, m_shouldCallCheckLoadComplete(false)
, m_opener(0)
, m_opener(nullptr)
, m_didPerformFirstNavigation(false)
, m_loadingFromCachedPage(false)
, m_suppressOpenerInNewFrame(false)
......@@ -246,7 +245,7 @@ FrameLoader::FrameLoader(Frame& frame, FrameLoaderClient& client)
FrameLoader::~FrameLoader()
{
setOpener(0);
setOpener(nullptr);
HashSet<Frame*>::iterator end = m_openedFrames.end();
for (HashSet<Frame*>::iterator it = m_openedFrames.begin(); it != end; ++it)
......@@ -268,7 +267,7 @@ void FrameLoader::init()
m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocument);
m_networkingContext = m_client.createNetworkingContext();
m_progressTracker = FrameProgressTracker::create(m_frame);
m_progressTracker = std::make_unique<FrameProgressTracker>(m_frame);
}
void FrameLoader::setDefersLoading(bool defers)
......@@ -2414,7 +2413,7 @@ void FrameLoader::detachFromParent()
detachViewsAndDocumentLoader();
m_progressTracker.clear();
m_progressTracker = nullptr;
if (Frame* parent = m_frame.tree().parent()) {
parent->loader().closeAndRemoveChild(&m_frame);
......
......@@ -382,19 +382,16 @@ private:
Frame& m_frame;
FrameLoaderClient& m_client;
// FIXME: These should be OwnPtr<T> to reduce build times and simplify
// header dependencies unless performance testing proves otherwise.
// Some of these could be lazily created for memory savings on devices.
const OwnPtr<PolicyChecker> m_policyChecker;
const OwnPtr<HistoryController> m_history;
const std::unique_ptr<PolicyChecker> m_policyChecker;
const std::unique_ptr<HistoryController> m_history;
mutable ResourceLoadNotifier m_notifier;
const OwnPtr<SubframeLoader> m_subframeLoader;
const std::unique_ptr<SubframeLoader> m_subframeLoader;
mutable FrameLoaderStateMachine m_stateMachine;
const OwnPtr<IconController> m_icon;
const std::unique_ptr<IconController> m_icon;
mutable MixedContentChecker m_mixedContentChecker;
class FrameProgressTracker;
OwnPtr<FrameProgressTracker> m_progressTracker;
std::unique_ptr<FrameProgressTracker> m_progressTracker;
FrameState m_state;
FrameLoadType m_loadType;
......
......@@ -43,14 +43,14 @@
namespace WebCore {
MixedContentChecker::MixedContentChecker(Frame* frame)
MixedContentChecker::MixedContentChecker(Frame& frame)
: m_frame(frame)
{
}
FrameLoaderClient& MixedContentChecker::client() const
{
return m_frame->loader().client();
return m_frame.loader().client();
}
// static
......@@ -68,7 +68,7 @@ bool MixedContentChecker::canDisplayInsecureContent(SecurityOrigin* securityOrig
if (!isMixedContent(securityOrigin, url))
return true;
bool allowed = client().allowDisplayingInsecureContent(m_frame->settings().allowDisplayOfInsecureContent(), securityOrigin, url);
bool allowed = client().allowDisplayingInsecureContent(m_frame.settings().allowDisplayOfInsecureContent(), securityOrigin, url);
logWarning(allowed, "displayed", url);
if (allowed)
......@@ -82,7 +82,7 @@ bool MixedContentChecker::canRunInsecureContent(SecurityOrigin* securityOrigin,
if (!isMixedContent(securityOrigin, url))
return true;
bool allowed = client().allowRunningInsecureContent(m_frame->settings().allowRunningOfInsecureContent(), securityOrigin, url);
bool allowed = client().allowRunningInsecureContent(m_frame.settings().allowRunningOfInsecureContent(), securityOrigin, url);
logWarning(allowed, "ran", url);
if (allowed)
......@@ -93,8 +93,8 @@ bool MixedContentChecker::canRunInsecureContent(SecurityOrigin* securityOrigin,
void MixedContentChecker::logWarning(bool allowed, const String& action, const URL& target) const
{
String message = makeString((allowed ? "" : "[blocked] "), "The page at ", m_frame->document()->url().stringCenterEllipsizedToLength(), " ", action, " insecure content from ", target.stringCenterEllipsizedToLength(), ".\n");
m_frame->document()->addConsoleMessage(SecurityMessageSource, WarningMessageLevel, message);
String message = makeString((allowed ? "" : "[blocked] "), "The page at ", m_frame.document()->url().stringCenterEllipsizedToLength(), " ", action, " insecure content from ", target.stringCenterEllipsizedToLength(), ".\n");
m_frame.document()->addConsoleMessage(SecurityMessageSource, WarningMessageLevel, message);
}
} // namespace WebCore
......@@ -44,7 +44,7 @@ class SecurityOrigin;
class MixedContentChecker {
WTF_MAKE_NONCOPYABLE(MixedContentChecker);
public:
MixedContentChecker(Frame*);
MixedContentChecker(Frame&);
bool canDisplayInsecureContent(SecurityOrigin*, const URL&) const;
bool canRunInsecureContent(SecurityOrigin*, const URL&) const;
......@@ -56,7 +56,7 @@ private:
void logWarning(bool allowed, const String& action, const URL&) const;
Frame* m_frame;
Frame& m_frame;
};
} // namespace WebCore
......
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