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 "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // URL. | 166 // URL. |
167 } else if ([type isEqualToString:NSURLPboardType]) { | 167 } else if ([type isEqualToString:NSURLPboardType]) { |
168 DCHECK(dropData_->url.is_valid()); | 168 DCHECK(dropData_->url.is_valid()); |
169 NSURL* url = [NSURL URLWithString:SysUTF8ToNSString(dropData_->url.spec())]; | 169 NSURL* url = [NSURL URLWithString:SysUTF8ToNSString(dropData_->url.spec())]; |
170 // If NSURL creation failed, check for a badly-escaped JavaScript URL. | 170 // If NSURL creation failed, check for a badly-escaped JavaScript URL. |
171 // Strip out any existing escapes and then re-escape uniformly. | 171 // Strip out any existing escapes and then re-escape uniformly. |
172 if (!url && dropData_->url.SchemeIs(url::kJavaScriptScheme)) { | 172 if (!url && dropData_->url.SchemeIs(url::kJavaScriptScheme)) { |
173 net::UnescapeRule::Type unescapeRules = | 173 net::UnescapeRule::Type unescapeRules = |
174 net::UnescapeRule::SPACES | | 174 net::UnescapeRule::SPACES | |
175 net::UnescapeRule::URL_SPECIAL_CHARS | | 175 net::UnescapeRule::URL_SPECIAL_CHARS | |
176 net::UnescapeRule::CONTROL_CHARS; | 176 net::UnescapeRule::SPOOFING_AND_CONTROL_CHARS; |
177 std::string unescapedUrlString = | 177 std::string unescapedUrlString = |
178 net::UnescapeURLComponent(dropData_->url.spec(), unescapeRules); | 178 net::UnescapeURLComponent(dropData_->url.spec(), unescapeRules); |
179 std::string escapedUrlString = | 179 std::string escapedUrlString = |
180 net::EscapeUrlEncodedData(unescapedUrlString, false); | 180 net::EscapeUrlEncodedData(unescapedUrlString, false); |
181 url = [NSURL URLWithString:SysUTF8ToNSString(escapedUrlString)]; | 181 url = [NSURL URLWithString:SysUTF8ToNSString(escapedUrlString)]; |
182 } | 182 } |
183 [url writeToPasteboard:pboard]; | 183 [url writeToPasteboard:pboard]; |
184 // URL title. | 184 // URL title. |
185 } else if ([type isEqualToString:kNSURLTitlePboardType]) { | 185 } else if ([type isEqualToString:kNSURLTitlePboardType]) { |
186 [pboard setString:SysUTF16ToNSString(dropData_->url_title) | 186 [pboard setString:SysUTF16ToNSString(dropData_->url_title) |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 - (NSImage*)dragImage { | 457 - (NSImage*)dragImage { |
458 if (dragImage_) | 458 if (dragImage_) |
459 return dragImage_; | 459 return dragImage_; |
460 | 460 |
461 // Default to returning a generic image. | 461 // Default to returning a generic image. |
462 return content::GetContentClient()->GetNativeImageNamed( | 462 return content::GetContentClient()->GetNativeImageNamed( |
463 IDR_DEFAULT_FAVICON).ToNSImage(); | 463 IDR_DEFAULT_FAVICON).ToNSImage(); |
464 } | 464 } |
465 | 465 |
466 @end // @implementation WebDragSource (Private) | 466 @end // @implementation WebDragSource (Private) |
OLD | NEW |