Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_view_views.cc

Issue 11416327: Omnibox should accept and navigate URLs dropped using drag and drop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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()) {
790 GURL url;
791 string16 title;
792 if (data.GetURLAndTitle(&url, &title)) {
793 string16 text(StripJavascriptSchemas(UTF8ToUTF16(url.spec())));
794 if (model()->CanPasteAndGo(text)) {
795 model()->PasteAndGo(text);
796 return ui::DragDropTypes::DRAG_COPY;
797 }
798 }
799 }
800 return ui::DragDropTypes::DRAG_NONE;
801 }
802
782 void OmniboxViewViews::UpdateContextMenu(ui::SimpleMenuModel* menu_contents) { 803 void OmniboxViewViews::UpdateContextMenu(ui::SimpleMenuModel* menu_contents) {
783 // Minor note: We use IDC_ for command id here while the underlying textfield 804 // 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 805 // is using IDS_ for all its command ids. This is because views cannot depend
785 // on IDC_ for now. 806 // on IDC_ for now.
786 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, 807 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES,
787 IDS_EDIT_SEARCH_ENGINES); 808 IDS_EDIT_SEARCH_ENGINES);
788 809
789 if (chrome::search::IsInstantExtendedAPIEnabled( 810 if (chrome::search::IsInstantExtendedAPIEnabled(
790 location_bar_view_->profile())) { 811 location_bar_view_->profile())) {
791 int copy_position = menu_contents->GetIndexOfCommandId(IDS_APP_COPY); 812 int copy_position = menu_contents->GetIndexOfCommandId(IDS_APP_COPY);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 if (!text.empty()) { 955 if (!text.empty()) {
935 // Record this paste, so we can do different behavior. 956 // Record this paste, so we can do different behavior.
936 model()->on_paste(); 957 model()->on_paste();
937 // Force a Paste operation to trigger the text_changed code in 958 // Force a Paste operation to trigger the text_changed code in
938 // OnAfterPossibleChange(), even if identical contents are pasted into the 959 // OnAfterPossibleChange(), even if identical contents are pasted into the
939 // text box. 960 // text box.
940 text_before_change_.clear(); 961 text_before_change_.clear();
941 textfield_->ReplaceSelection(text); 962 textfield_->ReplaceSelection(text);
942 } 963 }
943 } 964 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.h ('k') | ui/views/controls/textfield/native_textfield_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698