Chromium Code Reviews| 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 "content/browser/web_contents/web_drag_source_mac.h" | 5 #import "content/browser/web_contents/web_drag_source_mac.h" |
| 6 | 6 |
| 7 #include <sys/param.h> | 7 #include <sys/param.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 forType:type]; | 167 forType:type]; |
| 168 | 168 |
| 169 // URL. | 169 // URL. |
| 170 } else if ([type isEqualToString:NSURLPboardType]) { | 170 } else if ([type isEqualToString:NSURLPboardType]) { |
| 171 DCHECK(dropData_->url.is_valid()); | 171 DCHECK(dropData_->url.is_valid()); |
| 172 NSURL* url = [NSURL URLWithString:SysUTF8ToNSString(dropData_->url.spec())]; | 172 NSURL* url = [NSURL URLWithString:SysUTF8ToNSString(dropData_->url.spec())]; |
| 173 // If NSURL creation failed, check for a badly-escaped JavaScript URL. | 173 // If NSURL creation failed, check for a badly-escaped JavaScript URL. |
| 174 // Strip out any existing escapes and then re-escape uniformly. | 174 // Strip out any existing escapes and then re-escape uniformly. |
| 175 if (!url && dropData_->url.SchemeIs(url::kJavaScriptScheme)) { | 175 if (!url && dropData_->url.SchemeIs(url::kJavaScriptScheme)) { |
| 176 net::UnescapeRule::Type unescapeRules = | 176 net::UnescapeRule::Type unescapeRules = |
| 177 net::UnescapeRule::SPACES | | 177 net::UnescapeRule::SPACES | net::UnescapeRule::PATH_SEPARATORS | |
| 178 net::UnescapeRule::URL_SPECIAL_CHARS | | 178 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS | |
|
mmenke
2016/03/23 16:22:29
Unescaping path separators is always fine for Java
| |
| 179 net::UnescapeRule::SPOOFING_AND_CONTROL_CHARS; | 179 net::UnescapeRule::SPOOFING_AND_CONTROL_CHARS; |
| 180 std::string unescapedUrlString = | 180 std::string unescapedUrlString = |
| 181 net::UnescapeURLComponent(dropData_->url.spec(), unescapeRules); | 181 net::UnescapeURLComponent(dropData_->url.spec(), unescapeRules); |
| 182 std::string escapedUrlString = | 182 std::string escapedUrlString = |
| 183 net::EscapeUrlEncodedData(unescapedUrlString, false); | 183 net::EscapeUrlEncodedData(unescapedUrlString, false); |
| 184 url = [NSURL URLWithString:SysUTF8ToNSString(escapedUrlString)]; | 184 url = [NSURL URLWithString:SysUTF8ToNSString(escapedUrlString)]; |
| 185 } | 185 } |
| 186 [url writeToPasteboard:pboard]; | 186 [url writeToPasteboard:pboard]; |
| 187 // URL title. | 187 // URL title. |
| 188 } else if ([type isEqualToString:kNSURLTitlePboardType]) { | 188 } else if ([type isEqualToString:kNSURLTitlePboardType]) { |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 - (NSImage*)dragImage { | 464 - (NSImage*)dragImage { |
| 465 if (dragImage_) | 465 if (dragImage_) |
| 466 return dragImage_; | 466 return dragImage_; |
| 467 | 467 |
| 468 // Default to returning a generic image. | 468 // Default to returning a generic image. |
| 469 return content::GetContentClient()->GetNativeImageNamed( | 469 return content::GetContentClient()->GetNativeImageNamed( |
| 470 IDR_DEFAULT_FAVICON).ToNSImage(); | 470 IDR_DEFAULT_FAVICON).ToNSImage(); |
| 471 } | 471 } |
| 472 | 472 |
| 473 @end // @implementation WebDragSource (Private) | 473 @end // @implementation WebDragSource (Private) |
| OLD | NEW |