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

Unified Diff: content/browser/presentation/presentation_service_impl.cc

Issue 2174693004: [Presentation API] Add support to content/ for multiple URLs per PresentationRequest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated unittests. Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/presentation/presentation_service_impl.cc
diff --git a/content/browser/presentation/presentation_service_impl.cc b/content/browser/presentation/presentation_service_impl.cc
index 17ec835b5f3017cb2bf09d6e292e9a2c3798a26b..cde44f7c9881b5dd25e4e0eb524d85454b336f72 100644
--- a/content/browser/presentation/presentation_service_impl.cc
+++ b/content/browser/presentation/presentation_service_impl.cc
@@ -7,9 +7,7 @@
#include <stddef.h>
#include <stdint.h>
#include <algorithm>
-#include <string>
#include <utility>
-#include <vector>
#include "base/logging.h"
#include "base/stl_util.h"
@@ -218,8 +216,9 @@ void PresentationServiceImpl::StopListeningForScreenAvailability(
screen_availability_listeners_.erase(listener_it);
}
-void PresentationServiceImpl::StartSession(const mojo::String& presentation_url,
- const NewSessionCallback& callback) {
+void PresentationServiceImpl::StartSession(
+ mojo::Array<mojo::String> presentation_urls,
+ const NewSessionCallback& callback) {
DVLOG(2) << "StartSession";
if (!delegate_) {
callback.Run(
@@ -236,10 +235,15 @@ void PresentationServiceImpl::StartSession(const mojo::String& presentation_url,
return;
}
+ std::vector<std::string> urls(presentation_urls.size());
+ std::transform(presentation_urls.begin(), presentation_urls.end(),
+ urls.begin(),
+ [](const mojo::String& url) { return url.get(); });
+
start_session_request_id_ = GetNextRequestSessionId();
pending_start_session_cb_.reset(new NewSessionCallbackWrapper(callback));
delegate_->StartSession(
- render_process_id_, render_frame_id_, presentation_url,
+ render_process_id_, render_frame_id_, urls,
base::Bind(&PresentationServiceImpl::OnStartSessionSucceeded,
weak_factory_.GetWeakPtr(), start_session_request_id_),
base::Bind(&PresentationServiceImpl::OnStartSessionError,
@@ -247,7 +251,7 @@ void PresentationServiceImpl::StartSession(const mojo::String& presentation_url,
}
void PresentationServiceImpl::JoinSession(
- const mojo::String& presentation_url,
+ mojo::Array<mojo::String> presentation_urls,
const mojo::String& presentation_id,
const NewSessionCallback& callback) {
DVLOG(2) << "JoinSession";
@@ -264,11 +268,13 @@ void PresentationServiceImpl::JoinSession(
InvokeNewSessionCallbackWithError(callback);
return;
}
+ std::vector<std::string> urls(presentation_urls.size());
+ std::transform(presentation_urls.begin(), presentation_urls.end(),
+ urls.begin(),
+ [](const mojo::String& url) { return url.get(); });
+
delegate_->JoinSession(
- render_process_id_,
- render_frame_id_,
- presentation_url,
- presentation_id,
+ render_process_id_, render_frame_id_, urls, presentation_id,
base::Bind(&PresentationServiceImpl::OnJoinSessionSucceeded,
weak_factory_.GetWeakPtr(), request_session_id),
base::Bind(&PresentationServiceImpl::OnJoinSessionError,
@@ -357,19 +363,23 @@ bool PresentationServiceImpl::RunAndEraseJoinSessionMojoCallback(
return true;
}
-void PresentationServiceImpl::SetDefaultPresentationURL(
- const mojo::String& url) {
- DVLOG(2) << "SetDefaultPresentationURL";
+void PresentationServiceImpl::SetDefaultPresentationUrls(
+ mojo::Array<mojo::String> presentation_urls) {
+ DVLOG(2) << "SetDefaultPresentationUrls";
if (!delegate_)
return;
- const std::string& new_default_url = url.get();
- if (default_presentation_url_ == new_default_url)
+ std::vector<std::string> new_default_urls(presentation_urls.size());
+ std::transform(presentation_urls.begin(), presentation_urls.end(),
+ new_default_urls.begin(),
+ [](const mojo::String& url) { return url.get(); });
+
+ if (default_presentation_urls_ == new_default_urls)
return;
- default_presentation_url_ = new_default_url;
- delegate_->SetDefaultPresentationUrl(
- render_process_id_, render_frame_id_, new_default_url,
+ default_presentation_urls_ = new_default_urls;
+ delegate_->SetDefaultPresentationUrls(
+ render_process_id_, render_frame_id_, new_default_urls,
base::Bind(&PresentationServiceImpl::OnDefaultPresentationStarted,
weak_factory_.GetWeakPtr()));
}
@@ -523,7 +533,7 @@ void PresentationServiceImpl::Reset() {
if (delegate_)
delegate_->Reset(render_process_id_, render_frame_id_);
- default_presentation_url_.clear();
+ default_presentation_urls_.clear();
screen_availability_listeners_.clear();

Powered by Google App Engine
This is Rietveld 408576698