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 "content/renderer/presentation/presentation_dispatcher.h" | 5 #include "content/renderer/presentation/presentation_dispatcher.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/common/presentation/presentation_service.mojom.h" | 8 #include "content/common/presentation/presentation_service.mojom.h" |
9 #include "content/public/common/service_registry.h" | 9 #include "content/public/common/service_registry.h" |
10 #include "content/public/renderer/render_frame.h" | 10 #include "content/public/renderer/render_frame.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 void PresentationDispatcher::OnScreenAvailabilityChanged(bool available) { | 106 void PresentationDispatcher::OnScreenAvailabilityChanged(bool available) { |
107 if (!controller_) | 107 if (!controller_) |
108 return; | 108 return; |
109 | 109 |
110 // Reset the callback to get the next event. | 110 // Reset the callback to get the next event. |
111 updateAvailableChangeWatched(controller_->isAvailableChangeWatched()); | 111 updateAvailableChangeWatched(controller_->isAvailableChangeWatched()); |
112 | 112 |
113 controller_->didChangeAvailability(available); | 113 controller_->didChangeAvailability(available); |
114 } | 114 } |
115 | 115 |
116 void PresentationDispatcher::OnDefaultPresentationStarted( | |
117 presentation::PresentationSessionInfoPtr session_info) { | |
118 if (!controller_) | |
119 return; | |
120 | |
121 // Reset the callback to get the next event. | |
122 presentation_service_->ListenForDefaultPresentationStart(base::Bind( | |
123 &PresentationDispatcher::OnDefaultPresentationStarted, | |
124 base::Unretained(this))); | |
125 | |
126 DCHECK(!session_info.is_null()); | |
127 PresentationSessionDispatcher* session_dispatcher = | |
128 new PresentationSessionDispatcher(session_info.Pass()); | |
129 presentation_session_dispatchers_.push_back(session_dispatcher); | |
130 controller_->didStartDefaultPresentation( | |
131 new PresentationSessionClient(session_dispatcher)); | |
132 } | |
133 | |
116 void PresentationDispatcher::OnSessionCreated( | 134 void PresentationDispatcher::OnSessionCreated( |
117 blink::WebPresentationSessionClientCallbacks* callback, | 135 blink::WebPresentationSessionClientCallbacks* callback, |
118 presentation::PresentationSessionInfoPtr session_info, | 136 presentation::PresentationSessionInfoPtr session_info, |
119 presentation::PresentationErrorPtr error) { | 137 presentation::PresentationErrorPtr error) { |
120 DCHECK(callback); | 138 DCHECK(callback); |
121 if (!error.is_null()) { | 139 if (!error.is_null()) { |
122 DCHECK(session_info.is_null()); | 140 DCHECK(session_info.is_null()); |
123 callback->onError(new blink::WebPresentationError( | 141 callback->onError(new blink::WebPresentationError( |
124 GetWebPresentationErrorTypeFromMojo(error->errorType), | 142 GetWebPresentationErrorTypeFromMojo(error->errorType), |
125 blink::WebString::fromUTF8(error->message))); | 143 blink::WebString::fromUTF8(error->message))); |
126 return; | 144 return; |
127 } | 145 } |
128 | 146 |
129 DCHECK(!session_info.is_null()); | 147 DCHECK(!session_info.is_null()); |
130 PresentationSessionDispatcher* session_dispatcher = | 148 PresentationSessionDispatcher* session_dispatcher = |
131 new PresentationSessionDispatcher(session_info.Pass()); | 149 new PresentationSessionDispatcher(session_info.Pass()); |
132 presentation_session_dispatchers_.push_back(session_dispatcher); | 150 presentation_session_dispatchers_.push_back(session_dispatcher); |
133 callback->onSuccess(new PresentationSessionClient(session_dispatcher)); | 151 callback->onSuccess(new PresentationSessionClient(session_dispatcher)); |
134 } | 152 } |
135 | 153 |
136 void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() { | 154 void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() { |
137 if (presentation_service_.get()) | 155 if (presentation_service_.get()) |
138 return; | 156 return; |
139 | 157 |
140 render_frame()->GetServiceRegistry()->ConnectToRemoteService( | 158 render_frame()->GetServiceRegistry()->ConnectToRemoteService( |
141 &presentation_service_); | 159 &presentation_service_); |
160 presentation_service_->ListenForDefaultPresentationStart(base::Bind( | |
161 &PresentationDispatcher::OnDefaultPresentationStarted, | |
162 base::Unretained(this))); | |
mlamouri (slow - plz ping)
2015/03/06 22:06:56
nit: style, I would do something like
presentation
whywhat
2015/03/10 15:19:49
I had that but then I liked how both params to bas
| |
142 } | 163 } |
143 | 164 |
144 } // namespace content | 165 } // namespace content |
OLD | NEW |