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) { |
1032 if ([urls count] > 1) | 1032 GURL url(GURL(url_formatter::FixupURL(base::SysNSStringToUTF8(urlString), |
1033 NOTIMPLEMENTED(); | 1033 std::string()))); |
Avi (use Gerrit)
2016/11/13 22:55:56
Same as above.
shahriar
2016/11/13 23:40:34
Done.
| |
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 |
Avi (use Gerrit)
2016/11/13 22:55:55
You lost the anti-self-XSS code.
shahriar
2016/11/13 23:40:34
Agree, I removed it because I thought we are no lo
| |
1039 // Security: Sanitize text to prevent self-XSS. | 1039 OpenURLParams params(url, Referrer(), |
1040 if (url.SchemeIs(url::kJavaScriptScheme)) { | 1040 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
1041 browser_->window()->GetLocationBar()->GetOmniboxView()->SetUserText( | 1041 ui::PAGE_TRANSITION_TYPED, false); |
1042 OmniboxView::StripJavascriptSchemas(base::UTF8ToUTF16(url.spec()))); | 1042 browser_->tab_strip_model()->GetActiveWebContents()->OpenURL(params); |
1043 return; | |
1044 } | 1043 } |
1045 | |
1046 OpenURLParams params(url, Referrer(), WindowOpenDisposition::CURRENT_TAB, | |
1047 ui::PAGE_TRANSITION_TYPED, false); | |
1048 browser_->tab_strip_model()->GetActiveWebContents()->OpenURL(params); | |
1049 } | 1044 } |
1050 | 1045 |
1051 // (URLDropTargetController protocol) | 1046 // (URLDropTargetController protocol) |
1052 - (void)dropText:(NSString*)text inView:(NSView*)view at:(NSPoint)point { | 1047 - (void)dropText:(NSString*)text inView:(NSView*)view at:(NSPoint)point { |
1053 // TODO(viettrungluu): This code is more or less copied from the code in | 1048 // 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 | 1049 // |TabStripController|. I'll refactor this soon to make it common and expand |
1055 // its capabilities (e.g., allow text DnD). | 1050 // its capabilities (e.g., allow text DnD). |
1056 | 1051 |
1057 // If the input is plain text, classify the input and make the URL. | 1052 // If the input is plain text, classify the input and make the URL. |
1058 AutocompleteMatch match; | 1053 AutocompleteMatch match; |
(...skipping 20 matching lines...) Expand all Loading... | |
1079 - (void)hideDropURLsIndicatorInView:(NSView*)view { | 1074 - (void)hideDropURLsIndicatorInView:(NSView*)view { |
1080 // Do nothing. | 1075 // Do nothing. |
1081 } | 1076 } |
1082 | 1077 |
1083 // (URLDropTargetController protocol) | 1078 // (URLDropTargetController protocol) |
1084 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { | 1079 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { |
1085 return drag_util::IsUnsupportedDropData(profile_, info); | 1080 return drag_util::IsUnsupportedDropData(profile_, info); |
1086 } | 1081 } |
1087 | 1082 |
1088 @end | 1083 @end |
OLD | NEW |