summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/Source/modules/presentation/Presentation.h
blob: 8091cd9dcaca0c2ac1ae6e409dcfb5740bee3396 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2014 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 Presentation_h
#define Presentation_h

#include "bindings/core/v8/ScriptWrappable.h"
#include "core/frame/DOMWindowProperty.h"
#include "platform/heap/Handle.h"
#include "platform/heap/Heap.h"

namespace blink {

class LocalFrame;
class PresentationReceiver;
class PresentationRequest;

// Implements the main entry point of the Presentation API corresponding to the Presentation.idl
// See https://w3c.github.io/presentation-api/#navigatorpresentation for details.
//
// TODO(Oilpan): switch to GarbageCollected<Presentation> once object is unconditionally on the Oilpan heap.
class Presentation final
    : public GarbageCollectedFinalized<Presentation>
    , public ScriptWrappable
    , public DOMWindowProperty {
    WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Presentation);
    DEFINE_WRAPPERTYPEINFO();
public:
    static Presentation* create(LocalFrame*);
#if !ENABLE(OILPAN)
    ~Presentation() override = default;
#endif

    DECLARE_VIRTUAL_TRACE();

    PresentationRequest* defaultRequest() const;
    void setDefaultRequest(PresentationRequest*);

    PresentationReceiver* receiver();

private:
    explicit Presentation(LocalFrame*);

    // Default PresentationRequest used by the embedder.
    Member<PresentationRequest> m_defaultRequest;

    // PresentationReceiver instance. It will always be nullptr if the Blink
    // instance is not running as a presentation receiver.
    Member<PresentationReceiver> m_receiver;
};

} // namespace blink

#endif // Presentation_h