Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2004)

Unified Diff: app/clipboard/clipboard_mac.mm

Issue 2674002: Convert RTF on the pasteboard to HTML and all it to substitute if present and... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « app/DEPS ('k') | chrome/browser/cocoa/web_drop_target.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/clipboard/clipboard_mac.mm
===================================================================
--- app/clipboard/clipboard_mac.mm (revision 48762)
+++ app/clipboard/clipboard_mac.mm (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -14,6 +14,7 @@
#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
#include "gfx/size.h"
+#import "third_party/mozilla/NSPasteboard+Utils.h"
namespace {
@@ -165,6 +166,12 @@
NSPasteboard* pb = GetPasteboard();
NSArray* types = [pb types];
+ // Safari only places RTF on the pasteboard, never HTML. We can convert RTF
+ // to HTML, so the presence of either indicates success when looking for HTML.
+ if ([format_ns isEqualToString:NSHTMLPboardType]) {
+ return [types containsObject:NSHTMLPboardType] ||
+ [types containsObject:NSRTFPboardType];
+ }
return [types containsObject:format_ns];
}
@@ -195,11 +202,14 @@
DCHECK_EQ(buffer, BUFFER_STANDARD);
if (markup) {
NSPasteboard* pb = GetPasteboard();
- NSArray *supportedTypes = [NSArray arrayWithObjects:NSHTMLPboardType,
+ NSArray* supportedTypes = [NSArray arrayWithObjects:NSHTMLPboardType,
+ NSRTFPboardType,
NSStringPboardType,
nil];
- NSString *bestType = [pb availableTypeFromArray:supportedTypes];
+ NSString* bestType = [pb availableTypeFromArray:supportedTypes];
NSString* contents = [pb stringForType:bestType];
+ if ([bestType isEqualToString:NSRTFPboardType])
+ contents = [pb htmlFromRtf];
UTF8ToUTF16([contents UTF8String],
[contents lengthOfBytesUsingEncoding:NSUTF8StringEncoding],
markup);
« no previous file with comments | « app/DEPS ('k') | chrome/browser/cocoa/web_drop_target.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698