haikuwebkit/Source/WebCore/page/NavigatorIsLoggedIn.h

58 lines
2.1 KiB
C
Raw Permalink Normal View History

IsLoggedIn: Add as experimental feature https://bugs.webkit.org/show_bug.cgi?id=202707 <rdar://problem/56095064> Reviewed by Brent Fulgham and Chris Dumez. IsLoggedIn was proposed to the WebAppSec WG at TPAC 2019. So far there is only an explainer posted to the mailing list: https://lists.w3.org/Archives/Public/public-webappsec/2019Sep/0004.html Source/WebCore: This patch adds the three experimental web APIs: - Promise<void> setLoggedIn() - Promise<void> setLoggedOut() - Promise<bool> isLoggedIn() It also tests that those APIs are only exposed in secure contexts. The functionality is implemented as a supplement to Navigator. Tests: http/tests/is-logged-in/available-in-secure-contexts.https.html http/tests/is-logged-in/unavailable-in-insecure-contexts.html * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * page/NavigatorIsLoggedIn.cpp: Added. (WebCore::NavigatorIsLoggedIn::from): (WebCore::NavigatorIsLoggedIn::supplementName): (WebCore::NavigatorIsLoggedIn::setLoggedIn): (WebCore::NavigatorIsLoggedIn::setLoggedOut): (WebCore::NavigatorIsLoggedIn::isLoggedIn): * page/NavigatorIsLoggedIn.h: Added. * page/NavigatorIsLoggedIn.idl: Added. * page/PointerCaptureController.cpp: * page/PointerCaptureController.h: * page/Settings.yaml: Source/WebKit: * Shared/WebPreferences.yaml: LayoutTests: * http/tests/is-logged-in/available-in-secure-contexts.https-expected.txt: Added. * http/tests/is-logged-in/available-in-secure-contexts.https.html: Added. * http/tests/is-logged-in/unavailable-in-insecure-contexts-expected.txt: Added. * http/tests/is-logged-in/unavailable-in-insecure-contexts.html: Added. * platform/ios-device-wk1/TestExpectations: * platform/ios-simulator-wk1/TestExpectations: * platform/ios-wk1/TestExpectations: * platform/mac-highsierra/fast/dom/navigator-detached-no-crash-expected.txt: * platform/mac-wk1/TestExpectations: * platform/mac-wk2/fast/dom/navigator-detached-no-crash-expected.txt: * platform/wincairo-wk1/TestExpectations: Canonical link: https://commits.webkit.org/216235@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250944 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-10-10 00:03:47 +00:00
/*
* Copyright (C) 2019 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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 "Supplementable.h"
namespace WebCore {
class DeferredPromise;
class Navigator;
class NavigatorIsLoggedIn final : public Supplement<Navigator> {
WTF_MAKE_FAST_ALLOCATED;
public:
explicit NavigatorIsLoggedIn(Navigator& navigator)
: m_navigator(navigator)
{
}
static void setLoggedIn(Navigator&, Ref<DeferredPromise>&&);
static void setLoggedOut(Navigator&, Ref<DeferredPromise>&&);
static void isLoggedIn(Navigator&, Ref<DeferredPromise>&&);
private:
void setLoggedIn(Ref<DeferredPromise>&&);
void setLoggedOut(Ref<DeferredPromise>&&);
void isLoggedIn(Ref<DeferredPromise>&&);
static NavigatorIsLoggedIn* from(Navigator&);
static const char* supplementName();
Navigator& m_navigator;
};
} // namespace WebCore