Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6268)

Unified Diff: chrome/browser/ui/views/omnibox/omnibox_view_win.cc

Issue 11789003: Fixed a clipboard bug in views/omnibox. The content was always copied as pure text, never as hyperl… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Style changes Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/omnibox/omnibox_view_win.cc
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
index 5059591c35e695c5575c43bf31cb0a2fac0d42df..bfa0394fb42337a951fe6c425bf4e3080994e979 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
@@ -28,6 +28,7 @@
#include "chrome/browser/autocomplete/autocomplete_input.h"
#include "chrome/browser/autocomplete/autocomplete_match.h"
#include "chrome/browser/autocomplete/keyword_provider.h"
+#include "chrome/browser/bookmarks/bookmark_node_data.h"
#include "chrome/browser/command_updater.h"
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/profiles/profile.h"
@@ -127,13 +128,18 @@ bool IsDrag(const POINT& origin, const POINT& current) {
gfx::Point(current) - gfx::Point(origin));
}
-// Write |text| and an optional |url| to the clipboard.
-void DoCopy(const string16& text, const GURL* url) {
+// Copies |selected_text| as text to the primary clipboard.
+void DoCopyText(const string16& selected_text) {
ui::ScopedClipboardWriter scw(ui::Clipboard::GetForCurrentThread(),
ui::Clipboard::BUFFER_STANDARD);
- scw.WriteText(text);
- if (url != NULL)
- scw.WriteBookmark(text, url->spec());
+ scw.WriteText(selected_text);
+}
+
+// Writes |url| and |text| to the clipboard as a well-formed URL.
+void DoCopyURL(const GURL& url, const string16& text) {
+ BookmarkNodeData data;
+ data.ReadFromTuple(url, text);
+ data.WriteToClipboard(NULL);
}
} // namespace
@@ -1093,7 +1099,7 @@ int OmniboxViewWin::OnPerformDropImpl(const ui::DropTargetEvent& event,
}
void OmniboxViewWin::CopyURL() {
- DoCopy(toolbar_model()->GetText(false), &toolbar_model()->GetURL());
+ DoCopyURL(toolbar_model()->GetURL(), toolbar_model()->GetText(false));
}
bool OmniboxViewWin::SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) {
@@ -1428,7 +1434,10 @@ void OmniboxViewWin::OnCopy() {
// GetSel() doesn't preserve selection direction, so sel.cpMin will always be
// the smaller value.
model()->AdjustTextForCopy(sel.cpMin, IsSelectAll(), &text, &url, &write_url);
- DoCopy(text, write_url ? &url : NULL);
+ if (write_url)
+ DoCopyURL(url, text);
+ else
+ DoCopyText(text);
}
LRESULT OmniboxViewWin::OnCreate(const CREATESTRUCTW* /*create_struct*/) {
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698