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

Unified Diff: extensions/browser/api/cast_channel/cast_socket.cc

Issue 807723004: Cast audio only policy enforcement support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed windows compiler warning Created 5 years, 11 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: extensions/browser/api/cast_channel/cast_socket.cc
diff --git a/extensions/browser/api/cast_channel/cast_socket.cc b/extensions/browser/api/cast_channel/cast_socket.cc
index 0fc70cb3a2a4ca0904de31b0365e2b80b6213d2f..8fc457040fae5f7e77b1ccf777dd4f348626d5e4 100644
--- a/extensions/browser/api/cast_channel/cast_socket.cc
+++ b/extensions/browser/api/cast_channel/cast_socket.cc
@@ -89,7 +89,8 @@ CastSocketImpl::CastSocketImpl(const std::string& owner_extension_id,
ChannelAuthType channel_auth,
net::NetLog* net_log,
const base::TimeDelta& timeout,
- const scoped_refptr<Logger>& logger)
+ const scoped_refptr<Logger>& logger,
+ long device_capabilities)
: CastSocket(owner_extension_id),
auth_delegate_(this),
owner_extension_id_(owner_extension_id),
@@ -101,6 +102,7 @@ CastSocketImpl::CastSocketImpl(const std::string& owner_extension_id,
connect_timeout_(timeout),
connect_timeout_timer_(new base::OneShotTimer<CastSocketImpl>),
is_canceled_(false),
+ device_capabilities_(device_capabilities),
connect_state_(proto::CONN_STATE_NONE),
error_state_(CHANNEL_ERROR_NONE),
ready_state_(READY_STATE_NONE) {
@@ -216,10 +218,24 @@ bool CastSocketImpl::ExtractPeerCert(std::string* cert) {
return result;
}
+bool CastSocketImpl::VerifyChannelPolicy(const AuthResult& result) {
+ if ((device_capabilities_ & CastDeviceCapability::VIDEO_OUT) != 0 &&
+ (result.channel_policies & AuthResult::POLICY_AUDIO_ONLY) != 0) {
+ LOG(ERROR) << "Audio only policy enforced";
+ logger_->LogSocketEventWithDetails(
+ channel_id_, proto::CHANNEL_POLICY_ENFORCED, std::string());
+ return false;
+ }
+ return true;
+}
+
bool CastSocketImpl::VerifyChallengeReply() {
AuthResult result = AuthenticateChallengeReply(*challenge_reply_, peer_cert_);
if (result.success()) {
VLOG(1) << result.error_message;
+ if (!VerifyChannelPolicy(result)) {
+ return false;
+ }
}
logger_->LogSocketChallengeReplyEvent(channel_id_, result);
return result.success();
« no previous file with comments | « extensions/browser/api/cast_channel/cast_socket.h ('k') | extensions/browser/api/cast_channel/cast_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698