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

Side by Side Diff: remoting/host/clipboard_win.cc

Issue 930403002: Remove remoting::Clipboard::Stop(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « remoting/host/clipboard_mac.mm ('k') | remoting/host/clipboard_x11.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/clipboard.h" 5 #include "remoting/host/clipboard.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 typedef BOOL (WINAPI AddClipboardFormatListenerFn)(HWND); 100 typedef BOOL (WINAPI AddClipboardFormatListenerFn)(HWND);
101 typedef BOOL (WINAPI RemoveClipboardFormatListenerFn)(HWND); 101 typedef BOOL (WINAPI RemoveClipboardFormatListenerFn)(HWND);
102 102
103 } // namespace 103 } // namespace
104 104
105 namespace remoting { 105 namespace remoting {
106 106
107 class ClipboardWin : public Clipboard { 107 class ClipboardWin : public Clipboard {
108 public: 108 public:
109 ClipboardWin(); 109 ClipboardWin();
110 ~ClipboardWin() override;
110 111
111 virtual void Start( 112 virtual void Start(
112 scoped_ptr<protocol::ClipboardStub> client_clipboard) override; 113 scoped_ptr<protocol::ClipboardStub> client_clipboard) override;
113 virtual void InjectClipboardEvent( 114 virtual void InjectClipboardEvent(
114 const protocol::ClipboardEvent& event) override; 115 const protocol::ClipboardEvent& event) override;
115 virtual void Stop() override;
116 116
117 private: 117 private:
118 void OnClipboardUpdate(); 118 void OnClipboardUpdate();
119 119
120 // Handles messages received by |window_|. 120 // Handles messages received by |window_|.
121 bool HandleMessage(UINT message, 121 bool HandleMessage(UINT message,
122 WPARAM wparam, 122 WPARAM wparam,
123 LPARAM lparam, 123 LPARAM lparam,
124 LRESULT* result); 124 LRESULT* result);
125 125
126 scoped_ptr<protocol::ClipboardStub> client_clipboard_; 126 scoped_ptr<protocol::ClipboardStub> client_clipboard_;
127 AddClipboardFormatListenerFn* add_clipboard_format_listener_; 127 AddClipboardFormatListenerFn* add_clipboard_format_listener_;
128 RemoveClipboardFormatListenerFn* remove_clipboard_format_listener_; 128 RemoveClipboardFormatListenerFn* remove_clipboard_format_listener_;
129 129
130 // Used to subscribe to WM_CLIPBOARDUPDATE messages. 130 // Used to subscribe to WM_CLIPBOARDUPDATE messages.
131 scoped_ptr<base::win::MessageWindow> window_; 131 scoped_ptr<base::win::MessageWindow> window_;
132 132
133 DISALLOW_COPY_AND_ASSIGN(ClipboardWin); 133 DISALLOW_COPY_AND_ASSIGN(ClipboardWin);
134 }; 134 };
135 135
136 ClipboardWin::ClipboardWin() 136 ClipboardWin::ClipboardWin()
137 : add_clipboard_format_listener_(nullptr), 137 : add_clipboard_format_listener_(nullptr),
138 remove_clipboard_format_listener_(nullptr) { 138 remove_clipboard_format_listener_(nullptr) {
139 } 139 }
140 140
141 ClipboardWin::~ClipboardWin() {
142 if (window_ && remove_clipboard_format_listener_)
143 (*remove_clipboard_format_listener_)(window_->hwnd());
144 }
145
141 void ClipboardWin::Start( 146 void ClipboardWin::Start(
142 scoped_ptr<protocol::ClipboardStub> client_clipboard) { 147 scoped_ptr<protocol::ClipboardStub> client_clipboard) {
143 DCHECK(!add_clipboard_format_listener_); 148 DCHECK(!add_clipboard_format_listener_);
144 DCHECK(!remove_clipboard_format_listener_); 149 DCHECK(!remove_clipboard_format_listener_);
145 DCHECK(!window_); 150 DCHECK(!window_);
146 151
147 client_clipboard_.swap(client_clipboard); 152 client_clipboard_.swap(client_clipboard);
148 153
149 // user32.dll is statically linked. 154 // user32.dll is statically linked.
150 HMODULE user32 = GetModuleHandle(L"user32.dll"); 155 HMODULE user32 = GetModuleHandle(L"user32.dll");
(...skipping 21 matching lines...) Expand all
172 return; 177 return;
173 } 178 }
174 179
175 if (add_clipboard_format_listener_) { 180 if (add_clipboard_format_listener_) {
176 if (!(*add_clipboard_format_listener_)(window_->hwnd())) { 181 if (!(*add_clipboard_format_listener_)(window_->hwnd())) {
177 LOG(WARNING) << "AddClipboardFormatListener() failed: " << GetLastError(); 182 LOG(WARNING) << "AddClipboardFormatListener() failed: " << GetLastError();
178 } 183 }
179 } 184 }
180 } 185 }
181 186
182 void ClipboardWin::Stop() {
183 client_clipboard_.reset();
184
185 if (window_ && remove_clipboard_format_listener_)
186 (*remove_clipboard_format_listener_)(window_->hwnd());
187
188 window_.reset();
189 }
190
191 void ClipboardWin::InjectClipboardEvent( 187 void ClipboardWin::InjectClipboardEvent(
192 const protocol::ClipboardEvent& event) { 188 const protocol::ClipboardEvent& event) {
193 if (!window_) 189 if (!window_)
194 return; 190 return;
195 191
196 // Currently we only handle UTF-8 text. 192 // Currently we only handle UTF-8 text.
197 if (event.mime_type().compare(kMimeTypeTextUtf8) != 0) 193 if (event.mime_type().compare(kMimeTypeTextUtf8) != 0)
198 return; 194 return;
199 if (!StringIsUtf8(event.data().c_str(), event.data().length())) { 195 if (!StringIsUtf8(event.data().c_str(), event.data().length())) {
200 LOG(ERROR) << "ClipboardEvent: data is not UTF-8 encoded."; 196 LOG(ERROR) << "ClipboardEvent: data is not UTF-8 encoded.";
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 } 271 }
276 272
277 return false; 273 return false;
278 } 274 }
279 275
280 scoped_ptr<Clipboard> Clipboard::Create() { 276 scoped_ptr<Clipboard> Clipboard::Create() {
281 return make_scoped_ptr(new ClipboardWin()); 277 return make_scoped_ptr(new ClipboardWin());
282 } 278 }
283 279
284 } // namespace remoting 280 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/clipboard_mac.mm ('k') | remoting/host/clipboard_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698