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 <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "content/common/mime_util.h" |
13 #include "content/public/browser/plugin_service.h" | 14 #include "content/public/browser/plugin_service.h" |
14 #include "content/public/common/webplugininfo.h" | 15 #include "content/public/common/webplugininfo.h" |
15 #include "ipc/ipc_message.h" | 16 #include "ipc/ipc_message.h" |
16 #include "net/base/filename_util.h" | 17 #include "net/base/filename_util.h" |
17 #include "net/base/mime_util.h" | 18 #include "net/base/mime_util.h" |
18 #import "third_party/mozilla/NSPasteboard+Utils.h" | 19 #import "third_party/mozilla/NSPasteboard+Utils.h" |
19 #import "ui/base/dragdrop/cocoa_dnd_util.h" | 20 #import "ui/base/dragdrop/cocoa_dnd_util.h" |
20 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
21 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 22 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
22 #include "ui/resources/grit/ui_resources.h" | 23 #include "ui/resources/grit/ui_resources.h" |
23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
24 #include "url/url_constants.h" | 25 #include "url/url_constants.h" |
25 | 26 |
26 using content::PluginService; | 27 using content::PluginService; |
27 | 28 |
28 namespace drag_util { | 29 namespace drag_util { |
29 | 30 |
30 namespace { | 31 namespace { |
31 | 32 |
32 BOOL IsSupportedFileURL(Profile* profile, const GURL& url) { | 33 BOOL IsSupportedFileURL(Profile* profile, const GURL& url) { |
33 base::FilePath full_path; | 34 base::FilePath full_path; |
34 net::FileURLToFilePath(url, &full_path); | 35 net::FileURLToFilePath(url, &full_path); |
35 | 36 |
36 std::string mime_type; | 37 std::string mime_type; |
37 net::GetMimeTypeFromFile(full_path, &mime_type); | 38 net::GetMimeTypeFromFile(full_path, &mime_type); |
38 | 39 |
39 // This logic mirrors |BufferedResourceHandler::ShouldDownload()|. | 40 // This logic mirrors |BufferedResourceHandler::ShouldDownload()|. |
40 // TODO(asvitkine): Refactor this out to a common location instead of | 41 // TODO(asvitkine): Refactor this out to a common location instead of |
41 // duplicating code. | 42 // duplicating code. |
42 if (net::IsSupportedMimeType(mime_type)) | 43 if (content::IsSupportedMimeType(mime_type)) |
43 return YES; | 44 return YES; |
44 | 45 |
45 // Check whether there is a plugin that supports the mime type. (e.g. PDF) | 46 // Check whether there is a plugin that supports the mime type. (e.g. PDF) |
46 // TODO(bauerb): This possibly uses stale information, but it's guaranteed not | 47 // TODO(bauerb): This possibly uses stale information, but it's guaranteed not |
47 // to do disk access. | 48 // to do disk access. |
48 bool allow_wildcard = false; | 49 bool allow_wildcard = false; |
49 content::WebPluginInfo plugin; | 50 content::WebPluginInfo plugin; |
50 return PluginService::GetInstance()->GetPluginInfo( | 51 return PluginService::GetInstance()->GetPluginInfo( |
51 -1, // process ID | 52 -1, // process ID |
52 MSG_ROUTING_NONE, // routing ID | 53 MSG_ROUTING_NONE, // routing ID |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 fraction:0.7]; | 160 fraction:0.7]; |
160 NSRect target_text_rect = NSMakeRect(text_left, 0, | 161 NSRect target_text_rect = NSMakeRect(text_left, 0, |
161 text_size.width, drag_image_size.height); | 162 text_size.width, drag_image_size.height); |
162 DrawTruncatedTitle(rich_title, target_text_rect); | 163 DrawTruncatedTitle(rich_title, target_text_rect); |
163 [drag_image unlockFocus]; | 164 [drag_image unlockFocus]; |
164 | 165 |
165 return drag_image; | 166 return drag_image; |
166 } | 167 } |
167 | 168 |
168 } // namespace drag_util | 169 } // namespace drag_util |
OLD | NEW |