Chromium Code Reviews| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 772 const string16 text = textfield_->text(); | 772 const string16 text = textfield_->text(); |
| 773 GURL url; | 773 GURL url; |
| 774 bool write_url; | 774 bool write_url; |
| 775 model()->AdjustTextForCopy(selection_range.start(), selected_text == text, | 775 model()->AdjustTextForCopy(selection_range.start(), selected_text == text, |
| 776 &selected_text, &url, &write_url); | 776 &selected_text, &url, &write_url); |
| 777 data->SetString(selected_text); | 777 data->SetString(selected_text); |
| 778 if (write_url) | 778 if (write_url) |
| 779 data->SetURL(url, selected_text); | 779 data->SetURL(url, selected_text); |
| 780 } | 780 } |
| 781 | 781 |
| 782 void OmniboxViewViews::AppendDropFormats( | |
| 783 int* formats, | |
| 784 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) { | |
| 785 *formats = *formats | ui::OSExchangeData::URL; | |
| 786 } | |
| 787 | |
| 788 int OmniboxViewViews::OnDrop(const ui::OSExchangeData& data) { | |
| 789 if (data.HasURL()) { | |
|
sky
2012/12/03 23:46:40
Shouldn't this match the windows implementation? C
varunjain
2012/12/04 18:44:13
the windows implementation handles all drops in Om
| |
| 790 GURL url; | |
| 791 string16 title; | |
| 792 string16 text; | |
| 793 data.GetURLAndTitle(&url, &title); | |
| 794 if (url.is_valid()) | |
| 795 text = UTF8ToUTF16(url.spec()); | |
| 796 if (model()->CanPasteAndGo(text)) { | |
| 797 model()->PasteAndGo(text); | |
| 798 return ui::DragDropTypes::DRAG_COPY; | |
| 799 } | |
| 800 } | |
| 801 return ui::DragDropTypes::DRAG_NONE; | |
| 802 } | |
| 803 | |
| 782 void OmniboxViewViews::UpdateContextMenu(ui::SimpleMenuModel* menu_contents) { | 804 void OmniboxViewViews::UpdateContextMenu(ui::SimpleMenuModel* menu_contents) { |
| 783 // Minor note: We use IDC_ for command id here while the underlying textfield | 805 // Minor note: We use IDC_ for command id here while the underlying textfield |
| 784 // is using IDS_ for all its command ids. This is because views cannot depend | 806 // is using IDS_ for all its command ids. This is because views cannot depend |
| 785 // on IDC_ for now. | 807 // on IDC_ for now. |
| 786 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, | 808 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
| 787 IDS_EDIT_SEARCH_ENGINES); | 809 IDS_EDIT_SEARCH_ENGINES); |
| 788 | 810 |
| 789 if (chrome::search::IsInstantExtendedAPIEnabled( | 811 if (chrome::search::IsInstantExtendedAPIEnabled( |
| 790 location_bar_view_->profile())) { | 812 location_bar_view_->profile())) { |
| 791 int copy_position = menu_contents->GetIndexOfCommandId(IDS_APP_COPY); | 813 int copy_position = menu_contents->GetIndexOfCommandId(IDS_APP_COPY); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 934 if (!text.empty()) { | 956 if (!text.empty()) { |
| 935 // Record this paste, so we can do different behavior. | 957 // Record this paste, so we can do different behavior. |
| 936 model()->on_paste(); | 958 model()->on_paste(); |
| 937 // Force a Paste operation to trigger the text_changed code in | 959 // Force a Paste operation to trigger the text_changed code in |
| 938 // OnAfterPossibleChange(), even if identical contents are pasted into the | 960 // OnAfterPossibleChange(), even if identical contents are pasted into the |
| 939 // text box. | 961 // text box. |
| 940 text_before_change_.clear(); | 962 text_before_change_.clear(); |
| 941 textfield_->ReplaceSelection(text); | 963 textfield_->ReplaceSelection(text); |
| 942 } | 964 } |
| 943 } | 965 } |
| OLD | NEW |