summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorckocagil@chromium.org <ckocagil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-09 10:39:45 +0000
committerckocagil@chromium.org <ckocagil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-09 10:39:45 +0000
commit6c468bb773078fd4a17ba14711648140c8bea940 (patch)
treea505e86c47de2b404d25202a7ab804cd46b4a1b0
parent7a6bec1744dbe942f4ee4648ecbd9b341698f51d (diff)
downloadchromium_src-6c468bb773078fd4a17ba14711648140c8bea940.zip
chromium_src-6c468bb773078fd4a17ba14711648140c8bea940.tar.gz
chromium_src-6c468bb773078fd4a17ba14711648140c8bea940.tar.bz2
Implement text drag-drop on Views Omnibox
BUG=227371 Review URL: https://chromiumcodereview.appspot.com/13696004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193072 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/views/omnibox/omnibox_view_views.cc12
-rw-r--r--ui/views/controls/textfield/native_textfield_views.cc4
-rw-r--r--ui/views/controls/textfield/native_textfield_views.h1
-rw-r--r--ui/views/controls/textfield/native_textfield_win.cc5
-rw-r--r--ui/views/controls/textfield/native_textfield_win.h1
-rw-r--r--ui/views/controls/textfield/native_textfield_wrapper.h3
-rw-r--r--ui/views/controls/textfield/textfield.cc4
-rw-r--r--ui/views/controls/textfield/textfield.h3
8 files changed, 33 insertions, 0 deletions
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
index 1c4e184..480e459 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
@@ -717,6 +717,9 @@ void OmniboxViewViews::AppendDropFormats(
}
int OmniboxViewViews::OnDrop(const ui::OSExchangeData& data) {
+ if (HasTextBeingDragged())
+ return ui::DragDropTypes::DRAG_NONE;
+
if (data.HasURL()) {
GURL url;
string16 title;
@@ -727,7 +730,16 @@ int OmniboxViewViews::OnDrop(const ui::OSExchangeData& data) {
return ui::DragDropTypes::DRAG_COPY;
}
}
+ } else if (data.HasString()) {
+ string16 text;
+ if (data.GetString(&text)) {
+ string16 collapsed_text(CollapseWhitespace(text, true));
+ if (model()->CanPasteAndGo(collapsed_text))
+ model()->PasteAndGo(collapsed_text);
+ return ui::DragDropTypes::DRAG_COPY;
+ }
}
+
return ui::DragDropTypes::DRAG_NONE;
}
diff --git a/ui/views/controls/textfield/native_textfield_views.cc b/ui/views/controls/textfield/native_textfield_views.cc
index 54cb7a2..baf5c2d 100644
--- a/ui/views/controls/textfield/native_textfield_views.cc
+++ b/ui/views/controls/textfield/native_textfield_views.cc
@@ -708,6 +708,10 @@ void NativeTextfieldViews::ExecuteTextCommand(int command_id) {
ExecuteCommand(command_id, 0);
}
+bool NativeTextfieldViews::HasTextBeingDragged() {
+ return initiating_drag_;
+}
+
/////////////////////////////////////////////////////////////////
// NativeTextfieldViews, ui::SimpleMenuModel::Delegate overrides:
diff --git a/ui/views/controls/textfield/native_textfield_views.h b/ui/views/controls/textfield/native_textfield_views.h
index fcde532..f6bcfaa 100644
--- a/ui/views/controls/textfield/native_textfield_views.h
+++ b/ui/views/controls/textfield/native_textfield_views.h
@@ -149,6 +149,7 @@ class VIEWS_EXPORT NativeTextfieldViews : public View,
virtual int GetFontHeight() OVERRIDE;
virtual int GetTextfieldBaseline() const OVERRIDE;
virtual void ExecuteTextCommand(int command_id) OVERRIDE;
+ virtual bool HasTextBeingDragged() OVERRIDE;
// ui::SimpleMenuModel::Delegate overrides
virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
diff --git a/ui/views/controls/textfield/native_textfield_win.cc b/ui/views/controls/textfield/native_textfield_win.cc
index f3d3309..8c392b9 100644
--- a/ui/views/controls/textfield/native_textfield_win.cc
+++ b/ui/views/controls/textfield/native_textfield_win.cc
@@ -429,6 +429,11 @@ void NativeTextfieldWin::ExecuteTextCommand(int command_id) {
ExecuteCommand(command_id, 0);
}
+bool NativeTextfieldWin::HasTextBeingDragged() {
+ NOTIMPLEMENTED();
+ return false;
+}
+
////////////////////////////////////////////////////////////////////////////////
// NativeTextfieldWin, ui::SimpleMenuModel::Delegate implementation:
diff --git a/ui/views/controls/textfield/native_textfield_win.h b/ui/views/controls/textfield/native_textfield_win.h
index 9764f24..c8785c4 100644
--- a/ui/views/controls/textfield/native_textfield_win.h
+++ b/ui/views/controls/textfield/native_textfield_win.h
@@ -101,6 +101,7 @@ class NativeTextfieldWin
virtual int GetFontHeight() OVERRIDE;
virtual int GetTextfieldBaseline() const OVERRIDE;
virtual void ExecuteTextCommand(int command_id) OVERRIDE;
+ virtual bool HasTextBeingDragged() OVERRIDE;
// ui::SimpleMenuModel::Delegate:
virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
diff --git a/ui/views/controls/textfield/native_textfield_wrapper.h b/ui/views/controls/textfield/native_textfield_wrapper.h
index aa18b4e..9a9ab3f 100644
--- a/ui/views/controls/textfield/native_textfield_wrapper.h
+++ b/ui/views/controls/textfield/native_textfield_wrapper.h
@@ -172,6 +172,9 @@ class VIEWS_EXPORT NativeTextfieldWrapper {
// ExecuteCommand to avoid name clash.
virtual void ExecuteTextCommand(int command_id) = 0;
+ // Returns whether there is a drag operation originating from the textfield.
+ virtual bool HasTextBeingDragged() = 0;
+
// Creates an appropriate NativeTextfieldWrapper for the platform.
static NativeTextfieldWrapper* CreateWrapper(Textfield* field);
};
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
index f2bbe63..21a2ab4 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -441,6 +441,10 @@ void Textfield::ExecuteCommand(int command_id) {
native_wrapper_->ExecuteTextCommand(command_id);
}
+bool Textfield::HasTextBeingDragged() {
+ return native_wrapper_->HasTextBeingDragged();
+}
+
////////////////////////////////////////////////////////////////////////////////
// Textfield, View overrides:
diff --git a/ui/views/controls/textfield/textfield.h b/ui/views/controls/textfield/textfield.h
index 0edbe9f..4d53d9b 100644
--- a/ui/views/controls/textfield/textfield.h
+++ b/ui/views/controls/textfield/textfield.h
@@ -248,6 +248,9 @@ class VIEWS_EXPORT Textfield : public View {
return native_wrapper_;
}
+ // Returns whether there is a drag operation originating from the textfield.
+ bool HasTextBeingDragged();
+
// Overridden from View:
virtual void Layout() OVERRIDE;
virtual int GetBaseline() const OVERRIDE;