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

Side by Side Diff: Source/modules/presentation/PresentationSession.cpp

Issue 1015903002: [Presentation API] Adds close method to Presentation session. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addresses whywhat's comments Created 5 years, 9 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 #include "config.h" 5 #include "config.h"
6 #include "modules/presentation/PresentationSession.h" 6 #include "modules/presentation/PresentationSession.h"
7 7
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "modules/EventTargetModules.h" 10 #include "modules/EventTargetModules.h"
11 #include "modules/presentation/Presentation.h" 11 #include "modules/presentation/Presentation.h"
12 #include "modules/presentation/PresentationController.h"
12 #include "public/platform/WebString.h" 13 #include "public/platform/WebString.h"
13 #include "public/platform/modules/presentation/WebPresentationSessionClient.h" 14 #include "public/platform/modules/presentation/WebPresentationSessionClient.h"
14 #include "wtf/OwnPtr.h" 15 #include "wtf/OwnPtr.h"
15 16
16 namespace blink { 17 namespace blink {
17 18
18 PresentationSession::PresentationSession(LocalFrame* frame, const WebString& id) 19 PresentationSession::PresentationSession(LocalFrame* frame, const WebString& id, const WebString& url)
19 : DOMWindowProperty(frame) 20 : DOMWindowProperty(frame)
20 , m_id(id) 21 , m_id(id)
22 , m_url(url)
21 , m_state("disconnected") 23 , m_state("disconnected")
22 { 24 {
23 } 25 }
24 26
25 PresentationSession::~PresentationSession() 27 PresentationSession::~PresentationSession()
26 { 28 {
27 } 29 }
28 30
29 // static 31 // static
30 PresentationSession* PresentationSession::take(WebPresentationSessionClient* cli entRaw, Presentation* presentation) 32 PresentationSession* PresentationSession::take(WebPresentationSessionClient* cli entRaw, Presentation* presentation)
31 { 33 {
32 ASSERT(clientRaw); 34 ASSERT(clientRaw);
33 ASSERT(presentation); 35 ASSERT(presentation);
34 OwnPtr<WebPresentationSessionClient> client = adoptPtr(clientRaw); 36 OwnPtr<WebPresentationSessionClient> client = adoptPtr(clientRaw);
35 37
36 PresentationSession* session = new PresentationSession(presentation->frame() , client->getId()); 38 PresentationSession* session = new PresentationSession(presentation->frame() , client->getId(), client->getUrl());
37 presentation->registerSession(session); 39 presentation->registerSession(session);
38 return session; 40 return session;
39 } 41 }
40 42
41 // static 43 // static
42 void PresentationSession::dispose(WebPresentationSessionClient* client) 44 void PresentationSession::dispose(WebPresentationSessionClient* client)
43 { 45 {
44 delete client; 46 delete client;
45 } 47 }
46 48
(...skipping 13 matching lines...) Expand all
60 RefCountedGarbageCollectedEventTargetWithInlineData<PresentationSession>::tr ace(visitor); 62 RefCountedGarbageCollectedEventTargetWithInlineData<PresentationSession>::tr ace(visitor);
61 DOMWindowProperty::trace(visitor); 63 DOMWindowProperty::trace(visitor);
62 } 64 }
63 65
64 void PresentationSession::postMessage(const String& message) 66 void PresentationSession::postMessage(const String& message)
65 { 67 {
66 } 68 }
67 69
68 void PresentationSession::close() 70 void PresentationSession::close()
69 { 71 {
72 if (m_state != "connected")
73 return;
74 PresentationController* controller = presentationController();
75 if (controller)
76 controller->closeSession(m_url, m_id);
77 }
78
79 PresentationController* PresentationSession::presentationController()
80 {
81 if (!frame())
82 return nullptr;
83 return PresentationController::from(*frame());
70 } 84 }
71 85
72 } // namespace blink 86 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/presentation/PresentationSession.h ('k') | public/platform/modules/presentation/WebPresentationClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698