summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/Source/modules/presentation/PresentationAvailabilityCallbacks.h
blob: 4f32eec04459f91f6e7f11b5cc736b9b7b7c3a08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef PresentationAvailabilityCallbacks_h
#define PresentationAvailabilityCallbacks_h

#include "platform/heap/Handle.h"
#include "platform/weborigin/KURL.h"
#include "public/platform/WebCallbacks.h"
#include "wtf/Noncopyable.h"

namespace blink {

class ScriptPromiseResolver;
struct WebPresentationError;

// PresentationAvailabilityCallback extends WebCallbacks to resolve the
// underlying promise depending on the result passed to the callback. It takes a
// KURL in its constructor and will pass it to the WebAvailabilityObserver.
class PresentationAvailabilityCallbacks final : public WebCallbacks<bool, const WebPresentationError&> {
public:
    PresentationAvailabilityCallbacks(ScriptPromiseResolver*, const KURL&);
    ~PresentationAvailabilityCallbacks() override;

    void onSuccess(bool value) override;
    void onError(const WebPresentationError&) override;

private:
    Persistent<ScriptPromiseResolver> m_resolver;
    const KURL m_url;

    WTF_MAKE_NONCOPYABLE(PresentationAvailabilityCallbacks);
};

} // namespace blink

#endif // PresentationAvailabilityCallbacks_h