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/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1021 // (URLDropTargetController protocol) | 1021 // (URLDropTargetController protocol) |
1022 - (void)dropURLs:(NSArray*)urls inView:(NSView*)view at:(NSPoint)point { | 1022 - (void)dropURLs:(NSArray*)urls inView:(NSView*)view at:(NSPoint)point { |
1023 // TODO(viettrungluu): This code is more or less copied from the code in | 1023 // TODO(viettrungluu): This code is more or less copied from the code in |
1024 // |TabStripController|. I'll refactor this soon to make it common and expand | 1024 // |TabStripController|. I'll refactor this soon to make it common and expand |
1025 // its capabilities (e.g., allow text DnD). | 1025 // its capabilities (e.g., allow text DnD). |
1026 if ([urls count] < 1) { | 1026 if ([urls count] < 1) { |
1027 NOTREACHED(); | 1027 NOTREACHED(); |
1028 return; | 1028 return; |
1029 } | 1029 } |
1030 | 1030 |
1031 // TODO(viettrungluu): dropping multiple URLs? | 1031 for (id urlString in urls) { |
erikchen
2016/11/14 18:22:53
This code looks awfully similar to the previous ch
shahriar
2016/11/15 02:51:12
I looked for a common super/parent class, but they
| |
1032 if ([urls count] > 1) | 1032 GURL url = url_formatter::FixupURL(base::SysNSStringToUTF8(urlString), |
1033 NOTIMPLEMENTED(); | 1033 std::string()); |
1034 | 1034 |
1035 // Get the first URL and fix it up. | 1035 // If the URL isn't valid, don't bother. |
1036 GURL url(url_formatter::FixupURL( | 1036 if (!url.is_valid()) |
1037 base::SysNSStringToUTF8([urls objectAtIndex:0]), std::string())); | 1037 continue; |
1038 | 1038 |
1039 // Security: Sanitize text to prevent self-XSS. | 1039 // Security: Sanitize text to prevent self-XSS. |
1040 if (url.SchemeIs(url::kJavaScriptScheme)) { | 1040 if (url.SchemeIs(url::kJavaScriptScheme)) |
1041 browser_->window()->GetLocationBar()->GetOmniboxView()->SetUserText( | 1041 continue; |
1042 OmniboxView::StripJavascriptSchemas(base::UTF8ToUTF16(url.spec()))); | 1042 |
1043 return; | 1043 OpenURLParams params(url, Referrer(), |
1044 WindowOpenDisposition::NEW_FOREGROUND_TAB, | |
1045 ui::PAGE_TRANSITION_TYPED, false); | |
1046 browser_->tab_strip_model()->GetActiveWebContents()->OpenURL(params); | |
1044 } | 1047 } |
1045 | |
1046 OpenURLParams params(url, Referrer(), WindowOpenDisposition::CURRENT_TAB, | |
1047 ui::PAGE_TRANSITION_TYPED, false); | |
1048 browser_->tab_strip_model()->GetActiveWebContents()->OpenURL(params); | |
1049 } | 1048 } |
1050 | 1049 |
1051 // (URLDropTargetController protocol) | 1050 // (URLDropTargetController protocol) |
1052 - (void)dropText:(NSString*)text inView:(NSView*)view at:(NSPoint)point { | 1051 - (void)dropText:(NSString*)text inView:(NSView*)view at:(NSPoint)point { |
1053 // TODO(viettrungluu): This code is more or less copied from the code in | 1052 // TODO(viettrungluu): This code is more or less copied from the code in |
1054 // |TabStripController|. I'll refactor this soon to make it common and expand | 1053 // |TabStripController|. I'll refactor this soon to make it common and expand |
1055 // its capabilities (e.g., allow text DnD). | 1054 // its capabilities (e.g., allow text DnD). |
1056 | 1055 |
1057 // If the input is plain text, classify the input and make the URL. | 1056 // If the input is plain text, classify the input and make the URL. |
1058 AutocompleteMatch match; | 1057 AutocompleteMatch match; |
(...skipping 20 matching lines...) Expand all Loading... | |
1079 - (void)hideDropURLsIndicatorInView:(NSView*)view { | 1078 - (void)hideDropURLsIndicatorInView:(NSView*)view { |
1080 // Do nothing. | 1079 // Do nothing. |
1081 } | 1080 } |
1082 | 1081 |
1083 // (URLDropTargetController protocol) | 1082 // (URLDropTargetController protocol) |
1084 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { | 1083 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { |
1085 return drag_util::IsUnsupportedDropData(profile_, info); | 1084 return drag_util::IsUnsupportedDropData(profile_, info); |
1086 } | 1085 } |
1087 | 1086 |
1088 @end | 1087 @end |
OLD | NEW |