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/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
930 } | 930 } |
931 } | 931 } |
932 | 932 |
933 void OmniboxViewViews::OnWriteDragData(ui::OSExchangeData* data) { | 933 void OmniboxViewViews::OnWriteDragData(ui::OSExchangeData* data) { |
934 GURL url; | 934 GURL url; |
935 bool write_url; | 935 bool write_url; |
936 bool is_all_selected = IsSelectAll(); | 936 bool is_all_selected = IsSelectAll(); |
937 base::string16 selected_text = GetSelectedText(); | 937 base::string16 selected_text = GetSelectedText(); |
938 model()->AdjustTextForCopy(GetSelectedRange().GetMin(), is_all_selected, | 938 model()->AdjustTextForCopy(GetSelectedRange().GetMin(), is_all_selected, |
939 &selected_text, &url, &write_url); | 939 &selected_text, &url, &write_url); |
940 data->SetString(selected_text); | |
941 if (write_url) { | 940 if (write_url) { |
942 gfx::Image favicon; | 941 gfx::Image favicon; |
943 base::string16 title = selected_text; | 942 base::string16 title = selected_text; |
944 if (is_all_selected) | 943 if (is_all_selected) |
945 model()->GetDataForURLExport(&url, &title, &favicon); | 944 model()->GetDataForURLExport(&url, &title, &favicon); |
946 button_drag_utils::SetURLAndDragImage(url, title, favicon.AsImageSkia(), | 945 button_drag_utils::SetURLAndDragImage(url, title, favicon.AsImageSkia(), |
947 NULL, data, GetWidget()); | 946 NULL, data, GetWidget()); |
947 // Setting the URL also sets the string. | |
Peter Kasting
2014/06/20 20:45:36
This comment needs to say why it's important that
pkotwicz
2014/06/20 22:12:01
I removed the comment because as you mentioned it
| |
948 data->SetURL(url, title); | 948 data->SetURL(url, title); |
949 } else { | |
950 data->SetString(selected_text); | |
949 } | 951 } |
950 } | 952 } |
951 | 953 |
952 void OmniboxViewViews::OnGetDragOperationsForTextfield(int* drag_operations) { | 954 void OmniboxViewViews::OnGetDragOperationsForTextfield(int* drag_operations) { |
953 base::string16 selected_text = GetSelectedText(); | 955 base::string16 selected_text = GetSelectedText(); |
954 GURL url; | 956 GURL url; |
955 bool write_url; | 957 bool write_url; |
956 model()->AdjustTextForCopy(GetSelectedRange().GetMin(), IsSelectAll(), | 958 model()->AdjustTextForCopy(GetSelectedRange().GetMin(), IsSelectAll(), |
957 &selected_text, &url, &write_url); | 959 &selected_text, &url, &write_url); |
958 if (write_url) | 960 if (write_url) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1009 menu_contents->InsertItemWithStringIdAt( | 1011 menu_contents->InsertItemWithStringIdAt( |
1010 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL); | 1012 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL); |
1011 } | 1013 } |
1012 | 1014 |
1013 // Minor note: We use IDC_ for command id here while the underlying textfield | 1015 // Minor note: We use IDC_ for command id here while the underlying textfield |
1014 // is using IDS_ for all its command ids. This is because views cannot depend | 1016 // is using IDS_ for all its command ids. This is because views cannot depend |
1015 // on IDC_ for now. | 1017 // on IDC_ for now. |
1016 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, | 1018 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
1017 IDS_EDIT_SEARCH_ENGINES); | 1019 IDS_EDIT_SEARCH_ENGINES); |
1018 } | 1020 } |
OLD | NEW |