| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 // Copyright (c) 2009 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. | 
|  | 4 | 
|  | 5 #include "base/native_library.h" | 
|  | 6 | 
|  | 7 #include <windows.h> | 
|  | 8 | 
|  | 9 #include "base/file_path.h" | 
|  | 10 #include "base/path_service.h" | 
|  | 11 | 
|  | 12 namespace base { | 
|  | 13 | 
|  | 14 // static | 
|  | 15 NativeLibrary LoadNativeLibrary(const FilePath& library_path) { | 
|  | 16   // Switch the current directory to the library directory as the library | 
|  | 17   // may have dependencies on DLLs in this directory. | 
|  | 18   bool restore_directory = false; | 
|  | 19   std::wstring current_directory; | 
|  | 20   if (PathService::Get(base::DIR_CURRENT, ¤t_directory)) { | 
|  | 21     FilePath plugin_path = library_path.DirName(); | 
|  | 22     if (!plugin_path.value().empty()) { | 
|  | 23       PathService::SetCurrentDirectory(plugin_path.value()); | 
|  | 24       restore_directory = true; | 
|  | 25     } | 
|  | 26   } | 
|  | 27 | 
|  | 28   HMODULE module = LoadLibrary(library_path.value().c_str()); | 
|  | 29   if (restore_directory) | 
|  | 30     PathService::SetCurrentDirectory(current_directory); | 
|  | 31 | 
|  | 32   return module; | 
|  | 33 } | 
|  | 34 | 
|  | 35 // static | 
|  | 36 void UnloadNativeLibrary(NativeLibrary library) { | 
|  | 37   FreeLibrary(library); | 
|  | 38 } | 
|  | 39 | 
|  | 40 // static | 
|  | 41 void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, | 
|  | 42                                           NativeLibraryFunctionNameType name) { | 
|  | 43   return GetProcAddress(library, name); | 
|  | 44 } | 
|  | 45 | 
|  | 46 }  // namespace base | 
| OLD | NEW | 
|---|