blob: a5af33456b0126d67ddf629da67e9e339618e04c [file] [log] [blame]
/*
* Copyright (C) 2006-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "FrameLoaderTypes.h"
#include "ResourceRequest.h"
#include "UserGestureIndicator.h"
#include <wtf/Forward.h>
namespace WebCore {
class Document;
class Event;
class NavigationAction {
public:
NavigationAction();
WEBCORE_EXPORT NavigationAction(Document&, const ResourceRequest&, InitiatedByMainFrame, NavigationType = NavigationType::Other, ShouldOpenExternalURLsPolicy = ShouldOpenExternalURLsPolicy::ShouldNotAllow, Event* = nullptr, const AtomicString& downloadAttribute = nullAtom());
NavigationAction(Document&, const ResourceRequest&, InitiatedByMainFrame, FrameLoadType, bool isFormSubmission, Event* = nullptr, ShouldOpenExternalURLsPolicy = ShouldOpenExternalURLsPolicy::ShouldNotAllow, const AtomicString& downloadAttribute = nullAtom());
WEBCORE_EXPORT ~NavigationAction();
WEBCORE_EXPORT NavigationAction(const NavigationAction&);
NavigationAction& operator=(const NavigationAction&);
NavigationAction(NavigationAction&&);
NavigationAction& operator=(NavigationAction&&);
NavigationAction copyWithShouldOpenExternalURLsPolicy(ShouldOpenExternalURLsPolicy) const;
bool isEmpty() const { return !m_sourceDocument || m_resourceRequest.url().isEmpty(); }
URL url() const { return m_resourceRequest.url(); }
const ResourceRequest& resourceRequest() const { return m_resourceRequest; }
NavigationType type() const { return m_type; }
const Event* event() const { return m_event.get(); }
const Document* sourceDocument() const { return m_sourceDocument.get(); }
bool processingUserGesture() const { return m_userGestureToken ? m_userGestureToken->processingUserGesture() : false; }
RefPtr<UserGestureToken> userGestureToken() const { return m_userGestureToken; }
ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy() const { return m_shouldOpenExternalURLsPolicy; }
InitiatedByMainFrame initiatedByMainFrame() const { return m_initiatedByMainFrame; }
const AtomicString& downloadAttribute() const { return m_downloadAttribute; }
bool treatAsSameOriginNavigation() const { return m_treatAsSameOriginNavigation; }
void setIsCrossOriginWindowOpenNavigation(bool value) { m_isCrossOriginWindowOpenNavigation = value; }
bool isCrossOriginWindowOpenNavigation() const { return m_isCrossOriginWindowOpenNavigation; }
void setOpener(std::optional<std::pair<uint64_t, uint64_t>>&& opener) { m_opener = WTFMove(opener); }
const std::optional<std::pair<uint64_t, uint64_t>>& opener() const { return m_opener; }
private:
RefPtr<Document> m_sourceDocument;
ResourceRequest m_resourceRequest;
NavigationType m_type;
ShouldOpenExternalURLsPolicy m_shouldOpenExternalURLsPolicy;
InitiatedByMainFrame m_initiatedByMainFrame;
RefPtr<Event> m_event;
RefPtr<UserGestureToken> m_userGestureToken { UserGestureIndicator::currentUserGesture() };
AtomicString m_downloadAttribute;
bool m_treatAsSameOriginNavigation;
bool m_isCrossOriginWindowOpenNavigation { false };
std::optional<std::pair<uint64_t /* pageID */, uint64_t /* frameID */>> m_opener;
};
} // namespace WebCore