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

Unified Diff: ui/views/controls/textfield/native_textfield_views.cc

Issue 11416327: Omnibox should accept and navigate URLs dropped using drag and drop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 8 years 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
Index: ui/views/controls/textfield/native_textfield_views.cc
diff --git a/ui/views/controls/textfield/native_textfield_views.cc b/ui/views/controls/textfield/native_textfield_views.cc
index 5be141a325f950fd66f194ed5441d73aa4f55817..f7dd39b8192314a83eb3abcd1a730ca975eb77b5 100644
--- a/ui/views/controls/textfield/native_textfield_views.cc
+++ b/ui/views/controls/textfield/native_textfield_views.cc
@@ -193,11 +193,18 @@ bool NativeTextfieldViews::GetDropFormats(
return false;
// TODO(msw): Can we support URL, FILENAME, etc.?
*formats = ui::OSExchangeData::STRING;
+ TextfieldController* controller = textfield_->GetController();
+ if (controller)
+ controller->AppendDropFormats(formats, custom_formats);
return true;
}
bool NativeTextfieldViews::CanDrop(const OSExchangeData& data) {
- return textfield_->enabled() && !textfield_->read_only() && data.HasString();
+ int formats;
+ std::set<OSExchangeData::CustomFormat> custom_formats;
+ GetDropFormats(&formats, &custom_formats);
+ return textfield_->enabled() && !textfield_->read_only() &&
+ data.HasAnyFormat(formats, custom_formats);
}
int NativeTextfieldViews::OnDragUpdated(const ui::DropTargetEvent& event) {
@@ -219,6 +226,14 @@ int NativeTextfieldViews::OnDragUpdated(const ui::DropTargetEvent& event) {
int NativeTextfieldViews::OnPerformDrop(const ui::DropTargetEvent& event) {
DCHECK(CanDrop(event.data()));
+
+ TextfieldController* controller = textfield_->GetController();
+ if (controller) {
+ int drag_operation = controller->OnDrop(event.data());
+ if (drag_operation != ui::DragDropTypes::DRAG_NONE)
+ return drag_operation;
+ }
+
DCHECK(!initiating_drag_ ||
!GetRenderText()->IsPointInSelection(event.location()));
OnBeforeUserAction();
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.cc ('k') | ui/views/controls/textfield/textfield_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698