| Index: ui/ozone/ozone_platform.cc
|
| diff --git a/ui/ozone/ozone_platform.cc b/ui/ozone/ozone_platform.cc
|
| index 9715e13213b3e48df64341a6050ccb1bbf7eb54b..a0840058ed42764914e0f235a2ed90a1458f73f9 100644
|
| --- a/ui/ozone/ozone_platform.cc
|
| +++ b/ui/ozone/ozone_platform.cc
|
| @@ -5,9 +5,38 @@
|
| #include "base/command_line.h"
|
| #include "base/logging.h"
|
| #include "ui/ozone/ozone_platform.h"
|
| +#include "ui/ozone/ozone_platform_list.h"
|
| +#include "ui/ozone/ozone_switches.h"
|
|
|
| namespace ui {
|
|
|
| +namespace {
|
| +
|
| +// Helper to construct an OzonePlatform by name using the platform list.
|
| +OzonePlatform* CreatePlatform(const std::string& platform_name) {
|
| + // The first platform is the defualt.
|
| + if (platform_name == "default" && kOzonePlatformCount > 0)
|
| + return kOzonePlatforms[0].constructor();
|
| +
|
| + // Otherwise, search for a matching platform in the list.
|
| + for (int i = 0; i < kOzonePlatformCount; ++i)
|
| + if (platform_name == kOzonePlatforms[i].name)
|
| + return kOzonePlatforms[i].constructor();
|
| +
|
| + LOG(FATAL) << "Invalid ozone platform: " << platform_name;
|
| + return NULL; // not reached
|
| +}
|
| +
|
| +// Returns the name of the platform to use (value of --ozone-platform flag).
|
| +std::string GetRequestedPlatform() {
|
| + if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kOzonePlatform))
|
| + return "default";
|
| + return CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
|
| + switches::kOzonePlatform);
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| OzonePlatform::OzonePlatform() {}
|
|
|
| OzonePlatform::~OzonePlatform() {
|
| @@ -20,7 +49,7 @@ void OzonePlatform::Initialize() {
|
| if (instance_)
|
| return;
|
|
|
| - instance_ = CreateDefaultOzonePlatform();
|
| + instance_ = CreatePlatform(GetRequestedPlatform());
|
|
|
| // Inject ozone interfaces.
|
| gfx::SurfaceFactoryOzone::SetInstance(instance_->GetSurfaceFactoryOzone());
|
|
|