Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: Source/modules/presentation/Presentation.h

Issue 832263007: Added plumbing for the availablechange event from Blink to WebPresentationClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added onClientDestroyed Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef Presentation_h 5 #ifndef Presentation_h
6 #define Presentation_h 6 #define Presentation_h
7 7
8 #include "bindings/core/v8/ScriptPromise.h" 8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "core/dom/ContextLifecycleObserver.h"
10 #include "core/events/EventTarget.h" 9 #include "core/events/EventTarget.h"
10 #include "core/frame/DOMWindowProperty.h"
11 #include "modules/presentation/PresentationSession.h" 11 #include "modules/presentation/PresentationSession.h"
12 #include "platform/heap/Handle.h"
13
14 namespace WTF {
15 class String;
16 } // namespace WTF
12 17
13 namespace blink { 18 namespace blink {
14 19
20 class LocalFrame;
21 class PresentationController;
15 class ScriptState; 22 class ScriptState;
16 23
24 // Implements the main entry point of the Presentation API corresponding to the Presentation.idl
25 // See https://w3c.github.io/presentation-api/#navigatorpresentation for details .
17 class Presentation final 26 class Presentation final
18 : public RefCountedGarbageCollectedEventTargetWithInlineData<Presentation> 27 : public RefCountedGarbageCollectedEventTargetWithInlineData<Presentation>
19 , public ContextLifecycleObserver { 28 , public DOMWindowProperty {
20 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<P resentation>); 29 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<P resentation>);
21 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Presentation); 30 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Presentation);
22 DEFINE_WRAPPERTYPEINFO(); 31 DEFINE_WRAPPERTYPEINFO();
23 public: 32 public:
24 static Presentation* create(ExecutionContext*); 33 static Presentation* create(LocalFrame*);
25 virtual ~Presentation(); 34 virtual ~Presentation();
26 35
27 // EventTarget implementation. 36 // EventTarget implementation.
28 virtual const AtomicString& interfaceName() const override; 37 virtual const AtomicString& interfaceName() const override;
29 virtual ExecutionContext* executionContext() const override; 38 virtual ExecutionContext* executionContext() const override;
30 39
31 virtual void trace(Visitor*) override; 40 virtual void trace(Visitor*) override;
32 41
33 PresentationSession* session() const; 42 PresentationSession* session() const;
34 43
35 ScriptPromise startSession(ScriptState*, const String& senderId, const Strin g& presentationId); 44 ScriptPromise startSession(ScriptState*, const String& presentationUrl, cons t String& presentationId);
36 ScriptPromise joinSession(ScriptState*, const String& senderId, const String & presentationId); 45 ScriptPromise joinSession(ScriptState*, const String& presentationUrl, const String& presentationId);
37 46
38 DEFINE_ATTRIBUTE_EVENT_LISTENER(availablechange); 47 DEFINE_ATTRIBUTE_EVENT_LISTENER(availablechange);
39 48
49 // The embedder needs to keep track if anything is listening to the event so it could stop the
50 // might be expensive screen discovery process.
51 virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<Even tListener>, bool useCapture) override;
52 virtual bool removeEventListener(const AtomicString& eventType, PassRefPtr<E ventListener>, bool useCapture) override;
53 virtual void removeAllEventListeners() override;
54
55 // Called when the |availablechange| event needs to be fired.
56 void didChangeAvailability(bool available);
57 // Queried by the controller if |availablechange| event has any listeners.
58 bool isAvailableChangeWatched() const;
40 private: 59 private:
41 explicit Presentation(ExecutionContext*); 60 explicit Presentation(LocalFrame*);
61
62 // Returns the |PresentationController| object associated with the frame |Pr esentation| corresponds to.
63 // Can return |nullptr| if the frame is detached from the document.
64 PresentationController* presentationController();
42 65
43 Member<PresentationSession> m_session; 66 Member<PresentationSession> m_session;
44 }; 67 };
45 68
46 } // namespace blink 69 } // namespace blink
47 70
48 #endif // Presentation_h 71 #endif // Presentation_h
OLDNEW
« no previous file with comments | « Source/modules/presentation/NavigatorPresentation.idl ('k') | Source/modules/presentation/Presentation.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698