| 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 #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/bundle_locations.h" | 9 #include "base/mac/bundle_locations.h" |
| 10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| (...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 // Get the first URL and fix it up. | 759 // Get the first URL and fix it up. |
| 760 GURL url(URLFixerUpper::FixupURL( | 760 GURL url(URLFixerUpper::FixupURL( |
| 761 base::SysNSStringToUTF8([urls objectAtIndex:0]), std::string())); | 761 base::SysNSStringToUTF8([urls objectAtIndex:0]), std::string())); |
| 762 | 762 |
| 763 if (url.SchemeIs(chrome::kJavaScriptScheme)) { | 763 if (url.SchemeIs(chrome::kJavaScriptScheme)) { |
| 764 browser_->window()->GetLocationBar()->GetLocationEntry()->SetUserText( | 764 browser_->window()->GetLocationBar()->GetLocationEntry()->SetUserText( |
| 765 OmniboxView::StripJavascriptSchemas(UTF8ToUTF16(url.spec()))); | 765 OmniboxView::StripJavascriptSchemas(UTF8ToUTF16(url.spec()))); |
| 766 } | 766 } |
| 767 OpenURLParams params( | 767 OpenURLParams params( |
| 768 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false); | 768 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false); |
| 769 browser_->GetSelectedWebContents()->OpenURL(params); | 769 browser_->GetActiveWebContents()->OpenURL(params); |
| 770 } | 770 } |
| 771 | 771 |
| 772 // (URLDropTargetController protocol) | 772 // (URLDropTargetController protocol) |
| 773 - (void)dropText:(NSString*)text inView:(NSView*)view at:(NSPoint)point { | 773 - (void)dropText:(NSString*)text inView:(NSView*)view at:(NSPoint)point { |
| 774 // TODO(viettrungluu): This code is more or less copied from the code in | 774 // TODO(viettrungluu): This code is more or less copied from the code in |
| 775 // |TabStripController|. I'll refactor this soon to make it common and expand | 775 // |TabStripController|. I'll refactor this soon to make it common and expand |
| 776 // its capabilities (e.g., allow text DnD). | 776 // its capabilities (e.g., allow text DnD). |
| 777 | 777 |
| 778 // If the input is plain text, classify the input and make the URL. | 778 // If the input is plain text, classify the input and make the URL. |
| 779 AutocompleteMatch match; | 779 AutocompleteMatch match; |
| 780 browser_->profile()->GetAutocompleteClassifier()->Classify( | 780 browser_->profile()->GetAutocompleteClassifier()->Classify( |
| 781 base::SysNSStringToUTF16(text), string16(), false, false, &match, NULL); | 781 base::SysNSStringToUTF16(text), string16(), false, false, &match, NULL); |
| 782 GURL url(match.destination_url); | 782 GURL url(match.destination_url); |
| 783 | 783 |
| 784 OpenURLParams params( | 784 OpenURLParams params( |
| 785 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false); | 785 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false); |
| 786 browser_->GetSelectedWebContents()->OpenURL(params); | 786 browser_->GetActiveWebContents()->OpenURL(params); |
| 787 } | 787 } |
| 788 | 788 |
| 789 // (URLDropTargetController protocol) | 789 // (URLDropTargetController protocol) |
| 790 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point { | 790 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point { |
| 791 // Do nothing. | 791 // Do nothing. |
| 792 } | 792 } |
| 793 | 793 |
| 794 // (URLDropTargetController protocol) | 794 // (URLDropTargetController protocol) |
| 795 - (void)hideDropURLsIndicatorInView:(NSView*)view { | 795 - (void)hideDropURLsIndicatorInView:(NSView*)view { |
| 796 // Do nothing. | 796 // Do nothing. |
| 797 } | 797 } |
| 798 | 798 |
| 799 // (URLDropTargetController protocol) | 799 // (URLDropTargetController protocol) |
| 800 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { | 800 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { |
| 801 return drag_util::IsUnsupportedDropData(profile_, info); | 801 return drag_util::IsUnsupportedDropData(profile_, info); |
| 802 } | 802 } |
| 803 | 803 |
| 804 @end | 804 @end |
| OLD | NEW |