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" | 10 #include "content/public/common/url_constants.h" |
| 11 #include "content/public/common/webplugininfo.h" |
11 #include "ipc/ipc_message.h" | 12 #include "ipc/ipc_message.h" |
12 #include "net/base/mime_util.h" | 13 #include "net/base/mime_util.h" |
13 #include "net/base/net_util.h" | 14 #include "net/base/net_util.h" |
14 #import "third_party/mozilla/NSPasteboard+Utils.h" | 15 #import "third_party/mozilla/NSPasteboard+Utils.h" |
15 #import "ui/base/dragdrop/cocoa_dnd_util.h" | 16 #import "ui/base/dragdrop/cocoa_dnd_util.h" |
16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
17 #include "webkit/plugins/webplugininfo.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); |
28 | 28 |
29 std::string mime_type; | 29 std::string mime_type; |
30 net::GetMimeTypeFromFile(full_path, &mime_type); | 30 net::GetMimeTypeFromFile(full_path, &mime_type); |
31 | 31 |
32 // This logic mirrors |BufferedResourceHandler::ShouldDownload()|. | 32 // This logic mirrors |BufferedResourceHandler::ShouldDownload()|. |
33 // TODO(asvitkine): Refactor this out to a common location instead of | 33 // TODO(asvitkine): Refactor this out to a common location instead of |
34 // duplicating code. | 34 // duplicating code. |
35 if (net::IsSupportedMimeType(mime_type)) | 35 if (net::IsSupportedMimeType(mime_type)) |
36 return YES; | 36 return YES; |
37 | 37 |
38 // Check whether there is a plugin that supports the mime type. (e.g. PDF) | 38 // Check whether there is a plugin that supports the mime type. (e.g. PDF) |
39 // TODO(bauerb): This possibly uses stale information, but it's guaranteed not | 39 // TODO(bauerb): This possibly uses stale information, but it's guaranteed not |
40 // to do disk access. | 40 // to do disk access. |
41 bool allow_wildcard = false; | 41 bool allow_wildcard = false; |
42 webkit::WebPluginInfo plugin; | 42 content::WebPluginInfo plugin; |
43 return PluginService::GetInstance()->GetPluginInfo( | 43 return PluginService::GetInstance()->GetPluginInfo( |
44 -1, // process ID | 44 -1, // process ID |
45 MSG_ROUTING_NONE, // routing ID | 45 MSG_ROUTING_NONE, // routing ID |
46 profile->GetResourceContext(), | 46 profile->GetResourceContext(), |
47 url, GURL(), mime_type, allow_wildcard, | 47 url, GURL(), mime_type, allow_wildcard, |
48 NULL, &plugin, NULL); | 48 NULL, &plugin, NULL); |
49 } | 49 } |
50 | 50 |
51 } // namespace | 51 } // namespace |
52 | 52 |
(...skipping 15 matching lines...) Expand all Loading... |
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 |