Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This file implements the ScopedClipboardWriter class. Documentation on its | 5 // This file implements the ScopedClipboardWriter class. Documentation on its |
| 6 // purpose can be found in our header. Documentation on the format of the | 6 // purpose can be found in our header. Documentation on the format of the |
| 7 // parameters for each clipboard target can be found in clipboard.h. | 7 // parameters for each clipboard target can be found in clipboard.h. |
| 8 | 8 |
| 9 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 9 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| 10 | 10 |
| 11 #include "base/pickle.h" | 11 #include "base/pickle.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "ui/gfx/size.h" | 13 #include "ui/gfx/size.h" |
| 14 | 14 |
| 15 namespace ui { | 15 namespace ui { |
| 16 | 16 |
| 17 ScopedClipboardWriter::ScopedClipboardWriter(Clipboard* clipboard) | 17 ScopedClipboardWriter::ScopedClipboardWriter(Clipboard* clipboard, |
| 18 : clipboard_(clipboard) { | 18 Clipboard::Buffer buffer) |
| 19 : clipboard_(clipboard), buffer_(buffer) { | |
|
sky
2012/02/16 01:39:03
each param on its own line.
peter1
2012/02/17 18:45:41
Done.
| |
| 19 } | 20 } |
| 20 | 21 |
| 21 ScopedClipboardWriter::~ScopedClipboardWriter() { | 22 ScopedClipboardWriter::~ScopedClipboardWriter() { |
| 22 if (!objects_.empty() && clipboard_) { | 23 if (!objects_.empty() && clipboard_) { |
| 23 clipboard_->WriteObjects(objects_); | 24 clipboard_->WriteObjects(buffer_, objects_); |
| 24 if (url_text_.length()) | 25 if (buffer_ == Clipboard::BUFFER_STANDARD && url_text_.length()) |
| 25 clipboard_->DidWriteURL(url_text_); | 26 clipboard_->DidWriteURL(url_text_); |
| 26 } | 27 } |
| 27 } | 28 } |
| 28 | 29 |
| 29 void ScopedClipboardWriter::WriteText(const string16& text) { | 30 void ScopedClipboardWriter::WriteText(const string16& text) { |
| 30 WriteTextOrURL(text, false); | 31 WriteTextOrURL(text, false); |
| 31 } | 32 } |
| 32 | 33 |
| 33 void ScopedClipboardWriter::WriteURL(const string16& text) { | 34 void ScopedClipboardWriter::WriteURL(const string16& text) { |
| 34 WriteTextOrURL(text, true); | 35 WriteTextOrURL(text, true); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 objects_[Clipboard::CBF_TEXT] = parameters; | 134 objects_[Clipboard::CBF_TEXT] = parameters; |
| 134 | 135 |
| 135 if (is_url) { | 136 if (is_url) { |
| 136 url_text_ = utf8_text; | 137 url_text_ = utf8_text; |
| 137 } else { | 138 } else { |
| 138 url_text_.clear(); | 139 url_text_.clear(); |
| 139 } | 140 } |
| 140 } | 141 } |
| 141 | 142 |
| 142 } // namespace ui | 143 } // namespace ui |
| OLD | NEW |