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()); |
948 data->SetURL(url, title); | 947 data->SetURL(url, title); |
948 } else { | |
949 data->SetString(selected_text); | |
sky
2014/07/09 20:39:08
Why don't we always want to set the string content
pkotwicz
2014/07/09 23:00:18
The string content is set by the first caller of O
sky
2014/07/10 16:13:03
Was this always the case? I wonder if SetURL shoul
| |
949 } | 950 } |
950 } | 951 } |
951 | 952 |
952 void OmniboxViewViews::OnGetDragOperationsForTextfield(int* drag_operations) { | 953 void OmniboxViewViews::OnGetDragOperationsForTextfield(int* drag_operations) { |
953 base::string16 selected_text = GetSelectedText(); | 954 base::string16 selected_text = GetSelectedText(); |
954 GURL url; | 955 GURL url; |
955 bool write_url; | 956 bool write_url; |
956 model()->AdjustTextForCopy(GetSelectedRange().GetMin(), IsSelectAll(), | 957 model()->AdjustTextForCopy(GetSelectedRange().GetMin(), IsSelectAll(), |
957 &selected_text, &url, &write_url); | 958 &selected_text, &url, &write_url); |
958 if (write_url) | 959 if (write_url) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1009 menu_contents->InsertItemWithStringIdAt( | 1010 menu_contents->InsertItemWithStringIdAt( |
1010 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL); | 1011 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL); |
1011 } | 1012 } |
1012 | 1013 |
1013 // Minor note: We use IDC_ for command id here while the underlying textfield | 1014 // 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 | 1015 // is using IDS_ for all its command ids. This is because views cannot depend |
1015 // on IDC_ for now. | 1016 // on IDC_ for now. |
1016 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, | 1017 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
1017 IDS_EDIT_SEARCH_ENGINES); | 1018 IDS_EDIT_SEARCH_ENGINES); |
1018 } | 1019 } |
OLD | NEW |