| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "webkit/glue/scoped_clipboard_writer_glue.h" | |
| 6 #include "base/logging.h" | |
| 7 | |
| 8 namespace webkit_glue { | |
| 9 | |
| 10 ScopedClipboardWriterGlue::ScopedClipboardWriterGlue( | |
| 11 webkit_glue::ClipboardClient* client) | |
| 12 : ui::ScopedClipboardWriter(client->GetClipboard(), | |
| 13 ui::Clipboard::BUFFER_STANDARD), | |
| 14 context_(client->CreateWriteContext()) { | |
| 15 // We should never have an instance where both are set. | |
| 16 DCHECK((clipboard_ && !context_.get()) || | |
| 17 (!clipboard_ && context_.get())); | |
| 18 } | |
| 19 | |
| 20 ScopedClipboardWriterGlue::~ScopedClipboardWriterGlue() { | |
| 21 if (!objects_.empty() && context_) { | |
| 22 context_->Flush(objects_); | |
| 23 } | |
| 24 } | |
| 25 | |
| 26 void ScopedClipboardWriterGlue::WriteBitmapFromPixels(const void* pixels, | |
| 27 const gfx::Size& size) { | |
| 28 if (context_) { | |
| 29 context_->WriteBitmapFromPixels(&objects_, pixels, size); | |
| 30 } else { | |
| 31 ScopedClipboardWriter::WriteBitmapFromPixels(pixels, size); | |
| 32 } | |
| 33 } | |
| 34 | |
| 35 } // namespace webkit_glue | |
| OLD | NEW |