OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/cocoa/drag_util.h" | 5 #import "chrome/browser/ui/cocoa/drag_util.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "content/public/browser/plugin_service.h" | 9 #include "content/public/browser/plugin_service.h" |
10 #include "content/public/common/url_constants.h" | |
11 #include "content/public/common/webplugininfo.h" | 10 #include "content/public/common/webplugininfo.h" |
12 #include "ipc/ipc_message.h" | 11 #include "ipc/ipc_message.h" |
13 #include "net/base/filename_util.h" | 12 #include "net/base/filename_util.h" |
14 #include "net/base/mime_util.h" | 13 #include "net/base/mime_util.h" |
15 #import "third_party/mozilla/NSPasteboard+Utils.h" | 14 #import "third_party/mozilla/NSPasteboard+Utils.h" |
16 #import "ui/base/dragdrop/cocoa_dnd_util.h" | 15 #import "ui/base/dragdrop/cocoa_dnd_util.h" |
17 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 17 #include "url/url_constants.h" |
18 | 18 |
19 using content::PluginService; | 19 using content::PluginService; |
20 | 20 |
21 namespace drag_util { | 21 namespace drag_util { |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 BOOL IsSupportedFileURL(Profile* profile, const GURL& url) { | 25 BOOL IsSupportedFileURL(Profile* profile, const GURL& url) { |
26 base::FilePath full_path; | 26 base::FilePath full_path; |
27 net::FileURLToFilePath(url, &full_path); | 27 net::FileURLToFilePath(url, &full_path); |
(...skipping 23 matching lines...) Expand all Loading... |
51 } // namespace | 51 } // namespace |
52 | 52 |
53 GURL GetFileURLFromDropData(id<NSDraggingInfo> info) { | 53 GURL GetFileURLFromDropData(id<NSDraggingInfo> info) { |
54 if ([[info draggingPasteboard] containsURLData]) { | 54 if ([[info draggingPasteboard] containsURLData]) { |
55 GURL url; | 55 GURL url; |
56 ui::PopulateURLAndTitleFromPasteboard(&url, | 56 ui::PopulateURLAndTitleFromPasteboard(&url, |
57 NULL, | 57 NULL, |
58 [info draggingPasteboard], | 58 [info draggingPasteboard], |
59 YES); | 59 YES); |
60 | 60 |
61 if (url.SchemeIs(content::kFileScheme)) | 61 if (url.SchemeIs(url::kFileScheme)) |
62 return url; | 62 return url; |
63 } | 63 } |
64 return GURL(); | 64 return GURL(); |
65 } | 65 } |
66 | 66 |
67 BOOL IsUnsupportedDropData(Profile* profile, id<NSDraggingInfo> info) { | 67 BOOL IsUnsupportedDropData(Profile* profile, id<NSDraggingInfo> info) { |
68 GURL url = GetFileURLFromDropData(info); | 68 GURL url = GetFileURLFromDropData(info); |
69 if (!url.is_empty()) { | 69 if (!url.is_empty()) { |
70 // If dragging a file, only allow dropping supported file types (that the | 70 // If dragging a file, only allow dropping supported file types (that the |
71 // web view can display). | 71 // web view can display). |
72 return !IsSupportedFileURL(profile, url); | 72 return !IsSupportedFileURL(profile, url); |
73 } | 73 } |
74 return NO; | 74 return NO; |
75 } | 75 } |
76 | 76 |
77 } // namespace drag_util | 77 } // namespace drag_util |
OLD | NEW |