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_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 // See comment on |kHtmlHeader| above. | 193 // See comment on |kHtmlHeader| above. |
194 [pboard setString:SysUTF16ToNSString(kHtmlHeader + dropData_->html.string()) | 194 [pboard setString:SysUTF16ToNSString(kHtmlHeader + dropData_->html.string()) |
195 forType:type]; | 195 forType:type]; |
196 | 196 |
197 // URL. | 197 // URL. |
198 } else if ([type isEqualToString:NSURLPboardType]) { | 198 } else if ([type isEqualToString:NSURLPboardType]) { |
199 DCHECK(dropData_->url.is_valid()); | 199 DCHECK(dropData_->url.is_valid()); |
200 NSURL* url = [NSURL URLWithString:SysUTF8ToNSString(dropData_->url.spec())]; | 200 NSURL* url = [NSURL URLWithString:SysUTF8ToNSString(dropData_->url.spec())]; |
201 // If NSURL creation failed, check for a badly-escaped JavaScript URL. | 201 // If NSURL creation failed, check for a badly-escaped JavaScript URL. |
202 // Strip out any existing escapes and then re-escape uniformly. | 202 // Strip out any existing escapes and then re-escape uniformly. |
203 if (!url && dropData_->url.SchemeIs(chrome::kJavaScriptScheme)) { | 203 if (!url && dropData_->url.SchemeIs(content::kJavaScriptScheme)) { |
204 net::UnescapeRule::Type unescapeRules = | 204 net::UnescapeRule::Type unescapeRules = |
205 net::UnescapeRule::SPACES | | 205 net::UnescapeRule::SPACES | |
206 net::UnescapeRule::URL_SPECIAL_CHARS | | 206 net::UnescapeRule::URL_SPECIAL_CHARS | |
207 net::UnescapeRule::CONTROL_CHARS; | 207 net::UnescapeRule::CONTROL_CHARS; |
208 std::string unescapedUrlString = | 208 std::string unescapedUrlString = |
209 net::UnescapeURLComponent(dropData_->url.spec(), unescapeRules); | 209 net::UnescapeURLComponent(dropData_->url.spec(), unescapeRules); |
210 std::string escapedUrlString = | 210 std::string escapedUrlString = |
211 net::EscapeUrlEncodedData(unescapedUrlString, false); | 211 net::EscapeUrlEncodedData(unescapedUrlString, false); |
212 url = [NSURL URLWithString:SysUTF8ToNSString(escapedUrlString)]; | 212 url = [NSURL URLWithString:SysUTF8ToNSString(escapedUrlString)]; |
213 } | 213 } |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 - (NSImage*)dragImage { | 502 - (NSImage*)dragImage { |
503 if (dragImage_) | 503 if (dragImage_) |
504 return dragImage_; | 504 return dragImage_; |
505 | 505 |
506 // Default to returning a generic image. | 506 // Default to returning a generic image. |
507 return content::GetContentClient()->GetNativeImageNamed( | 507 return content::GetContentClient()->GetNativeImageNamed( |
508 IDR_DEFAULT_FAVICON).ToNSImage(); | 508 IDR_DEFAULT_FAVICON).ToNSImage(); |
509 } | 509 } |
510 | 510 |
511 @end // @implementation WebDragSource (Private) | 511 @end // @implementation WebDragSource (Private) |
OLD | NEW |