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

Unified Diff: components/proximity_auth/messenger_impl.cc

Issue 1375633004: Encrypting messages send/received from BLE devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new_test_tim
Patch Set: Using old protocol for BLE devices Created 5 years, 3 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
« no previous file with comments | « components/proximity_auth/messenger_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/proximity_auth/messenger_impl.cc
diff --git a/components/proximity_auth/messenger_impl.cc b/components/proximity_auth/messenger_impl.cc
index aab4adee94b075eb0c7d274a2d639fb1fa854058..6e23d6d1156c3ece4b69a4c0e7a9594ddbe3b0a4 100644
--- a/components/proximity_auth/messenger_impl.cc
+++ b/components/proximity_auth/messenger_impl.cc
@@ -94,7 +94,9 @@ void MessengerImpl::RemoveObserver(MessengerObserver* observer) {
bool MessengerImpl::SupportsSignIn() const {
return (secure_context_->GetProtocolVersion() ==
- SecureContext::PROTOCOL_VERSION_THREE_ONE);
+ SecureContext::PROTOCOL_VERSION_THREE_ONE) &&
+ connection_->remote_device().bluetooth_type !=
+ RemoteDevice::BLUETOOTH_LE;
}
void MessengerImpl::DispatchUnlockEvent() {
@@ -147,6 +149,9 @@ MessengerImpl::PendingMessage::PendingMessage(
: json_message(SerializeValueToJson(message)),
type(GetMessageType(message)) {}
+MessengerImpl::PendingMessage::PendingMessage(const std::string& message)
+ : json_message(message), type("") {}
+
MessengerImpl::PendingMessage::~PendingMessage() {}
void MessengerImpl::ProcessMessageQueue() {
@@ -167,6 +172,21 @@ void MessengerImpl::OnMessageEncoded(const std::string& encoded_message) {
}
void MessengerImpl::OnMessageDecoded(const std::string& decoded_message) {
+ // TODO(tengs): Unify the iOS status update protocol with the existing Android
+ // protocol, so we don't have this special case.
+ if (decoded_message == kScreenUnlocked || decoded_message == kScreenLocked) {
+ RemoteStatusUpdate update;
+ update.user_presence =
+ (decoded_message == kScreenUnlocked ? USER_PRESENT : USER_ABSENT);
+ update.secure_screen_lock_state = SECURE_SCREEN_LOCK_ENABLED;
+ update.trust_agent_state = TRUST_AGENT_ENABLED;
+ FOR_EACH_OBSERVER(MessengerObserver, observers_,
+ OnRemoteStatusUpdate(update));
+ pending_message_.reset();
+ ProcessMessageQueue();
+ return;
+ }
+
// The decoded message should be a JSON string.
scoped_ptr<base::Value> message_value =
base::JSONReader::Read(decoded_message);
@@ -264,7 +284,8 @@ void MessengerImpl::PollScreenStateForIOS() {
return;
// Sends message requesting screen state.
- connection_->SendMessage(make_scoped_ptr(new WireMessage(kPollScreenState)));
+ queued_messages_.push_back(PendingMessage(std::string(kPollScreenState)));
+ ProcessMessageQueue();
// Schedules the next message in |kPollingIntervalSeconds|.
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
@@ -288,20 +309,6 @@ void MessengerImpl::OnConnectionStatusChanged(Connection* connection,
void MessengerImpl::OnMessageReceived(const Connection& connection,
const WireMessage& wire_message) {
- // TODO(tengs): Unify the iOS status update protocol with the existing Android
- // protocol, so we don't have this special case.
- std::string payload = wire_message.payload();
- if (payload == kScreenUnlocked || payload == kScreenLocked) {
- RemoteStatusUpdate update;
- update.user_presence =
- (payload == kScreenUnlocked ? USER_PRESENT : USER_ABSENT);
- update.secure_screen_lock_state = SECURE_SCREEN_LOCK_ENABLED;
- update.trust_agent_state = TRUST_AGENT_ENABLED;
- FOR_EACH_OBSERVER(MessengerObserver, observers_,
- OnRemoteStatusUpdate(update));
- return;
- }
-
secure_context_->Decode(wire_message.payload(),
base::Bind(&MessengerImpl::OnMessageDecoded,
weak_ptr_factory_.GetWeakPtr()));
« no previous file with comments | « components/proximity_auth/messenger_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698