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..2f67eb0449237b0a0a7b2c11dac36a476fa75515 100644 |
--- a/extensions/browser/api/cast_channel/cast_socket.cc |
+++ b/extensions/browser/api/cast_channel/cast_socket.cc |
@@ -62,6 +62,15 @@ std::string FormatTimeForLogging(base::Time time) { |
exploded.millisecond); |
} |
+// Cast device capabilities. |
+enum CastDeviceCapability { |
+ VIDEO_OUT = 1 << 0, |
+ VIDEO_IN = 1 << 1, |
+ AUDIO_OUT = 1 << 2, |
+ AUDIO_IN = 1 << 3, |
+ DEV_MODE = 1 << 4 |
+}; |
+ |
} // namespace |
namespace extensions { |
@@ -89,7 +98,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 +111,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 +227,25 @@ bool CastSocketImpl::ExtractPeerCert(std::string* cert) { |
return result; |
} |
+bool CastSocketImpl::VerifyChannelPolicy(const AuthResult& result) { |
+ if ((device_capabilities_ & CastDeviceCapability::VIDEO_OUT) != 0) { |
mark a. foltz
2015/01/13 01:42:19
No reason to have nested if() statements; use &&
vadimgo
2015/01/13 02:21:44
Done.
|
+ if ((result.channel_policy & 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(); |