OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 5 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 // Get the first URL and fix it up. | 776 // Get the first URL and fix it up. |
777 GURL url(URLFixerUpper::FixupURL( | 777 GURL url(URLFixerUpper::FixupURL( |
778 base::SysNSStringToUTF8([urls objectAtIndex:0]), std::string())); | 778 base::SysNSStringToUTF8([urls objectAtIndex:0]), std::string())); |
779 | 779 |
780 if (url.SchemeIs(chrome::kJavaScriptScheme)) { | 780 if (url.SchemeIs(chrome::kJavaScriptScheme)) { |
781 browser_->window()->GetLocationBar()->location_entry()->SetUserText( | 781 browser_->window()->GetLocationBar()->location_entry()->SetUserText( |
782 OmniboxView::StripJavascriptSchemas(UTF8ToUTF16(url.spec()))); | 782 OmniboxView::StripJavascriptSchemas(UTF8ToUTF16(url.spec()))); |
783 return; | 783 return; |
784 } | 784 } |
785 browser_->GetSelectedTabContents()->OpenURL(url, GURL(), CURRENT_TAB, | 785 browser_->GetSelectedTabContents()->OpenURL(url, GURL(), CURRENT_TAB, |
786 PageTransition::TYPED); | 786 content::PAGE_TRANSITION_TYPED); |
787 } | 787 } |
788 | 788 |
789 // (URLDropTargetController protocol) | 789 // (URLDropTargetController protocol) |
790 - (void)dropText:(NSString*)text inView:(NSView*)view at:(NSPoint)point { | 790 - (void)dropText:(NSString*)text inView:(NSView*)view at:(NSPoint)point { |
791 // TODO(viettrungluu): This code is more or less copied from the code in | 791 // TODO(viettrungluu): This code is more or less copied from the code in |
792 // |TabStripController|. I'll refactor this soon to make it common and expand | 792 // |TabStripController|. I'll refactor this soon to make it common and expand |
793 // its capabilities (e.g., allow text DnD). | 793 // its capabilities (e.g., allow text DnD). |
794 | 794 |
795 // If the input is plain text, classify the input and make the URL. | 795 // If the input is plain text, classify the input and make the URL. |
796 AutocompleteMatch match; | 796 AutocompleteMatch match; |
797 browser_->profile()->GetAutocompleteClassifier()->Classify( | 797 browser_->profile()->GetAutocompleteClassifier()->Classify( |
798 base::SysNSStringToUTF16(text), string16(), false, false, &match, NULL); | 798 base::SysNSStringToUTF16(text), string16(), false, false, &match, NULL); |
799 GURL url(match.destination_url); | 799 GURL url(match.destination_url); |
800 | 800 |
801 browser_->GetSelectedTabContents()->OpenURL(url, GURL(), CURRENT_TAB, | 801 browser_->GetSelectedTabContents()->OpenURL(url, GURL(), CURRENT_TAB, |
802 PageTransition::TYPED); | 802 content::PAGE_TRANSITION_TYPED); |
803 } | 803 } |
804 | 804 |
805 // (URLDropTargetController protocol) | 805 // (URLDropTargetController protocol) |
806 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point { | 806 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point { |
807 // Do nothing. | 807 // Do nothing. |
808 } | 808 } |
809 | 809 |
810 // (URLDropTargetController protocol) | 810 // (URLDropTargetController protocol) |
811 - (void)hideDropURLsIndicatorInView:(NSView*)view { | 811 - (void)hideDropURLsIndicatorInView:(NSView*)view { |
812 // Do nothing. | 812 // Do nothing. |
813 } | 813 } |
814 | 814 |
815 // (URLDropTargetController protocol) | 815 // (URLDropTargetController protocol) |
816 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { | 816 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { |
817 return drag_util::IsUnsupportedDropData(profile_, info); | 817 return drag_util::IsUnsupportedDropData(profile_, info); |
818 } | 818 } |
819 | 819 |
820 @end | 820 @end |
OLD | NEW |