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/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // This logic mirrors |BufferedResourceHandler::ShouldDownload()|. | 77 // This logic mirrors |BufferedResourceHandler::ShouldDownload()|. |
78 // TODO(asvitkine): Refactor this out to a common location instead of | 78 // TODO(asvitkine): Refactor this out to a common location instead of |
79 // duplicating code. | 79 // duplicating code. |
80 if (net::IsSupportedMimeType(mime_type)) | 80 if (net::IsSupportedMimeType(mime_type)) |
81 return YES; | 81 return YES; |
82 | 82 |
83 // Check whether there is a plugin that supports the mime type. (e.g. PDF) | 83 // Check whether there is a plugin that supports the mime type. (e.g. PDF) |
84 // TODO(bauerb): This possibly uses stale information, but it's guaranteed not | 84 // TODO(bauerb): This possibly uses stale information, but it's guaranteed not |
85 // to do disk access. | 85 // to do disk access. |
86 bool allow_wildcard = false; | 86 bool allow_wildcard = false; |
87 bool stale = false; | |
88 webkit::WebPluginInfo plugin; | 87 webkit::WebPluginInfo plugin; |
89 return PluginService::GetInstance()->GetPluginInfo( | 88 return PluginService::GetInstance()->GetPluginInfo( |
90 -1, // process ID | 89 -1, // process ID |
91 MSG_ROUTING_NONE, // routing ID | 90 MSG_ROUTING_NONE, // routing ID |
92 profile->GetResourceContext(), | 91 profile->GetResourceContext(), |
93 url, GURL(), mime_type, allow_wildcard, | 92 url, GURL(), mime_type, allow_wildcard, |
94 &stale, &plugin, NULL); | 93 NULL, &plugin, NULL); |
95 } | 94 } |
96 | 95 |
97 BOOL IsUnsupportedDropData(Profile* profile, id<NSDraggingInfo> info) { | 96 BOOL IsUnsupportedDropData(Profile* profile, id<NSDraggingInfo> info) { |
98 GURL url = GetFileURLFromDropData(info); | 97 GURL url = GetFileURLFromDropData(info); |
99 if (!url.is_empty()) { | 98 if (!url.is_empty()) { |
100 // If dragging a file, only allow dropping supported file types (that the | 99 // If dragging a file, only allow dropping supported file types (that the |
101 // web view can display). | 100 // web view can display). |
102 return !IsSupportedFileURL(profile, url); | 101 return !IsSupportedFileURL(profile, url); |
103 } | 102 } |
104 return NO; | 103 return NO; |
105 } | 104 } |
106 | 105 |
107 } // namespace drag_util | 106 } // namespace drag_util |
OLD | NEW |