| 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 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 | 788 |
| 789 // Get the first URL and fix it up. | 789 // Get the first URL and fix it up. |
| 790 GURL url(url_fixer::FixupURL(base::SysNSStringToUTF8([urls objectAtIndex:0]), | 790 GURL url(url_fixer::FixupURL(base::SysNSStringToUTF8([urls objectAtIndex:0]), |
| 791 std::string())); | 791 std::string())); |
| 792 | 792 |
| 793 if (url.SchemeIs(url::kJavaScriptScheme)) { | 793 if (url.SchemeIs(url::kJavaScriptScheme)) { |
| 794 browser_->window()->GetLocationBar()->GetOmniboxView()->SetUserText( | 794 browser_->window()->GetLocationBar()->GetOmniboxView()->SetUserText( |
| 795 OmniboxView::StripJavascriptSchemas(base::UTF8ToUTF16(url.spec()))); | 795 OmniboxView::StripJavascriptSchemas(base::UTF8ToUTF16(url.spec()))); |
| 796 } | 796 } |
| 797 OpenURLParams params( | 797 OpenURLParams params( |
| 798 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false); | 798 url, Referrer(), CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false); |
| 799 browser_->tab_strip_model()->GetActiveWebContents()->OpenURL(params); | 799 browser_->tab_strip_model()->GetActiveWebContents()->OpenURL(params); |
| 800 } | 800 } |
| 801 | 801 |
| 802 // (URLDropTargetController protocol) | 802 // (URLDropTargetController protocol) |
| 803 - (void)dropText:(NSString*)text inView:(NSView*)view at:(NSPoint)point { | 803 - (void)dropText:(NSString*)text inView:(NSView*)view at:(NSPoint)point { |
| 804 // TODO(viettrungluu): This code is more or less copied from the code in | 804 // TODO(viettrungluu): This code is more or less copied from the code in |
| 805 // |TabStripController|. I'll refactor this soon to make it common and expand | 805 // |TabStripController|. I'll refactor this soon to make it common and expand |
| 806 // its capabilities (e.g., allow text DnD). | 806 // its capabilities (e.g., allow text DnD). |
| 807 | 807 |
| 808 // If the input is plain text, classify the input and make the URL. | 808 // If the input is plain text, classify the input and make the URL. |
| 809 AutocompleteMatch match; | 809 AutocompleteMatch match; |
| 810 AutocompleteClassifierFactory::GetForProfile(browser_->profile())->Classify( | 810 AutocompleteClassifierFactory::GetForProfile(browser_->profile())->Classify( |
| 811 base::SysNSStringToUTF16(text), false, false, | 811 base::SysNSStringToUTF16(text), false, false, |
| 812 metrics::OmniboxEventProto::BLANK, &match, NULL); | 812 metrics::OmniboxEventProto::BLANK, &match, NULL); |
| 813 GURL url(match.destination_url); | 813 GURL url(match.destination_url); |
| 814 | 814 |
| 815 OpenURLParams params( | 815 OpenURLParams params( |
| 816 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false); | 816 url, Referrer(), CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false); |
| 817 browser_->tab_strip_model()->GetActiveWebContents()->OpenURL(params); | 817 browser_->tab_strip_model()->GetActiveWebContents()->OpenURL(params); |
| 818 } | 818 } |
| 819 | 819 |
| 820 // (URLDropTargetController protocol) | 820 // (URLDropTargetController protocol) |
| 821 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point { | 821 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point { |
| 822 // Do nothing. | 822 // Do nothing. |
| 823 } | 823 } |
| 824 | 824 |
| 825 // (URLDropTargetController protocol) | 825 // (URLDropTargetController protocol) |
| 826 - (void)hideDropURLsIndicatorInView:(NSView*)view { | 826 - (void)hideDropURLsIndicatorInView:(NSView*)view { |
| 827 // Do nothing. | 827 // Do nothing. |
| 828 } | 828 } |
| 829 | 829 |
| 830 // (URLDropTargetController protocol) | 830 // (URLDropTargetController protocol) |
| 831 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { | 831 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { |
| 832 return drag_util::IsUnsupportedDropData(profile_, info); | 832 return drag_util::IsUnsupportedDropData(profile_, info); |
| 833 } | 833 } |
| 834 | 834 |
| 835 @end | 835 @end |
| OLD | NEW |