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/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "net/base/escape.h" | 13 #include "net/base/escape.h" |
14 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
15 | 15 |
16 namespace ui { | 16 namespace ui { |
17 | 17 |
18 ScopedClipboardWriter::ScopedClipboardWriter(Clipboard* clipboard, | 18 ScopedClipboardWriter::ScopedClipboardWriter(ClipboardType type) : type_(type) { |
19 ClipboardType type) | |
20 : clipboard_(clipboard), | |
21 type_(type) { | |
22 } | 19 } |
23 | 20 |
24 ScopedClipboardWriter::~ScopedClipboardWriter() { | 21 ScopedClipboardWriter::~ScopedClipboardWriter() { |
25 if (!objects_.empty() && clipboard_) | 22 if (!objects_.empty()) |
26 clipboard_->WriteObjects(type_, objects_); | 23 ui::Clipboard::GetForCurrentThread()->WriteObjects(type_, objects_); |
27 } | 24 } |
28 | 25 |
29 void ScopedClipboardWriter::WriteText(const base::string16& text) { | 26 void ScopedClipboardWriter::WriteText(const base::string16& text) { |
30 WriteTextOrURL(text, false); | 27 WriteTextOrURL(text, false); |
31 } | 28 } |
32 | 29 |
33 void ScopedClipboardWriter::WriteURL(const base::string16& text) { | 30 void ScopedClipboardWriter::WriteURL(const base::string16& text) { |
34 WriteTextOrURL(text, true); | 31 WriteTextOrURL(text, true); |
35 } | 32 } |
36 | 33 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 objects_[Clipboard::CBF_TEXT] = parameters; | 118 objects_[Clipboard::CBF_TEXT] = parameters; |
122 | 119 |
123 if (is_url) { | 120 if (is_url) { |
124 url_text_ = utf8_text; | 121 url_text_ = utf8_text; |
125 } else { | 122 } else { |
126 url_text_.clear(); | 123 url_text_.clear(); |
127 } | 124 } |
128 } | 125 } |
129 | 126 |
130 } // namespace ui | 127 } // namespace ui |
OLD | NEW |