Chromium Code Reviews| 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 <algorithm> | |
| 8 #include <utility> | 7 #include <utility> |
| 9 #include <vector> | 8 #include <vector> |
| 10 | 9 |
| 11 #include "base/bind.h" | 10 #include "base/bind.h" |
| 12 #include "base/logging.h" | 11 #include "base/logging.h" |
| 13 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 14 #include "content/public/common/presentation_constants.h" | 13 #include "content/public/common/presentation_constants.h" |
| 15 #include "content/public/renderer/render_frame.h" | 14 #include "content/public/renderer/render_frame.h" |
| 16 #include "content/renderer/presentation/presentation_connection_client.h" | 15 #include "content/renderer/presentation/presentation_connection_client.h" |
| 17 #include "services/shell/public/cpp/interface_provider.h" | 16 #include "services/shell/public/cpp/interface_provider.h" |
| 18 #include "third_party/WebKit/public/platform/WebString.h" | 17 #include "third_party/WebKit/public/platform/WebString.h" |
| 18 #include "third_party/WebKit/public/platform/WebURL.h" | |
| 19 #include "third_party/WebKit/public/platform/WebVector.h" | 19 #include "third_party/WebKit/public/platform/WebVector.h" |
| 20 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nAvailabilityObserver.h" | 20 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nAvailabilityObserver.h" |
| 21 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nController.h" | 21 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nController.h" |
| 22 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nError.h" | 22 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nError.h" |
| 23 #include "third_party/WebKit/public/platform/modules/presentation/presentation.m ojom.h" | 23 #include "third_party/WebKit/public/platform/modules/presentation/presentation.m ojom.h" |
| 24 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 24 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 25 #include "url/gurl.h" | 25 #include "url/gurl.h" |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 blink::WebPresentationController* controller) { | 93 blink::WebPresentationController* controller) { |
| 94 // There shouldn't be any swapping from one non-null controller to another. | 94 // There shouldn't be any swapping from one non-null controller to another. |
| 95 DCHECK(controller != controller_ && (!controller || !controller_)); | 95 DCHECK(controller != controller_ && (!controller || !controller_)); |
| 96 controller_ = controller; | 96 controller_ = controller; |
| 97 // The controller is set to null when the frame is about to be detached. | 97 // The controller is set to null when the frame is about to be detached. |
| 98 // Nothing is listening for screen availability anymore but the Mojo service | 98 // Nothing is listening for screen availability anymore but the Mojo service |
| 99 // will know about the frame being detached anyway. | 99 // will know about the frame being detached anyway. |
| 100 } | 100 } |
| 101 | 101 |
| 102 void PresentationDispatcher::startSession( | 102 void PresentationDispatcher::startSession( |
| 103 const blink::WebVector<blink::WebString>& presentationUrls, | 103 const blink::WebVector<blink::WebURL>& presentationUrls, |
| 104 blink::WebPresentationConnectionClientCallbacks* callback) { | 104 blink::WebPresentationConnectionClientCallbacks* callback) { |
| 105 DCHECK(callback); | 105 DCHECK(callback); |
| 106 ConnectToPresentationServiceIfNeeded(); | 106 ConnectToPresentationServiceIfNeeded(); |
| 107 | 107 |
| 108 std::vector<GURL> urls(presentationUrls.size()); | 108 std::vector<GURL> urls; |
| 109 std::transform(presentationUrls.begin(), presentationUrls.end(), urls.begin(), | 109 for (const auto& url : presentationUrls) |
| 110 [](const blink::WebString& url) { return GURL(url.utf8()); }); | 110 urls.push_back(url); |
| 111 | 111 |
| 112 // The dispatcher owns the service so |this| will be valid when | 112 // The dispatcher owns the service so |this| will be valid when |
| 113 // OnSessionCreated() is called. |callback| needs to be alive and also needs | 113 // OnSessionCreated() is called. |callback| needs to be alive and also needs |
| 114 // to be destroyed so we transfer its ownership to the mojo callback. | 114 // to be destroyed so we transfer its ownership to the mojo callback. |
| 115 presentation_service_->StartSession( | 115 presentation_service_->StartSession( |
| 116 urls, base::Bind(&PresentationDispatcher::OnSessionCreated, | 116 urls, base::Bind(&PresentationDispatcher::OnSessionCreated, |
| 117 base::Unretained(this), base::Owned(callback))); | 117 base::Unretained(this), base::Owned(callback))); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void PresentationDispatcher::joinSession( | 120 void PresentationDispatcher::joinSession( |
| 121 const blink::WebVector<blink::WebString>& presentationUrls, | 121 const blink::WebVector<blink::WebURL>& presentationUrls, |
| 122 const blink::WebString& presentationId, | 122 const blink::WebString& presentationId, |
| 123 blink::WebPresentationConnectionClientCallbacks* callback) { | 123 blink::WebPresentationConnectionClientCallbacks* callback) { |
| 124 DCHECK(callback); | 124 DCHECK(callback); |
| 125 ConnectToPresentationServiceIfNeeded(); | 125 ConnectToPresentationServiceIfNeeded(); |
| 126 | 126 |
| 127 std::vector<GURL> urls(presentationUrls.size()); | 127 std::vector<GURL> urls; |
| 128 std::transform(presentationUrls.begin(), presentationUrls.end(), urls.begin(), | 128 for (const auto& url : presentationUrls) |
| 129 [](const blink::WebString& url) { return GURL(url.utf8()); }); | 129 urls.push_back(url); |
| 130 | 130 |
| 131 // The dispatcher owns the service so |this| will be valid when | 131 // The dispatcher owns the service so |this| will be valid when |
| 132 // OnSessionCreated() is called. |callback| needs to be alive and also needs | 132 // OnSessionCreated() is called. |callback| needs to be alive and also needs |
| 133 // to be destroyed so we transfer its ownership to the mojo callback. | 133 // to be destroyed so we transfer its ownership to the mojo callback. |
| 134 presentation_service_->JoinSession( | 134 presentation_service_->JoinSession( |
| 135 urls, presentationId.utf8(), | 135 urls, presentationId.utf8(), |
| 136 base::Bind(&PresentationDispatcher::OnSessionCreated, | 136 base::Bind(&PresentationDispatcher::OnSessionCreated, |
| 137 base::Unretained(this), base::Owned(callback))); | 137 base::Unretained(this), base::Owned(callback))); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void PresentationDispatcher::sendString( | 140 void PresentationDispatcher::sendString(const blink::WebURL& presentationUrl, |
| 141 const blink::WebString& presentationUrl, | 141 const blink::WebString& presentationId, |
| 142 const blink::WebString& presentationId, | 142 const blink::WebString& message) { |
| 143 const blink::WebString& message) { | |
| 144 if (message.utf8().size() > kMaxPresentationSessionMessageSize) { | 143 if (message.utf8().size() > kMaxPresentationSessionMessageSize) { |
| 145 // TODO(crbug.com/459008): Limit the size of individual messages to 64k | 144 // TODO(crbug.com/459008): Limit the size of individual messages to 64k |
| 146 // for now. Consider throwing DOMException or splitting bigger messages | 145 // for now. Consider throwing DOMException or splitting bigger messages |
| 147 // into smaller chunks later. | 146 // into smaller chunks later. |
| 148 LOG(WARNING) << "message size exceeded limit!"; | 147 LOG(WARNING) << "message size exceeded limit!"; |
| 149 return; | 148 return; |
| 150 } | 149 } |
| 151 | 150 |
| 152 message_request_queue_.push(base::WrapUnique( | 151 message_request_queue_.push(base::WrapUnique( |
| 153 CreateSendTextMessageRequest(presentationUrl, presentationId, message))); | 152 CreateSendTextMessageRequest(presentationUrl, presentationId, message))); |
| 154 // Start processing request if only one in the queue. | 153 // Start processing request if only one in the queue. |
| 155 if (message_request_queue_.size() == 1) | 154 if (message_request_queue_.size() == 1) |
| 156 DoSendMessage(message_request_queue_.front().get()); | 155 DoSendMessage(message_request_queue_.front().get()); |
| 157 } | 156 } |
| 158 | 157 |
| 159 void PresentationDispatcher::sendArrayBuffer( | 158 void PresentationDispatcher::sendArrayBuffer( |
| 160 const blink::WebString& presentationUrl, | 159 const blink::WebURL& presentationUrl, |
| 161 const blink::WebString& presentationId, | 160 const blink::WebString& presentationId, |
| 162 const uint8_t* data, | 161 const uint8_t* data, |
| 163 size_t length) { | 162 size_t length) { |
| 164 DCHECK(data); | 163 DCHECK(data); |
| 165 if (length > kMaxPresentationSessionMessageSize) { | 164 if (length > kMaxPresentationSessionMessageSize) { |
| 166 // TODO(crbug.com/459008): Same as in sendString(). | 165 // TODO(crbug.com/459008): Same as in sendString(). |
| 167 LOG(WARNING) << "data size exceeded limit!"; | 166 LOG(WARNING) << "data size exceeded limit!"; |
| 168 return; | 167 return; |
| 169 } | 168 } |
| 170 | 169 |
| 171 message_request_queue_.push(base::WrapUnique(CreateSendBinaryMessageRequest( | 170 message_request_queue_.push(base::WrapUnique(CreateSendBinaryMessageRequest( |
| 172 presentationUrl, presentationId, | 171 presentationUrl, presentationId, |
| 173 blink::mojom::PresentationMessageType::ARRAY_BUFFER, data, length))); | 172 blink::mojom::PresentationMessageType::ARRAY_BUFFER, data, length))); |
| 174 // Start processing request if only one in the queue. | 173 // Start processing request if only one in the queue. |
| 175 if (message_request_queue_.size() == 1) | 174 if (message_request_queue_.size() == 1) |
| 176 DoSendMessage(message_request_queue_.front().get()); | 175 DoSendMessage(message_request_queue_.front().get()); |
| 177 } | 176 } |
| 178 | 177 |
| 179 void PresentationDispatcher::sendBlobData( | 178 void PresentationDispatcher::sendBlobData( |
| 180 const blink::WebString& presentationUrl, | 179 const blink::WebURL& presentationUrl, |
| 181 const blink::WebString& presentationId, | 180 const blink::WebString& presentationId, |
| 182 const uint8_t* data, | 181 const uint8_t* data, |
| 183 size_t length) { | 182 size_t length) { |
| 184 DCHECK(data); | 183 DCHECK(data); |
| 185 if (length > kMaxPresentationSessionMessageSize) { | 184 if (length > kMaxPresentationSessionMessageSize) { |
| 186 // TODO(crbug.com/459008): Same as in sendString(). | 185 // TODO(crbug.com/459008): Same as in sendString(). |
| 187 LOG(WARNING) << "data size exceeded limit!"; | 186 LOG(WARNING) << "data size exceeded limit!"; |
| 188 return; | 187 return; |
| 189 } | 188 } |
| 190 | 189 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 220 return; | 219 return; |
| 221 } | 220 } |
| 222 | 221 |
| 223 message_request_queue_.pop(); | 222 message_request_queue_.pop(); |
| 224 if (!message_request_queue_.empty()) { | 223 if (!message_request_queue_.empty()) { |
| 225 DoSendMessage(message_request_queue_.front().get()); | 224 DoSendMessage(message_request_queue_.front().get()); |
| 226 } | 225 } |
| 227 } | 226 } |
| 228 | 227 |
| 229 void PresentationDispatcher::closeSession( | 228 void PresentationDispatcher::closeSession( |
| 230 const blink::WebString& presentationUrl, | 229 const blink::WebURL& presentationUrl, |
| 231 const blink::WebString& presentationId) { | 230 const blink::WebString& presentationId) { |
| 232 ConnectToPresentationServiceIfNeeded(); | 231 ConnectToPresentationServiceIfNeeded(); |
| 233 presentation_service_->CloseConnection(GURL(presentationUrl.utf8()), | 232 presentation_service_->CloseConnection(presentationUrl, |
| 234 presentationId.utf8()); | 233 presentationId.utf8()); |
| 235 } | 234 } |
| 236 | 235 |
| 237 void PresentationDispatcher::terminateSession( | 236 void PresentationDispatcher::terminateSession( |
| 238 const blink::WebString& presentationUrl, | 237 const blink::WebURL& presentationUrl, |
| 239 const blink::WebString& presentationId) { | 238 const blink::WebString& presentationId) { |
| 240 ConnectToPresentationServiceIfNeeded(); | 239 ConnectToPresentationServiceIfNeeded(); |
| 241 presentation_service_->Terminate(GURL(presentationUrl.utf8()), | 240 presentation_service_->Terminate(presentationUrl, presentationId.utf8()); |
| 242 presentationId.utf8()); | |
| 243 } | 241 } |
| 244 | 242 |
| 245 void PresentationDispatcher::getAvailability( | 243 void PresentationDispatcher::getAvailability( |
| 246 const blink::WebString& availabilityUrl, | 244 const blink::WebURL& availabilityUrl, |
| 247 blink::WebPresentationAvailabilityCallbacks* callbacks) { | 245 blink::WebPresentationAvailabilityCallbacks* callbacks) { |
| 248 const std::string& availability_url = availabilityUrl.utf8(); | |
| 249 AvailabilityStatus* status = nullptr; | 246 AvailabilityStatus* status = nullptr; |
| 250 auto status_it = availability_status_.find(availability_url); | 247 auto status_it = availability_status_.find(availabilityUrl); |
| 251 if (status_it == availability_status_.end()) { | 248 if (status_it == availability_status_.end()) { |
| 252 status = new AvailabilityStatus(availability_url); | 249 status = new AvailabilityStatus(availabilityUrl); |
| 253 availability_status_[availability_url] = base::WrapUnique(status); | 250 availability_status_[availabilityUrl] = base::WrapUnique(status); |
| 254 } else { | 251 } else { |
| 255 status = status_it->second.get(); | 252 status = status_it->second.get(); |
| 256 } | 253 } |
| 257 DCHECK(status); | 254 DCHECK(status); |
| 258 | 255 |
| 259 if (status->listening_state == ListeningState::ACTIVE) { | 256 if (status->listening_state == ListeningState::ACTIVE) { |
| 260 callbacks->onSuccess(status->last_known_availability); | 257 callbacks->onSuccess(status->last_known_availability); |
| 261 delete callbacks; | 258 delete callbacks; |
| 262 return; | 259 return; |
| 263 } | 260 } |
| 264 | 261 |
| 265 status->availability_callbacks.Add(callbacks); | 262 status->availability_callbacks.Add(callbacks); |
| 266 UpdateListeningState(status); | 263 UpdateListeningState(status); |
| 267 } | 264 } |
| 268 | 265 |
| 269 void PresentationDispatcher::startListening( | 266 void PresentationDispatcher::startListening( |
| 270 blink::WebPresentationAvailabilityObserver* observer) { | 267 blink::WebPresentationAvailabilityObserver* observer) { |
| 271 const std::string& availability_url = observer->url().string().utf8(); | 268 auto status_it = availability_status_.find(observer->url()); |
| 272 auto status_it = availability_status_.find(availability_url); | |
| 273 if (status_it == availability_status_.end()) { | 269 if (status_it == availability_status_.end()) { |
| 274 DLOG(WARNING) << "Start listening for availability for unknown URL " | 270 DLOG(WARNING) << "Start listening for availability for unknown URL " |
| 275 << availability_url; | 271 << observer->url(); |
| 276 return; | 272 return; |
| 277 } | 273 } |
| 278 status_it->second->availability_observers.insert(observer); | 274 status_it->second->availability_observers.insert(observer); |
| 279 UpdateListeningState(status_it->second.get()); | 275 UpdateListeningState(status_it->second.get()); |
| 280 } | 276 } |
| 281 | 277 |
| 282 void PresentationDispatcher::stopListening( | 278 void PresentationDispatcher::stopListening( |
| 283 blink::WebPresentationAvailabilityObserver* observer) { | 279 blink::WebPresentationAvailabilityObserver* observer) { |
| 284 const std::string& availability_url = observer->url().string().utf8(); | 280 auto status_it = availability_status_.find(observer->url()); |
| 285 auto status_it = availability_status_.find(availability_url); | |
| 286 if (status_it == availability_status_.end()) { | 281 if (status_it == availability_status_.end()) { |
| 287 DLOG(WARNING) << "Stop listening for availability for unknown URL " | 282 DLOG(WARNING) << "Stop listening for availability for unknown URL " |
| 288 << availability_url; | 283 << observer->url(); |
| 289 return; | 284 return; |
| 290 } | 285 } |
| 291 status_it->second->availability_observers.erase(observer); | 286 status_it->second->availability_observers.erase(observer); |
| 292 UpdateListeningState(status_it->second.get()); | 287 UpdateListeningState(status_it->second.get()); |
| 293 } | 288 } |
| 294 | 289 |
| 295 void PresentationDispatcher::setDefaultPresentationUrls( | 290 void PresentationDispatcher::setDefaultPresentationUrls( |
| 296 const blink::WebVector<blink::WebString>& presentationUrls) { | 291 const blink::WebVector<blink::WebURL>& presentationUrls) { |
| 297 ConnectToPresentationServiceIfNeeded(); | 292 ConnectToPresentationServiceIfNeeded(); |
| 298 | 293 |
| 299 std::vector<GURL> urls(presentationUrls.size()); | 294 std::vector<GURL> urls; |
| 300 std::transform(presentationUrls.begin(), presentationUrls.end(), urls.begin(), | 295 for (const auto& url : presentationUrls) |
| 301 [](const blink::WebString& url) { return GURL(url.utf8()); }); | 296 urls.push_back(url); |
| 297 | |
| 302 presentation_service_->SetDefaultPresentationUrls(urls); | 298 presentation_service_->SetDefaultPresentationUrls(urls); |
| 303 } | 299 } |
| 304 | 300 |
| 305 void PresentationDispatcher::DidCommitProvisionalLoad( | 301 void PresentationDispatcher::DidCommitProvisionalLoad( |
| 306 bool is_new_navigation, | 302 bool is_new_navigation, |
| 307 bool is_same_page_navigation) { | 303 bool is_same_page_navigation) { |
| 308 blink::WebFrame* frame = render_frame()->GetWebFrame(); | 304 blink::WebFrame* frame = render_frame()->GetWebFrame(); |
| 309 // If not top-level navigation. | 305 // If not top-level navigation. |
| 310 if (frame->parent() || is_same_page_navigation) | 306 if (frame->parent() || is_same_page_navigation) |
| 311 return; | 307 return; |
| 312 | 308 |
| 313 // Remove all pending send message requests. | 309 // Remove all pending send message requests. |
| 314 MessageRequestQueue empty; | 310 MessageRequestQueue empty; |
| 315 std::swap(message_request_queue_, empty); | 311 std::swap(message_request_queue_, empty); |
| 316 } | 312 } |
| 317 | 313 |
| 318 void PresentationDispatcher::OnDestruct() { | 314 void PresentationDispatcher::OnDestruct() { |
| 319 delete this; | 315 delete this; |
| 320 } | 316 } |
| 321 | 317 |
| 322 void PresentationDispatcher::OnScreenAvailabilityUpdated(const GURL& url, | 318 void PresentationDispatcher::OnScreenAvailabilityUpdated(const GURL& url, |
| 323 bool available) { | 319 bool available) { |
| 324 auto status_it = availability_status_.find(url.spec()); | 320 auto status_it = availability_status_.find(url); |
| 325 if (status_it == availability_status_.end()) | 321 if (status_it == availability_status_.end()) |
| 326 return; | 322 return; |
| 327 AvailabilityStatus* status = status_it->second.get(); | 323 AvailabilityStatus* status = status_it->second.get(); |
| 328 DCHECK(status); | 324 DCHECK(status); |
| 329 | 325 |
| 330 if (status->listening_state == ListeningState::WAITING) | 326 if (status->listening_state == ListeningState::WAITING) |
| 331 status->listening_state = ListeningState::ACTIVE; | 327 status->listening_state = ListeningState::ACTIVE; |
| 332 | 328 |
| 333 for (auto* observer : status->availability_observers) | 329 for (auto* observer : status->availability_observers) |
| 334 observer->availabilityChanged(available); | 330 observer->availabilityChanged(available); |
| 335 | 331 |
| 336 for (AvailabilityCallbacksMap::iterator iter(&status->availability_callbacks); | 332 for (AvailabilityCallbacksMap::iterator iter(&status->availability_callbacks); |
| 337 !iter.IsAtEnd(); iter.Advance()) { | 333 !iter.IsAtEnd(); iter.Advance()) { |
| 338 iter.GetCurrentValue()->onSuccess(available); | 334 iter.GetCurrentValue()->onSuccess(available); |
| 339 } | 335 } |
| 340 status->last_known_availability = available; | 336 status->last_known_availability = available; |
| 341 status->availability_callbacks.Clear(); | 337 status->availability_callbacks.Clear(); |
| 342 UpdateListeningState(status); | 338 UpdateListeningState(status); |
| 343 } | 339 } |
| 344 | 340 |
| 345 void PresentationDispatcher::OnScreenAvailabilityNotSupported(const GURL& url) { | 341 void PresentationDispatcher::OnScreenAvailabilityNotSupported(const GURL& url) { |
| 346 auto status_it = availability_status_.find(url.spec()); | 342 auto status_it = availability_status_.find(url); |
| 347 if (status_it == availability_status_.end()) | 343 if (status_it == availability_status_.end()) |
| 348 return; | 344 return; |
| 349 AvailabilityStatus* status = status_it->second.get(); | 345 AvailabilityStatus* status = status_it->second.get(); |
| 350 DCHECK(status); | 346 DCHECK(status); |
| 351 DCHECK(status->listening_state == ListeningState::WAITING); | 347 DCHECK(status->listening_state == ListeningState::WAITING); |
| 352 | 348 |
| 353 const blink::WebString& not_supported_error = blink::WebString::fromUTF8( | 349 const blink::WebString& not_supported_error = blink::WebString::fromUTF8( |
| 354 "getAvailability() isn't supported at the moment. It can be due to " | 350 "getAvailability() isn't supported at the moment. It can be due to " |
| 355 "a permanent or temporary system limitation. It is recommended to " | 351 "a permanent or temporary system limitation. It is recommended to " |
| 356 "try to blindly start a session in that case."); | 352 "try to blindly start a session in that case."); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 bool should_listen = !status->availability_callbacks.IsEmpty() || | 464 bool should_listen = !status->availability_callbacks.IsEmpty() || |
| 469 !status->availability_observers.empty(); | 465 !status->availability_observers.empty(); |
| 470 bool is_listening = status->listening_state != ListeningState::INACTIVE; | 466 bool is_listening = status->listening_state != ListeningState::INACTIVE; |
| 471 | 467 |
| 472 if (should_listen == is_listening) | 468 if (should_listen == is_listening) |
| 473 return; | 469 return; |
| 474 | 470 |
| 475 ConnectToPresentationServiceIfNeeded(); | 471 ConnectToPresentationServiceIfNeeded(); |
| 476 if (should_listen) { | 472 if (should_listen) { |
| 477 status->listening_state = ListeningState::WAITING; | 473 status->listening_state = ListeningState::WAITING; |
| 478 presentation_service_->ListenForScreenAvailability(GURL(status->url)); | 474 presentation_service_->ListenForScreenAvailability(status->url); |
| 479 } else { | 475 } else { |
| 480 status->listening_state = ListeningState::INACTIVE; | 476 status->listening_state = ListeningState::INACTIVE; |
| 481 presentation_service_->StopListeningForScreenAvailability( | 477 presentation_service_->StopListeningForScreenAvailability(status->url); |
| 482 GURL(status->url)); | |
| 483 } | 478 } |
| 484 } | 479 } |
| 485 | 480 |
| 486 PresentationDispatcher::SendMessageRequest::SendMessageRequest( | 481 PresentationDispatcher::SendMessageRequest::SendMessageRequest( |
| 487 blink::mojom::PresentationSessionInfoPtr session_info, | 482 blink::mojom::PresentationSessionInfoPtr session_info, |
| 488 blink::mojom::SessionMessagePtr message) | 483 blink::mojom::SessionMessagePtr message) |
| 489 : session_info(std::move(session_info)), message(std::move(message)) {} | 484 : session_info(std::move(session_info)), message(std::move(message)) {} |
| 490 | 485 |
| 491 PresentationDispatcher::SendMessageRequest::~SendMessageRequest() {} | 486 PresentationDispatcher::SendMessageRequest::~SendMessageRequest() {} |
| 492 | 487 |
| 493 // static | 488 // static |
| 494 PresentationDispatcher::SendMessageRequest* | 489 PresentationDispatcher::SendMessageRequest* |
| 495 PresentationDispatcher::CreateSendTextMessageRequest( | 490 PresentationDispatcher::CreateSendTextMessageRequest( |
| 496 const blink::WebString& presentationUrl, | 491 const blink::WebURL& presentationUrl, |
| 497 const blink::WebString& presentationId, | 492 const blink::WebString& presentationId, |
| 498 const blink::WebString& message) { | 493 const blink::WebString& message) { |
| 499 blink::mojom::PresentationSessionInfoPtr session_info = | 494 blink::mojom::PresentationSessionInfoPtr session_info = |
| 500 blink::mojom::PresentationSessionInfo::New(); | 495 blink::mojom::PresentationSessionInfo::New(); |
| 501 session_info->url = GURL(presentationUrl.utf8()); | 496 session_info->url = presentationUrl; |
| 497 // session_info->url = GURL(presentationUrl.utf8()); | |
|
imcheng
2016/09/14 00:39:13
rm this line
mark a. foltz
2016/09/14 20:02:42
Done.
mark a. foltz
2016/09/14 20:02:42
Done.
| |
| 502 session_info->id = presentationId.utf8(); | 498 session_info->id = presentationId.utf8(); |
| 503 | 499 |
| 504 blink::mojom::SessionMessagePtr session_message = | 500 blink::mojom::SessionMessagePtr session_message = |
| 505 blink::mojom::SessionMessage::New(); | 501 blink::mojom::SessionMessage::New(); |
| 506 session_message->type = blink::mojom::PresentationMessageType::TEXT; | 502 session_message->type = blink::mojom::PresentationMessageType::TEXT; |
| 507 session_message->message = message.utf8(); | 503 session_message->message = message.utf8(); |
| 508 return new SendMessageRequest(std::move(session_info), | 504 return new SendMessageRequest(std::move(session_info), |
| 509 std::move(session_message)); | 505 std::move(session_message)); |
| 510 } | 506 } |
| 511 | 507 |
| 512 // static | 508 // static |
| 513 PresentationDispatcher::SendMessageRequest* | 509 PresentationDispatcher::SendMessageRequest* |
| 514 PresentationDispatcher::CreateSendBinaryMessageRequest( | 510 PresentationDispatcher::CreateSendBinaryMessageRequest( |
| 515 const blink::WebString& presentationUrl, | 511 const blink::WebURL& presentationUrl, |
| 516 const blink::WebString& presentationId, | 512 const blink::WebString& presentationId, |
| 517 blink::mojom::PresentationMessageType type, | 513 blink::mojom::PresentationMessageType type, |
| 518 const uint8_t* data, | 514 const uint8_t* data, |
| 519 size_t length) { | 515 size_t length) { |
| 520 blink::mojom::PresentationSessionInfoPtr session_info = | 516 blink::mojom::PresentationSessionInfoPtr session_info = |
| 521 blink::mojom::PresentationSessionInfo::New(); | 517 blink::mojom::PresentationSessionInfo::New(); |
| 522 session_info->url = GURL(presentationUrl.utf8()); | 518 session_info->url = presentationUrl; |
| 519 // session_info->url = GURL(presentationUrl.utf8()); | |
|
imcheng
2016/09/14 00:39:14
ditto
mark a. foltz
2016/09/14 20:02:42
Done.
| |
| 523 session_info->id = presentationId.utf8(); | 520 session_info->id = presentationId.utf8(); |
| 524 | 521 |
| 525 blink::mojom::SessionMessagePtr session_message = | 522 blink::mojom::SessionMessagePtr session_message = |
| 526 blink::mojom::SessionMessage::New(); | 523 blink::mojom::SessionMessage::New(); |
| 527 session_message->type = type; | 524 session_message->type = type; |
| 528 session_message->data = std::vector<uint8_t>(data, data + length); | 525 session_message->data = std::vector<uint8_t>(data, data + length); |
| 529 return new SendMessageRequest(std::move(session_info), | 526 return new SendMessageRequest(std::move(session_info), |
| 530 std::move(session_message)); | 527 std::move(session_message)); |
| 531 } | 528 } |
| 532 | 529 |
| 533 PresentationDispatcher::AvailabilityStatus::AvailabilityStatus( | 530 PresentationDispatcher::AvailabilityStatus::AvailabilityStatus( |
| 534 const std::string& availability_url) | 531 const GURL& availability_url) |
| 535 : url(availability_url), | 532 : url(availability_url), |
| 536 last_known_availability(false), | 533 last_known_availability(false), |
| 537 listening_state(ListeningState::INACTIVE) {} | 534 listening_state(ListeningState::INACTIVE) {} |
| 538 | 535 |
| 539 PresentationDispatcher::AvailabilityStatus::~AvailabilityStatus() { | 536 PresentationDispatcher::AvailabilityStatus::~AvailabilityStatus() { |
| 540 } | 537 } |
| 541 | 538 |
| 542 } // namespace content | 539 } // namespace content |
| OLD | NEW |