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

Side by Side Diff: webkit/glue/plugins/plugin_lib_mac.mm

Issue 87012: plugins: move NativeLibrary into base. (Closed)
Patch Set: more fixes from trybot Created 11 years, 8 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
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 "config.h" 5 #include "config.h"
6 6
7 #import <Carbon/Carbon.h> 7 #import <Carbon/Carbon.h>
8 8
9 #include "webkit/glue/plugins/plugin_lib.h" 9 #include "webkit/glue/plugins/plugin_lib.h"
10 10
11 #include "base/scoped_cftyperef.h" 11 #include "base/scoped_cftyperef.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/sys_string_conversions.h" 13 #include "base/sys_string_conversions.h"
14 #include "webkit/glue/plugins/plugin_list.h" 14 #include "webkit/glue/plugins/plugin_list.h"
15 15
16 static const short kSTRTypeDefinitionResourceID = 128; 16 static const short kSTRTypeDefinitionResourceID = 128;
17 static const short kSTRTypeDescriptionResourceID = 127; 17 static const short kSTRTypeDescriptionResourceID = 127;
18 static const short kSTRPluginDescriptionResourceID = 126; 18 static const short kSTRPluginDescriptionResourceID = 126;
19 19
20 namespace NPAPI 20 namespace NPAPI
21 { 21 {
22 22
23 /* static */
24 PluginLib::NativeLibrary PluginLib::LoadNativeLibrary(
25 const FilePath& library_path) {
26 scoped_cftyperef<CFURLRef> url(CFURLCreateFromFileSystemRepresentation(
27 kCFAllocatorDefault,
28 (const UInt8*)library_path.value().c_str(),
29 library_path.value().length(),
30 true));
31 if (!url)
32 return NULL;
33
34 return CFBundleCreate(kCFAllocatorDefault, url.get());
35 }
36
37 /* static */
38 void PluginLib::UnloadNativeLibrary(NativeLibrary library) {
39 CFRelease(library);
40 }
41
42 /* static */
43 void* PluginLib::GetFunctionPointerFromNativeLibrary(
44 NativeLibrary library,
45 NativeLibraryFunctionNameType name) {
46 return CFBundleGetFunctionPointerForName(library, name);
47 }
48
49 namespace { 23 namespace {
50 24
51 NSDictionary* GetMIMETypes(CFBundleRef bundle) { 25 NSDictionary* GetMIMETypes(CFBundleRef bundle) {
52 NSString* mime_filename = 26 NSString* mime_filename =
53 (NSString*)CFBundleGetValueForInfoDictionaryKey(bundle, 27 (NSString*)CFBundleGetValueForInfoDictionaryKey(bundle,
54 CFSTR("WebPluginMIMETypesFilename")); 28 CFSTR("WebPluginMIMETypesFilename"));
55 29
56 if (mime_filename) { 30 if (mime_filename) {
57 31
58 // get the file 32 // get the file
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 // (1) <<type0description>> 289 // (1) <<type0description>>
316 // (2) <<type1description>> 290 // (2) <<type1description>>
317 // (...) 291 // (...)
318 // (n+1) <<typendescription>> 292 // (n+1) <<typendescription>>
319 // STR# 126 293 // STR# 126
320 // (1) <<plugindescription>> 294 // (1) <<plugindescription>>
321 // (2) <<pluginname>> 295 // (2) <<pluginname>>
322 // 296 //
323 // Strictly speaking, only STR# 128 is required. 297 // Strictly speaking, only STR# 128 is required.
324 298
325 scoped_cftyperef<CFBundleRef> bundle(LoadNativeLibrary(filename)); 299 scoped_cftyperef<CFBundleRef> bundle(base::LoadNativeLibrary(filename));
326 if (!bundle) 300 if (!bundle)
327 return false; 301 return false;
328 302
329 // preflight 303 // preflight
330 304
331 OSType type = 0; 305 OSType type = 0;
332 CFBundleGetPackageInfo(bundle.get(), &type, NULL); 306 CFBundleGetPackageInfo(bundle.get(), &type, NULL);
333 if (type != FOUR_CHAR_CODE('BRPL')) 307 if (type != FOUR_CHAR_CODE('BRPL'))
334 return false; 308 return false;
335 309
336 CFErrorRef error; 310 CFErrorRef error;
337 Boolean would_load = CFBundlePreflightExecutable(bundle.get(), &error); 311 Boolean would_load = CFBundlePreflightExecutable(bundle.get(), &error);
338 if (!would_load) 312 if (!would_load)
339 return false; 313 return false;
340 314
341 // get the info 315 // get the info
342 316
343 if (ReadPlistPluginInfo(filename, bundle.get(), info)) 317 if (ReadPlistPluginInfo(filename, bundle.get(), info))
344 return true; 318 return true;
345 319
346 if (ReadSTRPluginInfo(filename, bundle.get(), info)) 320 if (ReadSTRPluginInfo(filename, bundle.get(), info))
347 return true; 321 return true;
348 322
349 // ... or not 323 // ... or not
350 324
351 return false; 325 return false;
352 } 326 }
353 327
354 } // namespace NPAPI 328 } // namespace NPAPI
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698