| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "modules/presentation/PresentationController.h" | 5 #include "modules/presentation/PresentationController.h" |
| 6 | 6 |
| 7 #include "core/frame/LocalFrame.h" | 7 #include "core/frame/LocalFrame.h" |
| 8 #include "modules/presentation/PresentationConnection.h" | 8 #include "modules/presentation/PresentationConnection.h" |
| 9 #include "public/platform/modules/presentation/WebPresentationClient.h" | 9 #include "public/platform/modules/presentation/WebPresentationClient.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 PresentationController::PresentationController(LocalFrame& frame, WebPresentatio
nClient* client) | 13 PresentationController::PresentationController(LocalFrame& frame, WebPresentatio
nClient* client) |
| 14 : LocalFrameLifecycleObserver(&frame) | 14 : LocalFrameLifecycleObserver(&frame) |
| 15 , m_client(client) | 15 , m_client(client) |
| 16 { | 16 { |
| 17 if (m_client) | 17 if (m_client) |
| 18 m_client->setController(this); | 18 m_client->setController(this); |
| 19 } | 19 } |
| 20 | 20 |
| 21 PresentationController::~PresentationController() | 21 PresentationController::~PresentationController() |
| 22 { | 22 { |
| 23 if (m_client) | 23 if (m_client) |
| 24 m_client->setController(nullptr); | 24 m_client->setController(nullptr); |
| 25 } | 25 } |
| 26 | 26 |
| 27 // static | 27 // static |
| 28 PassOwnPtrWillBeRawPtr<PresentationController> PresentationController::create(Lo
calFrame& frame, WebPresentationClient* client) | 28 RawPtr<PresentationController> PresentationController::create(LocalFrame& frame,
WebPresentationClient* client) |
| 29 { | 29 { |
| 30 return adoptPtrWillBeNoop(new PresentationController(frame, client)); | 30 return (new PresentationController(frame, client)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 // static | 33 // static |
| 34 const char* PresentationController::supplementName() | 34 const char* PresentationController::supplementName() |
| 35 { | 35 { |
| 36 return "PresentationController"; | 36 return "PresentationController"; |
| 37 } | 37 } |
| 38 | 38 |
| 39 // static | 39 // static |
| 40 PresentationController* PresentationController::from(LocalFrame& frame) | 40 PresentationController* PresentationController::from(LocalFrame& frame) |
| 41 { | 41 { |
| 42 return static_cast<PresentationController*>(WillBeHeapSupplement<LocalFrame>
::from(frame, supplementName())); | 42 return static_cast<PresentationController*>(HeapSupplement<LocalFrame>::from
(frame, supplementName())); |
| 43 } | 43 } |
| 44 | 44 |
| 45 // static | 45 // static |
| 46 void PresentationController::provideTo(LocalFrame& frame, WebPresentationClient*
client) | 46 void PresentationController::provideTo(LocalFrame& frame, WebPresentationClient*
client) |
| 47 { | 47 { |
| 48 WillBeHeapSupplement<LocalFrame>::provideTo(frame, PresentationController::s
upplementName(), PresentationController::create(frame, client)); | 48 HeapSupplement<LocalFrame>::provideTo(frame, PresentationController::supplem
entName(), PresentationController::create(frame, client)); |
| 49 } | 49 } |
| 50 | 50 |
| 51 WebPresentationClient* PresentationController::client() | 51 WebPresentationClient* PresentationController::client() |
| 52 { | 52 { |
| 53 return m_client; | 53 return m_client; |
| 54 } | 54 } |
| 55 | 55 |
| 56 DEFINE_TRACE(PresentationController) | 56 DEFINE_TRACE(PresentationController) |
| 57 { | 57 { |
| 58 visitor->trace(m_presentation); | 58 visitor->trace(m_presentation); |
| 59 visitor->trace(m_connections); | 59 visitor->trace(m_connections); |
| 60 WillBeHeapSupplement<LocalFrame>::trace(visitor); | 60 HeapSupplement<LocalFrame>::trace(visitor); |
| 61 LocalFrameLifecycleObserver::trace(visitor); | 61 LocalFrameLifecycleObserver::trace(visitor); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void PresentationController::didStartDefaultSession(WebPresentationConnectionCli
ent* connectionClient) | 64 void PresentationController::didStartDefaultSession(WebPresentationConnectionCli
ent* connectionClient) |
| 65 { | 65 { |
| 66 if (!m_presentation || !m_presentation->defaultRequest()) | 66 if (!m_presentation || !m_presentation->defaultRequest()) |
| 67 return; | 67 return; |
| 68 PresentationConnection::take(this, adoptPtr(connectionClient), m_presentatio
n->defaultRequest()); | 68 PresentationConnection::take(this, adoptPtr(connectionClient), m_presentatio
n->defaultRequest()); |
| 69 } | 69 } |
| 70 | 70 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 { | 131 { |
| 132 for (const auto& connection : m_connections) { | 132 for (const auto& connection : m_connections) { |
| 133 if (connection->matches(connectionClient)) | 133 if (connection->matches(connectionClient)) |
| 134 return connection.get(); | 134 return connection.get(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 return nullptr; | 137 return nullptr; |
| 138 } | 138 } |
| 139 | 139 |
| 140 } // namespace blink | 140 } // namespace blink |
| OLD | NEW |