Index: chrome/browser/autocomplete/autocomplete_edit_view_win.cc |
=================================================================== |
--- chrome/browser/autocomplete/autocomplete_edit_view_win.cc (revision 74430) |
+++ chrome/browser/autocomplete/autocomplete_edit_view_win.cc (working copy) |
@@ -40,6 +40,7 @@ |
#include "skia/ext/skia_utils_win.h" |
#include "ui/base/clipboard/clipboard.h" |
#include "ui/base/clipboard/scoped_clipboard_writer.h" |
+#include "ui/base/dragdrop/drag_drop_types.h" |
#include "ui/base/dragdrop/drag_source.h" |
#include "ui/base/dragdrop/drop_target.h" |
#include "ui/base/dragdrop/os_exchange_data.h" |
@@ -179,42 +180,18 @@ |
DWORD key_state, |
POINT cursor_position, |
DWORD effect) { |
+ effect = OnDragOver(data_object, key_state, cursor_position, effect); |
+ |
ui::OSExchangeData os_data(new ui::OSExchangeDataProviderWin(data_object)); |
+ views::DropTargetEvent event(os_data, cursor_position.x, cursor_position.y, |
+ ui::DragDropTypes::DropEffectToDragOperation(effect)); |
- if (drag_has_url_) { |
- GURL url; |
- string16 title; |
- if (os_data.GetURLAndTitle(&url, &title)) { |
- edit_->SetUserText(UTF8ToWide(url.spec())); |
- edit_->model()->AcceptInput(CURRENT_TAB, true); |
- return CopyOrLinkDropEffect(effect); |
- } |
- } else if (drag_has_string_) { |
- int string_drop_position = edit_->drop_highlight_position(); |
- string16 text; |
- if ((string_drop_position != -1 || !edit_->in_drag()) && |
- os_data.GetString(&text)) { |
- DCHECK(string_drop_position == -1 || |
- ((string_drop_position >= 0) && |
- (string_drop_position <= edit_->GetTextLength()))); |
- const DWORD drop_operation = |
- OnDragOver(data_object, key_state, cursor_position, effect); |
- if (edit_->in_drag()) { |
- if (drop_operation == DROPEFFECT_MOVE) |
- edit_->MoveSelectedText(string_drop_position); |
- else |
- edit_->InsertText(string_drop_position, text); |
- } else { |
- edit_->PasteAndGo(CollapseWhitespace(text, true)); |
- } |
- ResetDropHighlights(); |
- return drop_operation; |
- } |
- } |
+ int drag_operation = edit_->OnPerformDrop(event); |
- ResetDropHighlights(); |
+ if (!drag_has_url_) |
+ ResetDropHighlights(); |
- return DROPEFFECT_NONE; |
+ return ui::DragDropTypes::DragOperationToDropEffect(drag_operation); |
} |
void EditDropTarget::UpdateDropHighlightPosition( |
@@ -962,6 +939,40 @@ |
return host; |
} |
+int AutocompleteEditViewWin::OnPerformDrop( |
+ const views::DropTargetEvent& event) { |
+ const ui::OSExchangeData& data = event.data(); |
+ |
+ if (data.HasURL()) { |
+ GURL url; |
+ string16 title; |
+ if (data.GetURLAndTitle(&url, &title)) { |
+ SetUserText(UTF8ToWide(url.spec())); |
+ model()->AcceptInput(CURRENT_TAB, true); |
+ return event.source_operations(); |
sky
2011/02/11 01:06:07
I believe you need to return one type here, not al
Roger Tawa OOO till Jul 10th
2011/02/11 15:20:17
At line 183, effect is guaranteed to have only one
sky
2011/02/11 17:14:53
But isn't OnPerformDrop also forwarded from the to
Roger Tawa OOO till Jul 10th
2011/02/11 21:35:26
You are correct, I missed that. Fixed.
|
+ } |
+ } else if (data.HasString()) { |
+ int string_drop_position = drop_highlight_position(); |
+ string16 text; |
+ if ((string_drop_position != -1 || !in_drag()) && data.GetString(&text)) { |
+ DCHECK(string_drop_position == -1 || |
+ ((string_drop_position >= 0) && |
+ (string_drop_position <= GetTextLength()))); |
+ if (in_drag()) { |
+ if (event.source_operations()== ui::DragDropTypes::DRAG_MOVE) |
+ MoveSelectedText(string_drop_position); |
+ else |
+ InsertText(string_drop_position, text); |
+ } else { |
+ PasteAndGo(CollapseWhitespace(text, true)); |
+ } |
+ return event.source_operations(); |
+ } |
+ } |
+ |
+ return ui::DragDropTypes::DRAG_NONE; |
+} |
+ |
void AutocompleteEditViewWin::PasteAndGo(const string16& text) { |
if (CanPasteAndGo(text)) |
model_->PasteAndGo(); |