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

Side by Side Diff: content/renderer/scoped_clipboard_writer_glue.cc

Issue 558913003: Remove clipboard argument from ScopedClipboardWriter constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't leak a clipboard on Windows Created 6 years, 3 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
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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 "content/renderer/scoped_clipboard_writer_glue.h" 5 #include "content/renderer/scoped_clipboard_writer_glue.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 7
8 namespace content { 8 namespace content {
9 9
10 ScopedClipboardWriterGlue::ScopedClipboardWriterGlue(ClipboardClient* client) 10 ScopedClipboardWriterGlue::ScopedClipboardWriterGlue(ClipboardClient* client)
11 : ui::ScopedClipboardWriter(client->GetClipboard(), 11 : ui::ScopedClipboardWriter(ui::CLIPBOARD_TYPE_COPY_PASTE),
12 ui::CLIPBOARD_TYPE_COPY_PASTE),
13 context_(client->CreateWriteContext()) { 12 context_(client->CreateWriteContext()) {
14 // We should never have an instance where both are set. 13 DCHECK(context_);
15 DCHECK((clipboard_ && !context_.get()) ||
16 (!clipboard_ && context_.get()));
17 } 14 }
18 15
19 ScopedClipboardWriterGlue::~ScopedClipboardWriterGlue() { 16 ScopedClipboardWriterGlue::~ScopedClipboardWriterGlue() {
20 if (!objects_.empty() && context_) { 17 if (!objects_.empty() && context_) {
21 context_->Flush(objects_); 18 context_->Flush(objects_);
19 // TODO(dcheng): Temporary hack while the clipboard IPCs are cleaned up.
20 // This prevents the base class destructor from also trying to (probably
21 // unsuccessfully) flush things to the clipboard.
22 objects_.clear();
22 } 23 }
23 } 24 }
24 25
25 void ScopedClipboardWriterGlue::WriteBitmapFromPixels(const void* pixels, 26 void ScopedClipboardWriterGlue::WriteBitmapFromPixels(const void* pixels,
26 const gfx::Size& size) { 27 const gfx::Size& size) {
27 if (context_) { 28 if (context_) {
28 context_->WriteBitmapFromPixels(&objects_, pixels, size); 29 context_->WriteBitmapFromPixels(&objects_, pixels, size);
29 } else { 30 } else {
30 NOTREACHED(); 31 NOTREACHED();
31 } 32 }
32 } 33 }
33 34
34 } // namespace content 35 } // namespace content
35 36
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.cc ('k') | ui/base/clipboard/clipboard_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698