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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/api/cast_channel/cast_socket.h" 5 #include "extensions/browser/api/cast_channel/cast_socket.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 CastSocket::CastSocket(const std::string& owner_extension_id) 83 CastSocket::CastSocket(const std::string& owner_extension_id)
84 : ApiResource(owner_extension_id) { 84 : ApiResource(owner_extension_id) {
85 } 85 }
86 86
87 CastSocketImpl::CastSocketImpl(const std::string& owner_extension_id, 87 CastSocketImpl::CastSocketImpl(const std::string& owner_extension_id,
88 const net::IPEndPoint& ip_endpoint, 88 const net::IPEndPoint& ip_endpoint,
89 ChannelAuthType channel_auth, 89 ChannelAuthType channel_auth,
90 net::NetLog* net_log, 90 net::NetLog* net_log,
91 const base::TimeDelta& timeout, 91 const base::TimeDelta& timeout,
92 const scoped_refptr<Logger>& logger) 92 const scoped_refptr<Logger>& logger,
93 long device_capabilities)
93 : CastSocket(owner_extension_id), 94 : CastSocket(owner_extension_id),
94 auth_delegate_(this), 95 auth_delegate_(this),
95 owner_extension_id_(owner_extension_id), 96 owner_extension_id_(owner_extension_id),
96 channel_id_(0), 97 channel_id_(0),
97 ip_endpoint_(ip_endpoint), 98 ip_endpoint_(ip_endpoint),
98 channel_auth_(channel_auth), 99 channel_auth_(channel_auth),
99 net_log_(net_log), 100 net_log_(net_log),
100 logger_(logger), 101 logger_(logger),
101 connect_timeout_(timeout), 102 connect_timeout_(timeout),
102 connect_timeout_timer_(new base::OneShotTimer<CastSocketImpl>), 103 connect_timeout_timer_(new base::OneShotTimer<CastSocketImpl>),
103 is_canceled_(false), 104 is_canceled_(false),
105 device_capabilities_(device_capabilities),
104 connect_state_(proto::CONN_STATE_NONE), 106 connect_state_(proto::CONN_STATE_NONE),
105 error_state_(CHANNEL_ERROR_NONE), 107 error_state_(CHANNEL_ERROR_NONE),
106 ready_state_(READY_STATE_NONE) { 108 ready_state_(READY_STATE_NONE) {
107 DCHECK(net_log_); 109 DCHECK(net_log_);
108 DCHECK(channel_auth_ == CHANNEL_AUTH_TYPE_SSL || 110 DCHECK(channel_auth_ == CHANNEL_AUTH_TYPE_SSL ||
109 channel_auth_ == CHANNEL_AUTH_TYPE_SSL_VERIFIED); 111 channel_auth_ == CHANNEL_AUTH_TYPE_SSL_VERIFIED);
110 net_log_source_.type = net::NetLog::SOURCE_SOCKET; 112 net_log_source_.type = net::NetLog::SOURCE_SOCKET;
111 net_log_source_.id = net_log_->NextID(); 113 net_log_source_.id = net_log_->NextID();
112 } 114 }
113 115
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 ssl_info.cert->os_cert_handle(), cert); 211 ssl_info.cert->os_cert_handle(), cert);
210 if (result) { 212 if (result) {
211 VLOG_WITH_CONNECTION(1) << "Successfully extracted peer certificate"; 213 VLOG_WITH_CONNECTION(1) << "Successfully extracted peer certificate";
212 } 214 }
213 215
214 logger_->LogSocketEventWithRv( 216 logger_->LogSocketEventWithRv(
215 channel_id_, proto::DER_ENCODED_CERT_OBTAIN, result ? 1 : 0); 217 channel_id_, proto::DER_ENCODED_CERT_OBTAIN, result ? 1 : 0);
216 return result; 218 return result;
217 } 219 }
218 220
221 bool CastSocketImpl::VerifyChannelPolicy(const AuthResult& result) {
222 if ((device_capabilities_ & CastDeviceCapability::VIDEO_OUT) != 0 &&
223 (result.channel_policies & AuthResult::POLICY_AUDIO_ONLY) != 0) {
224 LOG(ERROR) << "Audio only policy enforced";
225 logger_->LogSocketEventWithDetails(
226 channel_id_, proto::CHANNEL_POLICY_ENFORCED, std::string());
227 return false;
228 }
229 return true;
230 }
231
219 bool CastSocketImpl::VerifyChallengeReply() { 232 bool CastSocketImpl::VerifyChallengeReply() {
220 AuthResult result = AuthenticateChallengeReply(*challenge_reply_, peer_cert_); 233 AuthResult result = AuthenticateChallengeReply(*challenge_reply_, peer_cert_);
221 if (result.success()) { 234 if (result.success()) {
222 VLOG(1) << result.error_message; 235 VLOG(1) << result.error_message;
236 if (!VerifyChannelPolicy(result)) {
237 return false;
238 }
223 } 239 }
224 logger_->LogSocketChallengeReplyEvent(channel_id_, result); 240 logger_->LogSocketChallengeReplyEvent(channel_id_, result);
225 return result.success(); 241 return result.success();
226 } 242 }
227 243
228 void CastSocketImpl::SetTransportForTesting( 244 void CastSocketImpl::SetTransportForTesting(
229 scoped_ptr<CastTransport> transport) { 245 scoped_ptr<CastTransport> transport) {
230 transport_ = transport.Pass(); 246 transport_ = transport.Pass();
231 } 247 }
232 248
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 void CastSocketImpl::SetErrorState(ChannelError error_state) { 576 void CastSocketImpl::SetErrorState(ChannelError error_state) {
561 VLOG_WITH_CONNECTION(1) << "SetErrorState " << error_state; 577 VLOG_WITH_CONNECTION(1) << "SetErrorState " << error_state;
562 DCHECK_EQ(CHANNEL_ERROR_NONE, error_state_); 578 DCHECK_EQ(CHANNEL_ERROR_NONE, error_state_);
563 error_state_ = error_state; 579 error_state_ = error_state;
564 logger_->LogSocketErrorState(channel_id_, ErrorStateToProto(error_state_)); 580 logger_->LogSocketErrorState(channel_id_, ErrorStateToProto(error_state_));
565 } 581 }
566 } // namespace cast_channel 582 } // namespace cast_channel
567 } // namespace core_api 583 } // namespace core_api
568 } // namespace extensions 584 } // namespace extensions
569 #undef VLOG_WITH_CONNECTION 585 #undef VLOG_WITH_CONNECTION
OLDNEW
« 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