OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/views/omnibox/omnibox_view_win.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_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 |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 ResetDropHighlights(); | 220 ResetDropHighlights(); |
221 } | 221 } |
222 | 222 |
223 DWORD OmniboxViewWin::EditDropTarget::OnDrop(IDataObject* data_object, | 223 DWORD OmniboxViewWin::EditDropTarget::OnDrop(IDataObject* data_object, |
224 DWORD key_state, | 224 DWORD key_state, |
225 POINT cursor_position, | 225 POINT cursor_position, |
226 DWORD effect) { | 226 DWORD effect) { |
227 effect = OnDragOver(data_object, key_state, cursor_position, effect); | 227 effect = OnDragOver(data_object, key_state, cursor_position, effect); |
228 | 228 |
229 ui::OSExchangeData os_data(new ui::OSExchangeDataProviderWin(data_object)); | 229 ui::OSExchangeData os_data(new ui::OSExchangeDataProviderWin(data_object)); |
230 views::DropTargetEvent event(os_data, cursor_position.x, cursor_position.y, | 230 ui::DropTargetEvent event(os_data, cursor_position.x, cursor_position.y, |
231 ui::DragDropTypes::DropEffectToDragOperation(effect)); | 231 ui::DragDropTypes::DropEffectToDragOperation(effect)); |
232 | 232 |
233 int drag_operation = edit_->OnPerformDropImpl(event, edit_->in_drag()); | 233 int drag_operation = edit_->OnPerformDropImpl(event, edit_->in_drag()); |
234 | 234 |
235 if (!drag_has_url_) | 235 if (!drag_has_url_) |
236 ResetDropHighlights(); | 236 ResetDropHighlights(); |
237 | 237 |
238 return ui::DragDropTypes::DragOperationToDropEffect(drag_operation); | 238 return ui::DragDropTypes::DragOperationToDropEffect(drag_operation); |
239 } | 239 } |
240 | 240 |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 } | 949 } |
950 | 950 |
951 views::View* OmniboxViewWin::AddToView(views::View* parent) { | 951 views::View* OmniboxViewWin::AddToView(views::View* parent) { |
952 native_view_host_ = new OmniboxViewWrapper(this); | 952 native_view_host_ = new OmniboxViewWrapper(this); |
953 parent->AddChildView(native_view_host_); | 953 parent->AddChildView(native_view_host_); |
954 native_view_host_->set_focus_view(parent); | 954 native_view_host_->set_focus_view(parent); |
955 native_view_host_->Attach(GetNativeView()); | 955 native_view_host_->Attach(GetNativeView()); |
956 return native_view_host_; | 956 return native_view_host_; |
957 } | 957 } |
958 | 958 |
959 int OmniboxViewWin::OnPerformDrop(const views::DropTargetEvent& event) { | 959 int OmniboxViewWin::OnPerformDrop(const ui::DropTargetEvent& event) { |
960 return OnPerformDropImpl(event, false); | 960 return OnPerformDropImpl(event, false); |
961 } | 961 } |
962 | 962 |
963 gfx::Font OmniboxViewWin::GetFont() { | 963 gfx::Font OmniboxViewWin::GetFont() { |
964 return font_; | 964 return font_; |
965 } | 965 } |
966 | 966 |
967 int OmniboxViewWin::WidthOfTextAfterCursor() { | 967 int OmniboxViewWin::WidthOfTextAfterCursor() { |
968 CHARRANGE selection; | 968 CHARRANGE selection; |
969 GetSelection(selection); | 969 GetSelection(selection); |
970 // See comments in LocationBarView::Layout as to why this uses -1. | 970 // See comments in LocationBarView::Layout as to why this uses -1. |
971 const int start = std::max(0, static_cast<int>(selection.cpMax - 1)); | 971 const int start = std::max(0, static_cast<int>(selection.cpMax - 1)); |
972 return WidthNeededToDisplay(GetText().substr(start)); | 972 return WidthNeededToDisplay(GetText().substr(start)); |
973 } | 973 } |
974 | 974 |
975 int OmniboxViewWin::OnPerformDropImpl(const views::DropTargetEvent& event, | 975 int OmniboxViewWin::OnPerformDropImpl(const ui::DropTargetEvent& event, |
976 bool in_drag) { | 976 bool in_drag) { |
977 const ui::OSExchangeData& data = event.data(); | 977 const ui::OSExchangeData& data = event.data(); |
978 | 978 |
979 if (data.HasURL()) { | 979 if (data.HasURL()) { |
980 GURL url; | 980 GURL url; |
981 string16 title; | 981 string16 title; |
982 if (data.GetURLAndTitle(&url, &title)) { | 982 if (data.GetURLAndTitle(&url, &title)) { |
983 string16 text(StripJavascriptSchemas(UTF8ToUTF16(url.spec()))); | 983 string16 text(StripJavascriptSchemas(UTF8ToUTF16(url.spec()))); |
984 OmniboxView::SetUserText(text); | 984 OmniboxView::SetUserText(text); |
985 model()->AcceptInput(CURRENT_TAB, true); | 985 model()->AcceptInput(CURRENT_TAB, true); |
(...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2632 return (rect.left - client_rect.left) + (client_rect.right - rect.right); | 2632 return (rect.left - client_rect.left) + (client_rect.right - rect.right); |
2633 } | 2633 } |
2634 | 2634 |
2635 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { | 2635 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { |
2636 // Use font_.GetStringWidth() instead of | 2636 // Use font_.GetStringWidth() instead of |
2637 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is | 2637 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is |
2638 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, | 2638 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, |
2639 // PosFromChar(i) might return 0 when i is greater than 1. | 2639 // PosFromChar(i) might return 0 when i is greater than 1. |
2640 return font_.GetStringWidth(text) + GetHorizontalMargin(); | 2640 return font_.GetStringWidth(text) + GetHorizontalMargin(); |
2641 } | 2641 } |
OLD | NEW |