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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_edit_view_win.cc

Issue 6250014: Move more dnd related files to ui/base (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « app/win/drop_target.cc ('k') | chrome/browser/bookmarks/bookmark_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/autocomplete/autocomplete_edit_view_win.h" 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <locale> 8 #include <locale>
9 #include <string> 9 #include <string>
10 10
11 #include <richedit.h> 11 #include <richedit.h>
12 #include <textserv.h> 12 #include <textserv.h>
13 13
14 #include "app/l10n_util.h" 14 #include "app/l10n_util.h"
15 #include "app/l10n_util_win.h" 15 #include "app/l10n_util_win.h"
16 #include "app/win/drag_source.h"
17 #include "app/win/drop_target.h"
18 #include "app/win/iat_patch_function.h" 16 #include "app/win/iat_patch_function.h"
19 #include "app/win/win_util.h" 17 #include "app/win/win_util.h"
20 #include "base/auto_reset.h" 18 #include "base/auto_reset.h"
21 #include "base/basictypes.h" 19 #include "base/basictypes.h"
22 #include "base/i18n/rtl.h" 20 #include "base/i18n/rtl.h"
23 #include "base/lazy_instance.h" 21 #include "base/lazy_instance.h"
24 #include "base/ref_counted.h" 22 #include "base/ref_counted.h"
25 #include "base/string_util.h" 23 #include "base/string_util.h"
26 #include "base/utf_string_conversions.h" 24 #include "base/utf_string_conversions.h"
27 #include "chrome/app/chrome_command_ids.h" 25 #include "chrome/app/chrome_command_ids.h"
(...skipping 12 matching lines...) Expand all
40 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 38 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
41 #include "chrome/common/notification_service.h" 39 #include "chrome/common/notification_service.h"
42 #include "googleurl/src/url_util.h" 40 #include "googleurl/src/url_util.h"
43 #include "gfx/canvas.h" 41 #include "gfx/canvas.h"
44 #include "gfx/canvas_skia.h" 42 #include "gfx/canvas_skia.h"
45 #include "grit/generated_resources.h" 43 #include "grit/generated_resources.h"
46 #include "net/base/escape.h" 44 #include "net/base/escape.h"
47 #include "skia/ext/skia_utils_win.h" 45 #include "skia/ext/skia_utils_win.h"
48 #include "ui/base/clipboard/clipboard.h" 46 #include "ui/base/clipboard/clipboard.h"
49 #include "ui/base/clipboard/scoped_clipboard_writer.h" 47 #include "ui/base/clipboard/scoped_clipboard_writer.h"
48 #include "ui/base/dragdrop/drag_source.h"
49 #include "ui/base/dragdrop/drop_target.h"
50 #include "ui/base/dragdrop/os_exchange_data.h" 50 #include "ui/base/dragdrop/os_exchange_data.h"
51 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" 51 #include "ui/base/dragdrop/os_exchange_data_provider_win.h"
52 #include "ui/base/keycodes/keyboard_codes.h" 52 #include "ui/base/keycodes/keyboard_codes.h"
53 #include "views/drag_utils.h" 53 #include "views/drag_utils.h"
54 #include "views/focus/focus_util_win.h" 54 #include "views/focus/focus_util_win.h"
55 #include "views/widget/widget.h" 55 #include "views/widget/widget.h"
56 56
57 #pragma comment(lib, "oleacc.lib") // Needed for accessibility support. 57 #pragma comment(lib, "oleacc.lib") // Needed for accessibility support.
58 #pragma comment(lib, "riched20.lib") // Needed for the richedit control. 58 #pragma comment(lib, "riched20.lib") // Needed for the richedit control.
59 59
60 /////////////////////////////////////////////////////////////////////////////// 60 ///////////////////////////////////////////////////////////////////////////////
61 // AutocompleteEditModel 61 // AutocompleteEditModel
62 62
63 namespace { 63 namespace {
64 64
65 // EditDropTarget is the IDropTarget implementation installed on 65 // EditDropTarget is the IDropTarget implementation installed on
66 // AutocompleteEditViewWin. EditDropTarget prefers URL over plain text. A drop 66 // AutocompleteEditViewWin. EditDropTarget prefers URL over plain text. A drop
67 // of a URL replaces all the text of the edit and navigates immediately to the 67 // of a URL replaces all the text of the edit and navigates immediately to the
68 // URL. A drop of plain text from the same edit either copies or moves the 68 // URL. A drop of plain text from the same edit either copies or moves the
69 // selected text, and a drop of plain text from a source other than the edit 69 // selected text, and a drop of plain text from a source other than the edit
70 // does a paste and go. 70 // does a paste and go.
71 class EditDropTarget : public app::win::DropTarget { 71 class EditDropTarget : public ui::DropTarget {
72 public: 72 public:
73 explicit EditDropTarget(AutocompleteEditViewWin* edit); 73 explicit EditDropTarget(AutocompleteEditViewWin* edit);
74 74
75 protected: 75 protected:
76 virtual DWORD OnDragEnter(IDataObject* data_object, 76 virtual DWORD OnDragEnter(IDataObject* data_object,
77 DWORD key_state, 77 DWORD key_state,
78 POINT cursor_position, 78 POINT cursor_position,
79 DWORD effect); 79 DWORD effect);
80 virtual DWORD OnDragOver(IDataObject* data_object, 80 virtual DWORD OnDragOver(IDataObject* data_object,
81 DWORD key_state, 81 DWORD key_state,
(...skipping 30 matching lines...) Expand all
112 // DROPEFFECTS. We prefer copy over link. 112 // DROPEFFECTS. We prefer copy over link.
113 DWORD CopyOrLinkDropEffect(DWORD effect) { 113 DWORD CopyOrLinkDropEffect(DWORD effect) {
114 if (effect & DROPEFFECT_COPY) 114 if (effect & DROPEFFECT_COPY)
115 return DROPEFFECT_COPY; 115 return DROPEFFECT_COPY;
116 if (effect & DROPEFFECT_LINK) 116 if (effect & DROPEFFECT_LINK)
117 return DROPEFFECT_LINK; 117 return DROPEFFECT_LINK;
118 return DROPEFFECT_NONE; 118 return DROPEFFECT_NONE;
119 } 119 }
120 120
121 EditDropTarget::EditDropTarget(AutocompleteEditViewWin* edit) 121 EditDropTarget::EditDropTarget(AutocompleteEditViewWin* edit)
122 : app::win::DropTarget(edit->m_hWnd), 122 : ui::DropTarget(edit->m_hWnd),
123 edit_(edit), 123 edit_(edit),
124 drag_has_url_(false), 124 drag_has_url_(false),
125 drag_has_string_(false) { 125 drag_has_string_(false) {
126 } 126 }
127 127
128 DWORD EditDropTarget::OnDragEnter(IDataObject* data_object, 128 DWORD EditDropTarget::OnDragEnter(IDataObject* data_object,
129 DWORD key_state, 129 DWORD key_state,
130 POINT cursor_position, 130 POINT cursor_position,
131 DWORD effect) { 131 DWORD effect) {
132 ui::OSExchangeData os_data(new ui::OSExchangeDataProviderWin(data_object)); 132 ui::OSExchangeData os_data(new ui::OSExchangeDataProviderWin(data_object));
(...skipping 2287 matching lines...) Expand 10 before | Expand all | Expand 10 after
2420 UserMetrics::RecordAction(UserMetricsAction("Omnibox_DragURL"), 2420 UserMetrics::RecordAction(UserMetricsAction("Omnibox_DragURL"),
2421 model_->profile()); 2421 model_->profile());
2422 } else { 2422 } else {
2423 supported_modes |= DROPEFFECT_MOVE; 2423 supported_modes |= DROPEFFECT_MOVE;
2424 UserMetrics::RecordAction(UserMetricsAction("Omnibox_DragString"), 2424 UserMetrics::RecordAction(UserMetricsAction("Omnibox_DragString"),
2425 model_->profile()); 2425 model_->profile());
2426 } 2426 }
2427 2427
2428 data.SetString(text_to_write); 2428 data.SetString(text_to_write);
2429 2429
2430 scoped_refptr<app::win::DragSource> drag_source(new app::win::DragSource); 2430 scoped_refptr<ui::DragSource> drag_source(new ui::DragSource);
2431 DWORD dropped_mode; 2431 DWORD dropped_mode;
2432 AutoReset<bool> auto_reset_in_drag(&in_drag_, true); 2432 AutoReset<bool> auto_reset_in_drag(&in_drag_, true);
2433 if (DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data), 2433 if (DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data),
2434 drag_source, supported_modes, &dropped_mode) == 2434 drag_source, supported_modes, &dropped_mode) ==
2435 DRAGDROP_S_DROP) { 2435 DRAGDROP_S_DROP) {
2436 if ((dropped_mode == DROPEFFECT_MOVE) && (start_text == GetText())) { 2436 if ((dropped_mode == DROPEFFECT_MOVE) && (start_text == GetText())) {
2437 ScopedFreeze freeze(this, GetTextObjectModel()); 2437 ScopedFreeze freeze(this, GetTextObjectModel());
2438 OnBeforePossibleChange(); 2438 OnBeforePossibleChange();
2439 SetSelectionRange(sel); 2439 SetSelectionRange(sel);
2440 ReplaceSel(L"", true); 2440 ReplaceSel(L"", true);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2560 } 2560 }
2561 2561
2562 int AutocompleteEditViewWin::WidthNeededToDisplay( 2562 int AutocompleteEditViewWin::WidthNeededToDisplay(
2563 const std::wstring& text) const { 2563 const std::wstring& text) const {
2564 // Use font_.GetStringWidth() instead of 2564 // Use font_.GetStringWidth() instead of
2565 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is 2565 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is
2566 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, 2566 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout,
2567 // PosFromChar(i) might return 0 when i is greater than 1. 2567 // PosFromChar(i) might return 0 when i is greater than 1.
2568 return font_.GetStringWidth(text) + GetHorizontalMargin(); 2568 return font_.GetStringWidth(text) + GetHorizontalMargin();
2569 } 2569 }
OLDNEW
« no previous file with comments | « app/win/drop_target.cc ('k') | chrome/browser/bookmarks/bookmark_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698