Chromium Code Reviews| Index: ui/base/ozone/ozone_platform.cc |
| diff --git a/ui/base/ozone/ozone_platform.cc b/ui/base/ozone/ozone_platform.cc |
| index ea638c24719b2ee256cbe9829feeb3e28b6f4fbb..28f24cd0b8fd45f3339b8bd19f64a6dd5cec10a2 100644 |
| --- a/ui/base/ozone/ozone_platform.cc |
| +++ b/ui/base/ozone/ozone_platform.cc |
| @@ -5,9 +5,31 @@ |
| #include "base/command_line.h" |
| #include "base/logging.h" |
| #include "ui/base/ozone/ozone_platform.h" |
| +#include "ui/base/ozone/ozone_platform_list.h" |
| +#include "ui/base/ozone/ozone_switches.h" |
| namespace ui { |
| +namespace { |
| + |
| +OzonePlatform* CreatePlatform(const std::string& platform_name) { |
| + for (int i = 0; i < kOzonePlatformCount; ++i) |
|
rjkroege
2013/10/28 16:02:15
default maps to the first element in the list righ
spang
2013/10/28 16:27:39
Done.
|
| + if (platform_name == kOzonePlatforms[i].name || platform_name == "default") |
| + return kOzonePlatforms[i].constructor(); |
| + |
| + LOG(FATAL) << "Invalid ozone platform: " << platform_name; |
| + return NULL; // not reached |
| +} |
| + |
| +std::string GetRequestedPlatform() { |
|
rjkroege
2013/10/28 16:02:15
maybe add a comment here saying "returns the name
spang
2013/10/28 16:27:39
Done.
|
| + if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kOzonePlatform)) |
| + return "default"; |
| + return CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| + switches::kOzonePlatform); |
| +} |
| + |
| +} // namespace |
| + |
| OzonePlatform::OzonePlatform() {} |
| OzonePlatform::~OzonePlatform() { |
| @@ -17,7 +39,7 @@ OzonePlatform::~OzonePlatform() { |
| // static |
| OzonePlatform* OzonePlatform::Create() { |
| - OzonePlatform* platform = CreateDefaultOzonePlatform(); |
| + OzonePlatform* platform = CreatePlatform(GetRequestedPlatform()); |
| gfx::SurfaceFactoryOzone::SetInstance(platform->GetSurfaceFactoryOzone()); |
| ui::EventFactoryOzone::SetInstance(platform->GetEventFactoryOzone()); |