| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "remoting/host/it2me/it2me_native_messaging_host.h" | 5 #include "remoting/host/it2me/it2me_native_messaging_host.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 namespace remoting { | 26 namespace remoting { |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 const remoting::protocol::NameMapElement<It2MeHostState> kIt2MeHostStates[] = { | 30 const remoting::protocol::NameMapElement<It2MeHostState> kIt2MeHostStates[] = { |
| 31 {kDisconnected, "DISCONNECTED"}, | 31 {kDisconnected, "DISCONNECTED"}, |
| 32 {kStarting, "STARTING"}, | 32 {kStarting, "STARTING"}, |
| 33 {kRequestedAccessCode, "REQUESTED_ACCESS_CODE"}, | 33 {kRequestedAccessCode, "REQUESTED_ACCESS_CODE"}, |
| 34 {kReceivedAccessCode, "RECEIVED_ACCESS_CODE"}, | 34 {kReceivedAccessCode, "RECEIVED_ACCESS_CODE"}, |
| 35 {kConnected, "CONNECTED"}, | 35 {kConnected, "CONNECTED"}, |
| 36 {kDisconnecting, "DISCONNECTING"}, | |
| 37 {kError, "ERROR"}, | 36 {kError, "ERROR"}, |
| 38 {kInvalidDomainError, "INVALID_DOMAIN_ERROR"}, | 37 {kInvalidDomainError, "INVALID_DOMAIN_ERROR"}, |
| 39 }; | 38 }; |
| 40 | 39 |
| 41 } // namespace | 40 } // namespace |
| 42 | 41 |
| 43 It2MeNativeMessagingHost::It2MeNativeMessagingHost( | 42 It2MeNativeMessagingHost::It2MeNativeMessagingHost( |
| 44 scoped_ptr<ChromotingHostContext> context, | 43 scoped_ptr<ChromotingHostContext> context, |
| 45 scoped_ptr<It2MeHostFactory> factory) | 44 scoped_ptr<It2MeHostFactory> factory) |
| 46 : client_(nullptr), | 45 : client_(nullptr), |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 void It2MeNativeMessagingHost::OnStateChanged( | 247 void It2MeNativeMessagingHost::OnStateChanged( |
| 249 It2MeHostState state, | 248 It2MeHostState state, |
| 250 const std::string& error_message) { | 249 const std::string& error_message) { |
| 251 DCHECK(task_runner()->BelongsToCurrentThread()); | 250 DCHECK(task_runner()->BelongsToCurrentThread()); |
| 252 | 251 |
| 253 state_ = state; | 252 state_ = state; |
| 254 | 253 |
| 255 scoped_ptr<base::DictionaryValue> message(new base::DictionaryValue()); | 254 scoped_ptr<base::DictionaryValue> message(new base::DictionaryValue()); |
| 256 | 255 |
| 257 message->SetString("type", "hostStateChanged"); | 256 message->SetString("type", "hostStateChanged"); |
| 258 message->SetString("state", | 257 message->SetString("state", HostStateToString(state)); |
| 259 It2MeNativeMessagingHost::HostStateToString(state)); | |
| 260 | 258 |
| 261 switch (state_) { | 259 switch (state_) { |
| 262 case kReceivedAccessCode: | 260 case kReceivedAccessCode: |
| 263 message->SetString("accessCode", access_code_); | 261 message->SetString("accessCode", access_code_); |
| 264 message->SetInteger("accessCodeLifetime", | 262 message->SetInteger("accessCodeLifetime", |
| 265 access_code_lifetime_.InSeconds()); | 263 access_code_lifetime_.InSeconds()); |
| 266 break; | 264 break; |
| 267 | 265 |
| 268 case kConnected: | 266 case kConnected: |
| 269 message->SetString("client", client_username_); | 267 message->SetString("client", client_username_); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 return host_context_->ui_task_runner(); | 319 return host_context_->ui_task_runner(); |
| 322 } | 320 } |
| 323 | 321 |
| 324 /* static */ | 322 /* static */ |
| 325 std::string It2MeNativeMessagingHost::HostStateToString( | 323 std::string It2MeNativeMessagingHost::HostStateToString( |
| 326 It2MeHostState host_state) { | 324 It2MeHostState host_state) { |
| 327 return ValueToName(kIt2MeHostStates, host_state); | 325 return ValueToName(kIt2MeHostStates, host_state); |
| 328 } | 326 } |
| 329 | 327 |
| 330 } // namespace remoting | 328 } // namespace remoting |
| OLD | NEW |