| Index: ui/ozone/ozone_platform.cc
|
| diff --git a/ui/ozone/ozone_platform.cc b/ui/ozone/ozone_platform.cc
|
| index e8199b2ce93f86846235f73b8459b9f650859d5f..7bfa1fd167013d8d6517fad60ca0ac6e0dfb9cd4 100644
|
| --- a/ui/ozone/ozone_platform.cc
|
| +++ b/ui/ozone/ozone_platform.cc
|
| @@ -5,6 +5,9 @@
|
| #include "base/command_line.h"
|
| #include "base/debug/trace_event.h"
|
| #include "base/logging.h"
|
| +#include "base/scoped_native_library.h"
|
| +#include "base/strings/utf_string_conversions.h"
|
| +#include "base/threading/thread_restrictions.h"
|
| #include "ui/base/cursor/ozone/cursor_factory_ozone.h"
|
| #include "ui/events/ozone/event_factory_ozone.h"
|
| #include "ui/gfx/ozone/surface_factory_ozone.h"
|
| @@ -20,11 +23,37 @@ namespace {
|
| // Helper to construct an OzonePlatform by name using the platform list.
|
| OzonePlatform* CreatePlatform(const std::string& platform_name) {
|
| // Search for a matching platform in the list.
|
| - for (int i = 0; i < kOzonePlatformCount; ++i)
|
| + for (int i = 0; i < kOzonePlatformCount; ++i) {
|
| if (platform_name == kOzonePlatforms[i].name)
|
| return kOzonePlatforms[i].constructor();
|
| -
|
| - LOG(FATAL) << "Invalid ozone platform: " << platform_name;
|
| + }
|
| +
|
| + // Try to load the module for the paltform.
|
| + base::ThreadRestrictions::ScopedAllowIO allow_io;
|
| + base::NativeLibraryLoadError load_error;
|
| + base::string16 platform_module_path =
|
| + base::GetNativeLibraryName(base::ASCIIToUTF16(platform_name));
|
| + const char kPlatformConstructor[] = "CreateOzonePlatform";
|
| + base::NativeLibrary platform_module = base::LoadNativeLibrary(
|
| + base::FilePath(base::UTF16ToASCII(platform_module_path)), &load_error);
|
| + if (!platform_module) {
|
| + LOG(FATAL) << "Failed to load library (error: " << load_error.ToString()
|
| + << ")";
|
| + } else {
|
| + OzonePlatformConstructor platform_constructor =
|
| + reinterpret_cast<OzonePlatformConstructor>(
|
| + base::GetFunctionPointerFromNativeLibrary(platform_module,
|
| + kPlatformConstructor));
|
| + if (platform_constructor) {
|
| + return platform_constructor();
|
| + } else {
|
| + LOG(FATAL) << "Module " << platform_module_path
|
| + << " does not have the constructor function ("
|
| + << kPlatformConstructor << ") to initialize the platform.";
|
| + }
|
| + }
|
| +
|
| + NOTREACHED();
|
| return NULL; // not reached
|
| }
|
|
|
|
|