summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/PageLoadState.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/UIProcess/PageLoadState.cpp')
-rw-r--r--Source/WebKit2/UIProcess/PageLoadState.cpp114
1 files changed, 100 insertions, 14 deletions
diff --git a/Source/WebKit2/UIProcess/PageLoadState.cpp b/Source/WebKit2/UIProcess/PageLoadState.cpp
index d4044165c..dd9d4c7d9 100644
--- a/Source/WebKit2/UIProcess/PageLoadState.cpp
+++ b/Source/WebKit2/UIProcess/PageLoadState.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,13 +26,16 @@
#include "config.h"
#include "PageLoadState.h"
+#include "WebPageProxy.h"
+
namespace WebKit {
// Progress always starts at this value. This helps provide feedback as soon as a load starts.
static const double initialProgressValue = 0.1;
-PageLoadState::PageLoadState()
- : m_mayHaveUncommittedChanges(false)
+PageLoadState::PageLoadState(WebPageProxy& webPageProxy)
+ : m_webPageProxy(webPageProxy)
+ , m_mayHaveUncommittedChanges(false)
, m_outstandingTransactionCount(0)
{
}
@@ -42,6 +45,26 @@ PageLoadState::~PageLoadState()
ASSERT(m_observers.isEmpty());
}
+PageLoadState::Transaction::Transaction(PageLoadState& pageLoadState)
+ : m_webPageProxy(&pageLoadState.m_webPageProxy)
+ , m_pageLoadState(&pageLoadState)
+{
+ m_pageLoadState->beginTransaction();
+}
+
+PageLoadState::Transaction::Transaction(Transaction&& other)
+ : m_webPageProxy(WTFMove(other.m_webPageProxy))
+ , m_pageLoadState(other.m_pageLoadState)
+{
+ other.m_pageLoadState = nullptr;
+}
+
+PageLoadState::Transaction::~Transaction()
+{
+ if (m_pageLoadState)
+ m_pageLoadState->endTransaction();
+}
+
void PageLoadState::addObserver(Observer& observer)
{
ASSERT(!m_observers.contains(&observer));
@@ -51,10 +74,8 @@ void PageLoadState::addObserver(Observer& observer)
void PageLoadState::removeObserver(Observer& observer)
{
- ASSERT(m_observers.contains(&observer));
-
- size_t index = m_observers.find(&observer);
- m_observers.remove(index);
+ bool removed = m_observers.removeFirst(&observer);
+ ASSERT_UNUSED(removed, removed);
}
void PageLoadState::endTransaction()
@@ -72,12 +93,20 @@ void PageLoadState::commitChanges()
m_mayHaveUncommittedChanges = false;
+ bool canGoBackChanged = m_committedState.canGoBack != m_uncommittedState.canGoBack;
+ bool canGoForwardChanged = m_committedState.canGoForward != m_uncommittedState.canGoForward;
bool titleChanged = m_committedState.title != m_uncommittedState.title;
- bool isLoadingChanged = isLoadingState(m_committedState.state) != isLoadingState(m_uncommittedState.state);
+ bool isLoadingChanged = isLoading(m_committedState) != isLoading(m_uncommittedState);
bool activeURLChanged = activeURL(m_committedState) != activeURL(m_uncommittedState);
bool hasOnlySecureContentChanged = hasOnlySecureContent(m_committedState) != hasOnlySecureContent(m_uncommittedState);
bool estimatedProgressChanged = estimatedProgress(m_committedState) != estimatedProgress(m_uncommittedState);
+ bool networkRequestsInProgressChanged = m_committedState.networkRequestsInProgress != m_uncommittedState.networkRequestsInProgress;
+ bool certificateInfoChanged = m_committedState.certificateInfo != m_uncommittedState.certificateInfo;
+ if (canGoBackChanged)
+ callObserverCallback(&Observer::willChangeCanGoBack);
+ if (canGoForwardChanged)
+ callObserverCallback(&Observer::willChangeCanGoForward);
if (titleChanged)
callObserverCallback(&Observer::willChangeTitle);
if (isLoadingChanged)
@@ -88,10 +117,20 @@ void PageLoadState::commitChanges()
callObserverCallback(&Observer::willChangeHasOnlySecureContent);
if (estimatedProgressChanged)
callObserverCallback(&Observer::willChangeEstimatedProgress);
+ if (networkRequestsInProgressChanged)
+ callObserverCallback(&Observer::willChangeNetworkRequestsInProgress);
+ if (certificateInfoChanged)
+ callObserverCallback(&Observer::willChangeCertificateInfo);
m_committedState = m_uncommittedState;
+ m_webPageProxy.isLoadingChanged();
+
// The "did" ordering is the reverse of the "will". This is a requirement of Cocoa Key-Value Observing.
+ if (certificateInfoChanged)
+ callObserverCallback(&Observer::didChangeCertificateInfo);
+ if (networkRequestsInProgressChanged)
+ callObserverCallback(&Observer::didChangeNetworkRequestsInProgress);
if (estimatedProgressChanged)
callObserverCallback(&Observer::didChangeEstimatedProgress);
if (hasOnlySecureContentChanged)
@@ -102,6 +141,10 @@ void PageLoadState::commitChanges()
callObserverCallback(&Observer::didChangeIsLoading);
if (titleChanged)
callObserverCallback(&Observer::didChangeTitle);
+ if (canGoForwardChanged)
+ callObserverCallback(&Observer::didChangeCanGoForward);
+ if (canGoBackChanged)
+ callObserverCallback(&Observer::didChangeCanGoBack);
}
void PageLoadState::reset(const Transaction::Token& token)
@@ -121,11 +164,12 @@ void PageLoadState::reset(const Transaction::Token& token)
m_uncommittedState.title = String();
m_uncommittedState.estimatedProgress = 0;
+ m_uncommittedState.networkRequestsInProgress = false;
}
bool PageLoadState::isLoading() const
{
- return isLoadingState(m_committedState.state);
+ return isLoading(m_committedState);
}
String PageLoadState::activeURL(const Data& data)
@@ -161,7 +205,7 @@ bool PageLoadState::hasOnlySecureContent(const Data& data)
if (data.hasInsecureContent)
return false;
- return data.url.startsWith("https:", false);
+ return WebCore::protocolIs(data.url, "https");
}
bool PageLoadState::hasOnlySecureContent() const
@@ -230,13 +274,14 @@ void PageLoadState::didFailProvisionalLoad(const Transaction::Token& token)
m_uncommittedState.unreachableURL = m_lastUnreachableURL;
}
-void PageLoadState::didCommitLoad(const Transaction::Token& token)
+void PageLoadState::didCommitLoad(const Transaction::Token& token, WebCertificateInfo& certificateInfo, bool hasInsecureContent)
{
ASSERT_UNUSED(token, &token.m_pageLoadState == this);
ASSERT(m_uncommittedState.state == State::Provisional);
m_uncommittedState.state = State::Committed;
- m_uncommittedState.hasInsecureContent = false;
+ m_uncommittedState.hasInsecureContent = hasInsecureContent;
+ m_uncommittedState.certificateInfo = &certificateInfo;
m_uncommittedState.url = m_uncommittedState.provisionalURL;
m_uncommittedState.provisionalURL = String();
@@ -295,6 +340,28 @@ void PageLoadState::setTitle(const Transaction::Token& token, const String& titl
m_uncommittedState.title = title;
}
+bool PageLoadState::canGoBack() const
+{
+ return m_committedState.canGoBack;
+}
+
+void PageLoadState::setCanGoBack(const Transaction::Token& token, bool canGoBack)
+{
+ ASSERT_UNUSED(token, &token.m_pageLoadState == this);
+ m_uncommittedState.canGoBack = canGoBack;
+}
+
+bool PageLoadState::canGoForward() const
+{
+ return m_committedState.canGoForward;
+}
+
+void PageLoadState::setCanGoForward(const Transaction::Token& token, bool canGoForward)
+{
+ ASSERT_UNUSED(token, &token.m_pageLoadState == this);
+ m_uncommittedState.canGoForward = canGoForward;
+}
+
void PageLoadState::didStartProgress(const Transaction::Token& token)
{
ASSERT_UNUSED(token, &token.m_pageLoadState == this);
@@ -313,9 +380,18 @@ void PageLoadState::didFinishProgress(const Transaction::Token& token)
m_uncommittedState.estimatedProgress = 1;
}
-bool PageLoadState::isLoadingState(State state)
+void PageLoadState::setNetworkRequestsInProgress(const Transaction::Token& token, bool networkRequestsInProgress)
+{
+ ASSERT_UNUSED(token, &token.m_pageLoadState == this);
+ m_uncommittedState.networkRequestsInProgress = networkRequestsInProgress;
+}
+
+bool PageLoadState::isLoading(const Data& data)
{
- switch (state) {
+ if (!data.pendingAPIRequestURL.isNull())
+ return true;
+
+ switch (data.state) {
case State::Provisional:
case State::Committed:
return true;
@@ -328,6 +404,16 @@ bool PageLoadState::isLoadingState(State state)
return false;
}
+void PageLoadState::willChangeProcessIsResponsive()
+{
+ callObserverCallback(&Observer::willChangeWebProcessIsResponsive);
+}
+
+void PageLoadState::didChangeProcessIsResponsive()
+{
+ callObserverCallback(&Observer::didChangeWebProcessIsResponsive);
+}
+
void PageLoadState::callObserverCallback(void (Observer::*callback)())
{
for (auto* observer : m_observers)