Index: chrome/browser/ui/cocoa/drag_util.mm |
diff --git a/chrome/browser/ui/cocoa/drag_util.mm b/chrome/browser/ui/cocoa/drag_util.mm |
index a8d94302af324ba87d8883cc434ec9b16867269c..40ea249a2b052e6f1d6610b55f2097fb09b1e03a 100644 |
--- a/chrome/browser/ui/cocoa/drag_util.mm |
+++ b/chrome/browser/ui/cocoa/drag_util.mm |
@@ -4,9 +4,7 @@ |
#import "chrome/browser/ui/cocoa/drag_util.h" |
-#include "base/basictypes.h" |
-#include "base/logging.h" |
-#include "base/sys_string_conversions.h" |
+#include "base/file_path.h" |
#include "chrome/browser/profiles/profile.h" |
#include "content/browser/plugin_service.h" |
#include "content/public/common/url_constants.h" |
@@ -14,60 +12,13 @@ |
#include "net/base/mime_util.h" |
#include "net/base/net_util.h" |
#import "third_party/mozilla/NSPasteboard+Utils.h" |
-#include "webkit/plugins/npapi/plugin_list.h" |
+#import "ui/base/dragdrop/cocoa_dnd_util.h" |
namespace drag_util { |
-BOOL PopulateURLAndTitleFromPasteBoard(GURL* url, |
- string16* title, |
- NSPasteboard* pboard, |
- BOOL convert_filenames) { |
- CHECK(url); |
+namespace { |
- // Bail out early if there's no URL data. |
- if (![pboard containsURLData]) |
- return NO; |
- |
- // -getURLs:andTitles:convertingFilenames: will already validate URIs so we |
- // don't need to again. The arrays returned are both of NSStrings. |
- NSArray* url_array = nil; |
- NSArray* title_array = nil; |
- [pboard getURLs:&url_array andTitles:&title_array |
- convertingFilenames:convert_filenames]; |
- DCHECK_EQ([url_array count], [title_array count]); |
- // It's possible that no URLs were actually provided! |
- if (![url_array count]) |
- return NO; |
- NSString* url_string = [url_array objectAtIndex:0]; |
- if ([url_string length]) { |
- // Check again just to make sure to not assign NULL into a std::string, |
- // which throws an exception. |
- const char* utf8_url = [url_string UTF8String]; |
- if (utf8_url) { |
- *url = GURL(utf8_url); |
- // Extra paranoia check. |
- if (title && [title_array count]) |
- *title = base::SysNSStringToUTF16([title_array objectAtIndex:0]); |
- } |
- } |
- return YES; |
-} |
- |
-GURL GetFileURLFromDropData(id<NSDraggingInfo> info) { |
- if ([[info draggingPasteboard] containsURLData]) { |
- GURL url; |
- PopulateURLAndTitleFromPasteBoard(&url, |
- NULL, |
- [info draggingPasteboard], |
- YES); |
- |
- if (url.SchemeIs(chrome::kFileScheme)) |
- return url; |
- } |
- return GURL(); |
-} |
- |
-static BOOL IsSupportedFileURL(Profile* profile, const GURL& url) { |
+BOOL IsSupportedFileURL(Profile* profile, const GURL& url) { |
FilePath full_path; |
net::FileURLToFilePath(url, &full_path); |
@@ -93,6 +44,22 @@ static BOOL IsSupportedFileURL(Profile* profile, const GURL& url) { |
NULL, &plugin, NULL); |
} |
+} // namespace |
+ |
+GURL GetFileURLFromDropData(id<NSDraggingInfo> info) { |
+ if ([[info draggingPasteboard] containsURLData]) { |
+ GURL url; |
+ ui::PopulateURLAndTitleFromPasteboard(&url, |
+ NULL, |
+ [info draggingPasteboard], |
+ YES); |
+ |
+ if (url.SchemeIs(chrome::kFileScheme)) |
+ return url; |
+ } |
+ return GURL(); |
+} |
+ |
BOOL IsUnsupportedDropData(Profile* profile, id<NSDraggingInfo> info) { |
GURL url = GetFileURLFromDropData(info); |
if (!url.is_empty()) { |