app_list: Fix unnecessary image zoomy on click.
[chromium-blink-merge.git] / base / native_library.h
blob891f35bd540a07c5049417ba37e4e2e20ded9df7
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
3 // found in the LICENSE file.
5 #ifndef BASE_NATIVE_LIBRARY_H_
6 #define BASE_NATIVE_LIBRARY_H_
8 // This file defines a cross-platform "NativeLibrary" type which represents
9 // a loadable module.
11 #include "base/base_export.h"
12 #include "build/build_config.h"
14 #if defined(OS_WIN)
15 #include <windows.h>
16 #elif defined(OS_MACOSX)
17 #import <CoreFoundation/CoreFoundation.h>
18 #endif // OS_*
20 #include "base/strings/string16.h"
22 // Macro useful for writing cross-platform function pointers.
23 #if defined(OS_WIN) && !defined(CDECL)
24 #define CDECL __cdecl
25 #else
26 #define CDECL
27 #endif
29 namespace base {
31 class FilePath;
33 #if defined(OS_WIN)
34 typedef HMODULE NativeLibrary;
35 #elif defined(OS_MACOSX)
36 enum NativeLibraryType {
37 BUNDLE,
38 DYNAMIC_LIB
40 enum NativeLibraryObjCStatus {
41 OBJC_UNKNOWN,
42 OBJC_PRESENT,
43 OBJC_NOT_PRESENT,
45 struct NativeLibraryStruct {
46 NativeLibraryType type;
47 CFBundleRefNum bundle_resource_ref;
48 NativeLibraryObjCStatus objc_status;
49 union {
50 CFBundleRef bundle;
51 void* dylib;
54 typedef NativeLibraryStruct* NativeLibrary;
55 #elif defined(OS_POSIX)
56 typedef void* NativeLibrary;
57 #endif // OS_*
59 // Loads a native library from disk. Release it with UnloadNativeLibrary when
60 // you're done. Returns NULL on failure.
61 // If |err| is not NULL, it may be filled in with an error message on
62 // error.
63 BASE_EXPORT NativeLibrary LoadNativeLibrary(const FilePath& library_path,
64 std::string* error);
66 #if defined(OS_WIN)
67 // Loads a native library from disk. Release it with UnloadNativeLibrary when
68 // you're done.
69 // This function retrieves the LoadLibrary function exported from kernel32.dll
70 // and calls it instead of directly calling the LoadLibrary function via the
71 // import table.
72 BASE_EXPORT NativeLibrary LoadNativeLibraryDynamically(
73 const FilePath& library_path);
74 #endif // OS_WIN
76 // Unloads a native library.
77 BASE_EXPORT void UnloadNativeLibrary(NativeLibrary library);
79 // Gets a function pointer from a native library.
80 BASE_EXPORT void* GetFunctionPointerFromNativeLibrary(NativeLibrary library,
81 const char* name);
83 // Returns the full platform specific name for a native library.
84 // For example:
85 // "mylib" returns "mylib.dll" on Windows, "libmylib.so" on Linux,
86 // "mylib.dylib" on Mac.
87 BASE_EXPORT string16 GetNativeLibraryName(const string16& name);
89 } // namespace base
91 #endif // BASE_NATIVE_LIBRARY_H_