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

Side by Side Diff: content/public/test/clipboard_write_observer.cc

Issue 12041078: Clear the clipboard closing Incognito window (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Selection clipboard support Created 7 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
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "clipboard_write_observer.h"
6
7 #include "content/public/test/test_utils.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace content {
11
12 ClipboardWriteObserver::ClipboardWriteObserver(ui::Clipboard* clipboard,
13 ui::Clipboard::Buffer buffer)
14 : seen_(false),
15 running_(false),
16 buffer_(buffer),
17 clipboard_(clipboard) {
18 clipboard_->AddObserver(this);
19 DCHECK(ui::Clipboard::IsValidBuffer(buffer_));
20 }
21
22 ClipboardWriteObserver::~ClipboardWriteObserver() {
23 clipboard_->RemoveObserver(this);
24 }
25
26 void ClipboardWriteObserver::Wait() {
27 if (seen_) return;
28
29 running_ = true;
30 message_loop_runner_ = new MessageLoopRunner;
31 message_loop_runner_->Run();
32 EXPECT_TRUE(seen_);
33 }
34
35 void ClipboardWriteObserver::OnWriteObjects(ui::Clipboard::Buffer buffer) {
36 if (buffer != buffer_) return;
37 seen_ = true;
38 if (!running_) return;
39
40 message_loop_runner_->Quit();
41 running_ = false;
42 }
43
44 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698