Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: chrome/browser/ui/cocoa/drag_util.mm

Issue 7497030: PluginList cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix crash Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "content/common/url_constants.h" 10 #include "content/common/url_constants.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 std::string mime_type; 72 std::string mime_type;
73 net::GetMimeTypeFromFile(full_path, &mime_type); 73 net::GetMimeTypeFromFile(full_path, &mime_type);
74 74
75 // This logic mirrors |BufferedResourceHandler::ShouldDownload()|. 75 // This logic mirrors |BufferedResourceHandler::ShouldDownload()|.
76 // TODO(asvitkine): Refactor this out to a common location instead of 76 // TODO(asvitkine): Refactor this out to a common location instead of
77 // duplicating code. 77 // duplicating code.
78 if (net::IsSupportedMimeType(mime_type)) 78 if (net::IsSupportedMimeType(mime_type))
79 return YES; 79 return YES;
80 80
81 // Check whether there is a plugin that supports the mime type. (e.g. PDF) 81 // Check whether there is a plugin that supports the mime type. (e.g. PDF)
82 webkit::npapi::PluginList* list = webkit::npapi::PluginList::Singleton(); 82 // TODO(bauerb): This possibly uses stale information, but it's guaranteed not
83 webkit::npapi::WebPluginInfo info; 83 // to do disk access.
84 if (!list->stale() && 84 bool stale = false;
85 list->GetPluginInfo(GURL(), mime_type, false, &info, NULL)) { 85 std::vector<webkit::npapi::WebPluginInfo> info_array;
86 return webkit::npapi::IsPluginEnabled(info); 86 webkit::npapi::PluginList::Singleton()->GetPluginInfoArray(
87 url, mime_type, false, &stale, &info_array, NULL);
88 for (size_t i = 0; i < info_array.size(); ++i) {
89 if (webkit::npapi::IsPluginEnabled(info_array[i]))
90 return true;
87 } 91 }
88 92
89 return NO; 93 return NO;
90 } 94 }
91 95
92 BOOL IsUnsupportedDropData(id<NSDraggingInfo> info) { 96 BOOL IsUnsupportedDropData(id<NSDraggingInfo> info) {
93 GURL url = GetFileURLFromDropData(info); 97 GURL url = GetFileURLFromDropData(info);
94 if (!url.is_empty()) { 98 if (!url.is_empty()) {
95 // 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
96 // web view can display). 100 // web view can display).
97 return !IsSupportedFileURL(url); 101 return !IsSupportedFileURL(url);
98 } 102 }
99 return NO; 103 return NO;
100 } 104 }
101 105
102 } // namespace drag_util 106 } // namespace drag_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698