Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/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 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 951 } | 951 } |
| 952 | 952 |
| 953 int OmniboxViewWin::OnPerformDropImpl(const views::DropTargetEvent& event, | 953 int OmniboxViewWin::OnPerformDropImpl(const views::DropTargetEvent& event, |
| 954 bool in_drag) { | 954 bool in_drag) { |
| 955 const ui::OSExchangeData& data = event.data(); | 955 const ui::OSExchangeData& data = event.data(); |
| 956 | 956 |
| 957 if (data.HasURL()) { | 957 if (data.HasURL()) { |
| 958 GURL url; | 958 GURL url; |
| 959 string16 title; | 959 string16 title; |
| 960 if (data.GetURLAndTitle(&url, &title)) { | 960 if (data.GetURLAndTitle(&url, &title)) { |
| 961 SetUserText(UTF8ToWide(url.spec())); | 961 string16 text(UTF8ToUTF16(url.spec())); |
| 962 model()->AcceptInput(CURRENT_TAB, true); | 962 bool changed = StripJavascriptSchema(text, &text); |
| 963 SetUserText(text); | |
| 964 if (!changed) | |
| 965 model()->AcceptInput(CURRENT_TAB, true); | |
| 963 return CopyOrLinkDragOperation(event.source_operations()); | 966 return CopyOrLinkDragOperation(event.source_operations()); |
| 964 } | 967 } |
| 965 } else if (data.HasString()) { | 968 } else if (data.HasString()) { |
| 966 int string_drop_position = drop_highlight_position(); | 969 int string_drop_position = drop_highlight_position(); |
| 967 string16 text; | 970 string16 text; |
| 968 if ((string_drop_position != -1 || !in_drag) && data.GetString(&text)) { | 971 if ((string_drop_position != -1 || !in_drag) && data.GetString(&text)) { |
| 969 DCHECK(string_drop_position == -1 || | 972 DCHECK(string_drop_position == -1 || |
| 970 ((string_drop_position >= 0) && | 973 ((string_drop_position >= 0) && |
| 971 (string_drop_position <= GetTextLength()))); | 974 (string_drop_position <= GetTextLength()))); |
| 972 if (in_drag) { | 975 if (in_drag) { |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1713 | 1716 |
| 1714 // Blit the memory DC to the actual paint DC and clean up. | 1717 // Blit the memory DC to the actual paint DC and clean up. |
| 1715 BitBlt(paint_dc, rect.left, rect.top, rect.Width(), rect.Height(), memory_dc, | 1718 BitBlt(paint_dc, rect.left, rect.top, rect.Width(), rect.Height(), memory_dc, |
| 1716 rect.left, rect.top, SRCCOPY); | 1719 rect.left, rect.top, SRCCOPY); |
| 1717 memory_dc.SelectBitmap(old_bitmap); | 1720 memory_dc.SelectBitmap(old_bitmap); |
| 1718 edit_hwnd = old_edit_hwnd; | 1721 edit_hwnd = old_edit_hwnd; |
| 1719 } | 1722 } |
| 1720 | 1723 |
| 1721 void OmniboxViewWin::OnPaste() { | 1724 void OmniboxViewWin::OnPaste() { |
| 1722 // Replace the selection if we have something to paste. | 1725 // Replace the selection if we have something to paste. |
| 1723 const string16 text(GetClipboardText()); | 1726 string16 text(GetClipboardText()); |
| 1727 StripJavascriptSchema(text, &text); | |
|
Peter Kasting
2011/05/10 23:27:42
You should be doing this fixup in GetClipboardText
Cris Neckar
2011/05/11 21:42:36
Done.
| |
| 1724 if (!text.empty()) { | 1728 if (!text.empty()) { |
| 1725 // Record this paste, so we can do different behavior. | 1729 // Record this paste, so we can do different behavior. |
| 1726 model_->on_paste(); | 1730 model_->on_paste(); |
| 1727 // Force a Paste operation to trigger the text_changed code in | 1731 // Force a Paste operation to trigger the text_changed code in |
| 1728 // OnAfterPossibleChange(), even if identical contents are pasted into the | 1732 // OnAfterPossibleChange(), even if identical contents are pasted into the |
| 1729 // text box. | 1733 // text box. |
| 1730 text_before_change_.clear(); | 1734 text_before_change_.clear(); |
| 1731 ReplaceSel(text.c_str(), true); | 1735 ReplaceSel(text.c_str(), true); |
| 1732 } | 1736 } |
| 1733 } | 1737 } |
| (...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2595 // PosFromChar(i) might return 0 when i is greater than 1. | 2599 // PosFromChar(i) might return 0 when i is greater than 1. |
| 2596 return font_.GetStringWidth(text) + GetHorizontalMargin(); | 2600 return font_.GetStringWidth(text) + GetHorizontalMargin(); |
| 2597 } | 2601 } |
| 2598 | 2602 |
| 2599 bool OmniboxViewWin::IsCaretAtEnd() const { | 2603 bool OmniboxViewWin::IsCaretAtEnd() const { |
| 2600 long length = GetTextLength(); | 2604 long length = GetTextLength(); |
| 2601 CHARRANGE sel; | 2605 CHARRANGE sel; |
| 2602 GetSelection(sel); | 2606 GetSelection(sel); |
| 2603 return sel.cpMin == sel.cpMax && sel.cpMin == length; | 2607 return sel.cpMin == sel.cpMax && sel.cpMin == length; |
| 2604 } | 2608 } |
| OLD | NEW |