summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-07 21:32:56 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-07 21:32:56 +0000
commit7e82b34a2b9eb39731b92dedc073c629f01ee8ce (patch)
tree7faed8d3c963007647e01a3d673ce22ba2f5de93 /ui
parent6a4d7f6028cb493847f51128adf26686c5926d57 (diff)
downloadchromium_src-7e82b34a2b9eb39731b92dedc073c629f01ee8ce.zip
chromium_src-7e82b34a2b9eb39731b92dedc073c629f01ee8ce.tar.gz
chromium_src-7e82b34a2b9eb39731b92dedc073c629f01ee8ce.tar.bz2
Whenever we set plain text on the standard clipboard, also set
the selection clipboard on Linux. Most of the time, this happens automatically since the only way to set the standard clipboard is to select text (which sets the selection clipboard), but it's possible to set the standard clipboard using javascript (event.clipboardData.setData('text/plain', ...)). Since we always set the selection clipboard, I removed some code that was for handling the "Copy Link Address" context menu item. I tested on GTK+ and Aura. BUG=168135 TEST=Right click a link, select "Copy Link Addres", middle click in a text field. This should paste the URL. Here's a test case for clipboardData.setData: http://jsfiddle.net/LNWMG/ Review URL: https://codereview.chromium.org/11792002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175387 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/base/clipboard/clipboard.h10
-rw-r--r--ui/base/clipboard/clipboard_aurax11.cc22
-rw-r--r--ui/base/clipboard/clipboard_gtk.cc17
-rw-r--r--ui/base/clipboard/scoped_clipboard_writer.cc5
4 files changed, 19 insertions, 35 deletions
diff --git a/ui/base/clipboard/clipboard.h b/ui/base/clipboard/clipboard.h
index 16e0275..94d78712 100644
--- a/ui/base/clipboard/clipboard.h
+++ b/ui/base/clipboard/clipboard.h
@@ -213,16 +213,6 @@ class UI_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
// kept until the system clipboard is set again.
void WriteObjects(Buffer buffer, const ObjectMap& objects);
- // On Linux/BSD, we need to know when the clipboard is set to a URL. Most
- // platforms don't care.
-#if defined(OS_WIN) || defined(OS_MACOSX) \
- || (defined(USE_AURA) && defined(OS_CHROMEOS)) \
- || defined(OS_ANDROID)
- void DidWriteURL(const std::string& utf8_text) {}
-#else
- void DidWriteURL(const std::string& utf8_text);
-#endif
-
// Returns a sequence number which uniquely identifies clipboard state.
// This can be used to version the data on the clipboard and determine
// whether it has changed.
diff --git a/ui/base/clipboard/clipboard_aurax11.cc b/ui/base/clipboard/clipboard_aurax11.cc
index b8f6670..6d273fa 100644
--- a/ui/base/clipboard/clipboard_aurax11.cc
+++ b/ui/base/clipboard/clipboard_aurax11.cc
@@ -894,8 +894,17 @@ void Clipboard::WriteObjects(Buffer buffer, const ObjectMap& objects) {
iter != objects.end(); ++iter) {
DispatchObject(static_cast<ObjectType>(iter->first), iter->second);
}
-
aurax11_details_->TakeOwnershipOfSelection(buffer);
+
+ if (buffer == BUFFER_STANDARD) {
+ ObjectMap::const_iterator text_iter = objects.find(CBF_TEXT);
+ if (text_iter != objects.end()) {
+ aurax11_details_->CreateNewClipboardData();
+ const ObjectMapParam& char_vector = text_iter->second[0];
+ WriteText(&char_vector.front(), char_vector.size());
+ aurax11_details_->TakeOwnershipOfSelection(BUFFER_SELECTION);
+ }
+ }
}
bool Clipboard::IsFormatAvailable(const FormatType& format,
@@ -1047,17 +1056,6 @@ void Clipboard::ReadData(const FormatType& format, std::string* result) const {
data->AssignTo(result);
}
-// When a URL is copied from a render view context menu (via "copy link
-// location", for example), we additionally stick it in the X clipboard. This
-// matches other linux browsers.
-void Clipboard::DidWriteURL(const std::string& utf8_text) {
- DCHECK(CalledOnValidThread());
-
- aurax11_details_->CreateNewClipboardData();
- WriteText(utf8_text.c_str(), utf8_text.size());
- aurax11_details_->TakeOwnershipOfSelection(BUFFER_SELECTION);
-}
-
uint64 Clipboard::GetSequenceNumber(Buffer buffer) {
DCHECK(CalledOnValidThread());
if (buffer == BUFFER_STANDARD)
diff --git a/ui/base/clipboard/clipboard_gtk.cc b/ui/base/clipboard/clipboard_gtk.cc
index 40c58ca..022fca4 100644
--- a/ui/base/clipboard/clipboard_gtk.cc
+++ b/ui/base/clipboard/clipboard_gtk.cc
@@ -229,15 +229,6 @@ void Clipboard::WriteObjects(Buffer buffer, const ObjectMap& objects) {
SetGtkClipboard(buffer);
}
-// When a URL is copied from a render view context menu (via "copy link
-// location", for example), we additionally stick it in the X clipboard. This
-// matches other linux browsers.
-void Clipboard::DidWriteURL(const std::string& utf8_text) {
- DCHECK(CalledOnValidThread());
- gtk_clipboard_set_text(primary_selection_, utf8_text.c_str(),
- utf8_text.length());
-}
-
// Take ownership of the GTK clipboard and inform it of the targets we support.
void Clipboard::SetGtkClipboard(Buffer buffer) {
scoped_array<GtkTargetEntry> targets(
@@ -262,6 +253,14 @@ void Clipboard::SetGtkClipboard(Buffer buffer) {
clipboard_data_->size());
}
+ if (buffer == BUFFER_STANDARD) {
+ Clipboard::TargetMap::iterator text_iter = clipboard_data_->find("TEXT");
+ if (text_iter != clipboard_data_->end()) {
+ gtk_clipboard_set_text(primary_selection_, text_iter->second.first,
+ text_iter->second.second);
+ }
+ }
+
// clipboard_data_ now owned by the GtkClipboard.
clipboard_data_ = NULL;
}
diff --git a/ui/base/clipboard/scoped_clipboard_writer.cc b/ui/base/clipboard/scoped_clipboard_writer.cc
index 5ecb43c..9726446 100644
--- a/ui/base/clipboard/scoped_clipboard_writer.cc
+++ b/ui/base/clipboard/scoped_clipboard_writer.cc
@@ -21,11 +21,8 @@ ScopedClipboardWriter::ScopedClipboardWriter(Clipboard* clipboard,
}
ScopedClipboardWriter::~ScopedClipboardWriter() {
- if (!objects_.empty() && clipboard_) {
+ if (!objects_.empty() && clipboard_)
clipboard_->WriteObjects(buffer_, objects_);
- if (buffer_ == Clipboard::BUFFER_STANDARD && url_text_.length())
- clipboard_->DidWriteURL(url_text_);
- }
}
void ScopedClipboardWriter::WriteText(const string16& text) {