Index: components/arc/arc_bridge_service.cc |
diff --git a/components/arc/arc_bridge_service.cc b/components/arc/arc_bridge_service.cc |
index 2d10d8a468d1e9ed5c41ae273a15c436f1e980ce..37c6d70d76fa88723f23f5c88a171536f76f3d21 100644 |
--- a/components/arc/arc_bridge_service.cc |
+++ b/components/arc/arc_bridge_service.cc |
@@ -80,6 +80,31 @@ void ArcBridgeService::CloseAppChannel() { |
FOR_EACH_OBSERVER(Observer, observer_list(), OnAppInstanceClosed()); |
} |
+void ArcBridgeService::OnClipboardInstanceReady( |
+ ClipboardInstancePtr clipboard_ptr) { |
+ DCHECK(CalledOnValidThread()); |
+ temporary_clipboard_ptr_ = std::move(clipboard_ptr); |
+ temporary_clipboard_ptr_.QueryVersion(base::Bind( |
+ &ArcBridgeService::OnClipboardVersionReady, weak_factory_.GetWeakPtr())); |
+} |
+ |
+void ArcBridgeService::OnClipboardVersionReady(int32_t version) { |
+ DCHECK(CalledOnValidThread()); |
+ clipboard_ptr_ = std::move(temporary_clipboard_ptr_); |
+ FOR_EACH_OBSERVER(Observer, observer_list(), OnClipboardInstanceReady()); |
+ clipboard_ptr_.set_connection_error_handler(base::Bind( |
+ &ArcBridgeService::CloseClipboardChannel, weak_factory_.GetWeakPtr())); |
+} |
+ |
+void ArcBridgeService::CloseClipboardChannel() { |
+ DCHECK(CalledOnValidThread()); |
+ if (!clipboard_ptr_) |
+ return; |
+ |
+ clipboard_ptr_.reset(); |
+ FOR_EACH_OBSERVER(Observer, observer_list(), OnClipboardInstanceClosed()); |
+} |
+ |
void ArcBridgeService::OnInputInstanceReady(InputInstancePtr input_ptr) { |
DCHECK(CalledOnValidThread()); |
temporary_input_ptr_ = std::move(input_ptr); |
@@ -226,6 +251,7 @@ void ArcBridgeService::CloseAllChannels() { |
// Call all the error handlers of all the channels to both close the channel |
// and notify any observers that the channel is closed. |
CloseAppChannel(); |
+ CloseClipboardChannel(); |
CloseInputChannel(); |
CloseNotificationsChannel(); |
ClosePowerChannel(); |