| OLD | NEW |
| 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 // 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::Buffer buffer) | 18 Clipboard::Buffer buffer) |
| 19 : clipboard_(clipboard), | 19 : clipboard_(clipboard), |
| 20 buffer_(buffer) { | 20 buffer_(buffer), |
| 21 source_tag_() { |
| 22 } |
| 23 |
| 24 ScopedClipboardWriter::ScopedClipboardWriter(Clipboard* clipboard, |
| 25 Clipboard::Buffer buffer, |
| 26 Clipboard::SourceTag source_tag) |
| 27 : clipboard_(clipboard), |
| 28 buffer_(buffer), |
| 29 source_tag_(source_tag) { |
| 21 } | 30 } |
| 22 | 31 |
| 23 ScopedClipboardWriter::~ScopedClipboardWriter() { | 32 ScopedClipboardWriter::~ScopedClipboardWriter() { |
| 24 if (!objects_.empty() && clipboard_) | 33 if (!objects_.empty() && clipboard_) |
| 25 clipboard_->WriteObjects(buffer_, objects_); | 34 clipboard_->WriteObjects(buffer_, objects_, source_tag_); |
| 26 } | 35 } |
| 27 | 36 |
| 28 void ScopedClipboardWriter::WriteText(const string16& text) { | 37 void ScopedClipboardWriter::WriteText(const string16& text) { |
| 29 WriteTextOrURL(text, false); | 38 WriteTextOrURL(text, false); |
| 30 } | 39 } |
| 31 | 40 |
| 32 void ScopedClipboardWriter::WriteURL(const string16& text) { | 41 void ScopedClipboardWriter::WriteURL(const string16& text) { |
| 33 WriteTextOrURL(text, true); | 42 WriteTextOrURL(text, true); |
| 34 } | 43 } |
| 35 | 44 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 objects_[Clipboard::CBF_TEXT] = parameters; | 147 objects_[Clipboard::CBF_TEXT] = parameters; |
| 139 | 148 |
| 140 if (is_url) { | 149 if (is_url) { |
| 141 url_text_ = utf8_text; | 150 url_text_ = utf8_text; |
| 142 } else { | 151 } else { |
| 143 url_text_.clear(); | 152 url_text_.clear(); |
| 144 } | 153 } |
| 145 } | 154 } |
| 146 | 155 |
| 147 } // namespace ui | 156 } // namespace ui |
| OLD | NEW |