OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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/command_line.h" |
| 6 #include "base/logging.h" |
| 7 #include "ui/ozone/ozone_switches.h" |
| 8 #include "ui/ozone/platform_list.h" |
| 9 |
| 10 namespace ui { |
| 11 |
| 12 namespace { |
| 13 |
| 14 // Returns the name of the platform to use (value of --ozone-platform flag). |
| 15 std::string GetPlatformName() { |
| 16 // The first platform is the default. |
| 17 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kOzonePlatform) && |
| 18 kPlatformCount > 0) |
| 19 return kPlatformNames[0]; |
| 20 return CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 21 switches::kOzonePlatform); |
| 22 } |
| 23 |
| 24 int g_selected_platform = -1; |
| 25 |
| 26 } // namespace |
| 27 |
| 28 int GetOzonePlatformId() { |
| 29 if (g_selected_platform >= 0) |
| 30 return g_selected_platform; |
| 31 |
| 32 std::string platform_name = GetPlatformName(); |
| 33 |
| 34 // Search for a matching platform in the list. |
| 35 for (int platform_id = 0; platform_id < kPlatformCount; ++platform_id) { |
| 36 if (platform_name == kPlatformNames[platform_id]) { |
| 37 g_selected_platform = platform_id; |
| 38 return g_selected_platform; |
| 39 } |
| 40 } |
| 41 |
| 42 LOG(FATAL) << "Invalid ozone platform: " << platform_name; |
| 43 return -1; // not reached |
| 44 } |
| 45 |
| 46 const char* GetOzonePlatformName() { |
| 47 return kPlatformNames[GetOzonePlatformId()]; |
| 48 } |
| 49 |
| 50 } // namespace ui |
OLD | NEW |