Index: remoting/client/plugin/chromoting_instance.cc |
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc |
index 6bb34a852af25cdd67265a94a87402dd7c832f92..b3c28d39fa0b9591fe2c12bc8e8296c29b521a0c 100644 |
--- a/remoting/client/plugin/chromoting_instance.cc |
+++ b/remoting/client/plugin/chromoting_instance.cc |
@@ -330,7 +330,7 @@ void ChromotingInstance::DidChangeView(const pp::Rect& position, |
bool ChromotingInstance::HandleInputEvent(const pp::InputEvent& event) { |
DCHECK(plugin_message_loop_->BelongsToCurrentThread()); |
- if (!input_handler_.get()) |
+ if (!IsConnected()) |
return false; |
// TODO(wez): When we have a good hook into Host dimensions changes, move |
@@ -452,13 +452,13 @@ void ChromotingInstance::OnIncomingIq(const std::string& iq) { |
} |
void ChromotingInstance::ReleaseAllKeys() { |
- if (input_tracker_.get()) |
+ if (IsConnected()) |
input_tracker_->ReleaseAll(); |
} |
void ChromotingInstance::InjectKeyEvent(const protocol::KeyEvent& event) { |
// Inject after the KeyEventMapper, so the event won't get mapped or trapped. |
- if (input_tracker_.get()) |
+ if (IsConnected()) |
input_tracker_->InjectKeyEvent(event); |
} |
@@ -473,7 +473,7 @@ void ChromotingInstance::TrapKey(uint32 usb_keycode, bool trap) { |
void ChromotingInstance::SendClipboardItem(const std::string& mime_type, |
const std::string& item) { |
- if (!host_connection_.get()) { |
+ if (!IsConnected()) { |
return; |
} |
protocol::ClipboardEvent event; |
@@ -483,7 +483,7 @@ void ChromotingInstance::SendClipboardItem(const std::string& mime_type, |
} |
void ChromotingInstance::NotifyClientDimensions(int width, int height) { |
- if (!host_connection_.get()) { |
+ if (!IsConnected()) { |
return; |
} |
protocol::ClientDimensions client_dimensions; |
@@ -654,4 +654,9 @@ void ChromotingInstance::ProcessLogToUI(const std::string& message) { |
g_logging_to_plugin = false; |
} |
+bool ChromotingInstance::IsConnected() { |
+ return host_connection_.get() && |
+ (host_connection_->state() == protocol::ConnectionToHost::CONNECTED); |
+} |
+ |
} // namespace remoting |