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_views.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
729 OnAfterPossibleChange(); | 729 OnAfterPossibleChange(); |
730 } | 730 } |
731 | 731 |
732 void OmniboxViewViews::OnAfterCutOrCopy() { | 732 void OmniboxViewViews::OnAfterCutOrCopy() { |
733 ui::Clipboard* cb = ui::Clipboard::GetForCurrentThread(); | 733 ui::Clipboard* cb = ui::Clipboard::GetForCurrentThread(); |
734 string16 selected_text; | 734 string16 selected_text; |
735 cb->ReadText(ui::Clipboard::BUFFER_STANDARD, &selected_text); | 735 cb->ReadText(ui::Clipboard::BUFFER_STANDARD, &selected_text); |
736 GURL url; | 736 GURL url; |
737 bool write_url; | 737 bool write_url; |
738 model()->AdjustTextForCopy(GetSelectedRange().GetMin(), IsSelectAll(), | 738 model()->AdjustTextForCopy(GetSelectedRange().GetMin(), IsSelectAll(), |
739 &selected_text, &url, &write_url); | 739 &selected_text, &url, &write_url); |
Peter Kasting
2013/10/03 23:46:43
Can we kill write_url entirely?
scottmg
2013/10/04 00:07:12
No, we use it e.g. below when determining if the d
| |
740 if (write_url) { | 740 ui::ScopedClipboardWriter scoped_clipboard_writer( |
741 BookmarkNodeData data; | 741 ui::Clipboard::GetForCurrentThread(), ui::Clipboard::BUFFER_STANDARD); |
742 data.ReadFromTuple(url, selected_text); | 742 scoped_clipboard_writer.WriteText(selected_text); |
743 data.WriteToClipboard(); | |
744 } else { | |
745 ui::ScopedClipboardWriter scoped_clipboard_writer( | |
746 ui::Clipboard::GetForCurrentThread(), ui::Clipboard::BUFFER_STANDARD); | |
747 scoped_clipboard_writer.WriteText(selected_text); | |
748 } | |
749 } | 743 } |
750 | 744 |
751 void OmniboxViewViews::OnGetDragOperationsForTextfield(int* drag_operations) { | 745 void OmniboxViewViews::OnGetDragOperationsForTextfield(int* drag_operations) { |
752 string16 selected_text = GetSelectedText(); | 746 string16 selected_text = GetSelectedText(); |
753 GURL url; | 747 GURL url; |
754 bool write_url; | 748 bool write_url; |
755 model()->AdjustTextForCopy(GetSelectedRange().GetMin(), IsSelectAll(), | 749 model()->AdjustTextForCopy(GetSelectedRange().GetMin(), IsSelectAll(), |
756 &selected_text, &url, &write_url); | 750 &selected_text, &url, &write_url); |
757 if (write_url) | 751 if (write_url) |
758 *drag_operations |= ui::DragDropTypes::DRAG_LINK; | 752 *drag_operations |= ui::DragDropTypes::DRAG_LINK; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
956 const string16 text(GetClipboardText()); | 950 const string16 text(GetClipboardText()); |
957 if (!text.empty()) { | 951 if (!text.empty()) { |
958 // Record this paste, so we can do different behavior. | 952 // Record this paste, so we can do different behavior. |
959 model()->on_paste(); | 953 model()->on_paste(); |
960 // Force a Paste operation to trigger the text_changed code in | 954 // Force a Paste operation to trigger the text_changed code in |
961 // OnAfterPossibleChange(), even if identical contents are pasted. | 955 // OnAfterPossibleChange(), even if identical contents are pasted. |
962 text_before_change_.clear(); | 956 text_before_change_.clear(); |
963 InsertOrReplaceText(text); | 957 InsertOrReplaceText(text); |
964 } | 958 } |
965 } | 959 } |
OLD | NEW |