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

Side by Side Diff: webkit/glue/plugins/plugin_list.cc

Issue 207025: NaCl-Chrome integration (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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
« no previous file with comments | « webkit/glue/plugins/plugin_list.h ('k') | webkit/glue/plugins/plugin_list_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "webkit/glue/plugins/plugin_list.h" 5 #include "webkit/glue/plugins/plugin_list.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/time.h" 10 #include "base/time.h"
11 #include "net/base/mime_util.h" 11 #include "net/base/mime_util.h"
12 #include "webkit/default_plugin/plugin_main.h" 12 #include "webkit/default_plugin/plugin_main.h"
13 #include "webkit/glue/plugins/plugin_constants_win.h" 13 #include "webkit/glue/plugins/plugin_constants_win.h"
14 #include "webkit/glue/plugins/plugin_lib.h" 14 #include "webkit/glue/plugins/plugin_lib.h"
15 #include "webkit/glue/webkit_glue.h" 15 #include "webkit/glue/webkit_glue.h"
16 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
17 17
18 #define kNpGoogleNaClPlugin (FILE_PATH_LITERAL("npgooglenaclplugin"))
19
18 namespace NPAPI { 20 namespace NPAPI {
19 21
20 base::LazyInstance<PluginList> g_singleton(base::LINKER_INITIALIZED); 22 base::LazyInstance<PluginList> g_singleton(base::LINKER_INITIALIZED);
21 23
22 // static 24 // static
23 PluginList* PluginList::Singleton() { 25 PluginList* PluginList::Singleton() {
24 return g_singleton.Pointer(); 26 return g_singleton.Pointer();
25 } 27 }
26 28
27 bool PluginList::PluginsLoaded() { 29 bool PluginList::PluginsLoaded() {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 mime_type.description.erase(ext); 108 mime_type.description.erase(ext);
107 } 109 }
108 } 110 }
109 111
110 info->mime_types.push_back(mime_type); 112 info->mime_types.push_back(mime_type);
111 } 113 }
112 114
113 return true; 115 return true;
114 } 116 }
115 117
116 PluginList::PluginList() : plugins_loaded_(false) { 118 PluginList::PluginList() : plugins_loaded_(false),
119 use_internal_nacl_(false) {
117 PlatformInit(); 120 PlatformInit();
118 121
119 #if defined(OS_WIN) 122 #if defined(OS_WIN)
120 const PluginVersionInfo default_plugin = { 123 const PluginVersionInfo default_plugin = {
121 FilePath(kDefaultPluginLibraryName), 124 FilePath(kDefaultPluginLibraryName),
122 L"Default Plug-in", 125 L"Default Plug-in",
123 L"Provides functionality for installing third-party plug-ins", 126 L"Provides functionality for installing third-party plug-ins",
124 L"1", 127 L"1",
125 L"*", 128 L"*",
126 L"", 129 L"",
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 LoadPlugin(extra_plugin_paths[i], &new_plugins); 164 LoadPlugin(extra_plugin_paths[i], &new_plugins);
162 165
163 for (size_t i = 0; i < extra_plugin_dirs.size(); ++i) { 166 for (size_t i = 0; i < extra_plugin_dirs.size(); ++i) {
164 LoadPluginsFromDir(extra_plugin_dirs[i], &new_plugins); 167 LoadPluginsFromDir(extra_plugin_dirs[i], &new_plugins);
165 } 168 }
166 169
167 for (size_t i = 0; i < directories_to_scan.size(); ++i) { 170 for (size_t i = 0; i < directories_to_scan.size(); ++i) {
168 LoadPluginsFromDir(directories_to_scan[i], &new_plugins); 171 LoadPluginsFromDir(directories_to_scan[i], &new_plugins);
169 } 172 }
170 173
174 if (use_internal_nacl_) {
175 LoadPlugin(FilePath(kNaClPluginLibraryName), &new_plugins);
176 }
177
171 if (webkit_glue::IsDefaultPluginEnabled()) 178 if (webkit_glue::IsDefaultPluginEnabled())
172 LoadPlugin(FilePath(kDefaultPluginLibraryName), &new_plugins); 179 LoadPlugin(FilePath(kDefaultPluginLibraryName), &new_plugins);
173 180
174 base::TimeTicks end_time = base::TimeTicks::Now(); 181 base::TimeTicks end_time = base::TimeTicks::Now();
175 base::TimeDelta elapsed = end_time - start_time; 182 base::TimeDelta elapsed = end_time - start_time;
176 DLOG(INFO) << "Loaded plugin list in " << elapsed.InMilliseconds() << " ms."; 183 DLOG(INFO) << "Loaded plugin list in " << elapsed.InMilliseconds() << " ms.";
177 184
178 AutoLock lock(lock_); 185 AutoLock lock(lock_);
179 plugins_ = new_plugins; 186 plugins_ = new_plugins;
180 plugins_loaded_ = true; 187 plugins_loaded_ = true;
(...skipping 21 matching lines...) Expand all
202 // to handle mimeTypes on its own. 209 // to handle mimeTypes on its own.
203 const std::string &mime_type = plugin_info.mime_types[i].mime_type; 210 const std::string &mime_type = plugin_info.mime_types[i].mime_type;
204 if (mime_type == "*" ) 211 if (mime_type == "*" )
205 return; 212 return;
206 } 213 }
207 } 214 }
208 215
209 plugins->push_back(plugin_info); 216 plugins->push_back(plugin_info);
210 } 217 }
211 218
219 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info,
220 std::vector<WebPluginInfo>* plugins) {
221 FilePath::StringType filename =
222 StringToLowerASCII(info.path.BaseName().value());
223
224 // Don't load the external version of NaCl when we need to use
225 // the internal one.
226 if (use_internal_nacl_) {
227 if (std::wstring::npos != filename.find(kNpGoogleNaClPlugin))
228 return false;
229 }
230 return PlatformShouldLoadPlugin(info, plugins);
231 }
232
212 bool PluginList::FindPlugin(const std::string& mime_type, 233 bool PluginList::FindPlugin(const std::string& mime_type,
213 bool allow_wildcard, 234 bool allow_wildcard,
214 WebPluginInfo* info) { 235 WebPluginInfo* info) {
215 DCHECK(mime_type == StringToLowerASCII(mime_type)); 236 DCHECK(mime_type == StringToLowerASCII(mime_type));
216 237
217 LoadPlugins(false); 238 LoadPlugins(false);
218 AutoLock lock(lock_); 239 AutoLock lock(lock_);
219 for (size_t i = 0; i < plugins_.size(); ++i) { 240 for (size_t i = 0; i < plugins_.size(); ++i) {
220 if (SupportsType(plugins_[i], mime_type, allow_wildcard)) { 241 if (SupportsType(plugins_[i], mime_type, allow_wildcard)) {
221 *info = plugins_[i]; 242 *info = plugins_[i];
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } 341 }
321 } 342 }
322 343
323 return false; 344 return false;
324 } 345 }
325 346
326 void PluginList::Shutdown() { 347 void PluginList::Shutdown() {
327 // TODO 348 // TODO
328 } 349 }
329 350
351 // static
352 void PluginList::UseInternalNaCl(PluginEntryPoints* entry_points) {
353 // We access the singleton directly, and not through Singleton(), since
354 // we don't want LoadPlugins() to be called.
355 g_singleton.Pointer()->use_internal_nacl_ = true;
356
357 const NPAPI::PluginVersionInfo nacl_plugin_info = {
358 FilePath(kNaClPluginLibraryName),
359 L"Native Client",
360 L"Statically linked NaCl",
361 L"1, 0, 0, 1",
362 L"application/x-nacl-srpc",
363 L"",
364 L"",
365 *entry_points
366 };
367
368 Singleton()->RegisterInternalPlugin(nacl_plugin_info);
369 }
370
330 } // namespace NPAPI 371 } // namespace NPAPI
OLDNEW
« no previous file with comments | « webkit/glue/plugins/plugin_list.h ('k') | webkit/glue/plugins/plugin_list_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698