OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/linux_util.h" | 5 #include "base/linux_util.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 114 } |
115 | 115 |
116 // We use this static string to hold the Linux distro info. If we | 116 // We use this static string to hold the Linux distro info. If we |
117 // crash, the crash handler code will send this in the crash dump. | 117 // crash, the crash handler code will send this in the crash dump. |
118 std::string linux_distro = "Unknown"; | 118 std::string linux_distro = "Unknown"; |
119 | 119 |
120 std::string GetLinuxDistro() { | 120 std::string GetLinuxDistro() { |
121 LinuxDistroHelper* distro_state_singleton = LinuxDistroHelper::Get(); | 121 LinuxDistroHelper* distro_state_singleton = LinuxDistroHelper::Get(); |
122 LinuxDistroState state = distro_state_singleton->State(); | 122 LinuxDistroState state = distro_state_singleton->State(); |
123 if (STATE_DID_NOT_CHECK == state) { | 123 if (STATE_DID_NOT_CHECK == state) { |
| 124 #if defined(OS_CHROMEOS) |
| 125 linux_distro = "CrOS"; |
| 126 #else // if defined(OS_LINUX) |
124 // We do this check only once per process. If it fails, there's | 127 // We do this check only once per process. If it fails, there's |
125 // little reason to believe it will work if we attempt to run | 128 // little reason to believe it will work if we attempt to run |
126 // lsb_release again. | 129 // lsb_release again. |
127 std::vector<std::string> argv; | 130 std::vector<std::string> argv; |
128 argv.push_back("lsb_release"); | 131 argv.push_back("lsb_release"); |
129 argv.push_back("-d"); | 132 argv.push_back("-d"); |
130 std::string output; | 133 std::string output; |
131 base::GetAppOutput(CommandLine(argv), &output); | 134 base::GetAppOutput(CommandLine(argv), &output); |
132 if (output.length() > 0) { | 135 if (output.length() > 0) { |
133 // lsb_release -d should return: Description:<tab>Distro Info | 136 // lsb_release -d should return: Description:<tab>Distro Info |
134 static const std::string field = "Description:\t"; | 137 static const std::string field = "Description:\t"; |
135 if (output.compare(0, field.length(), field) == 0) | 138 if (output.compare(0, field.length(), field) == 0) |
136 linux_distro = output.substr(field.length()); | 139 linux_distro = output.substr(field.length()); |
137 } | 140 } |
| 141 #endif |
138 distro_state_singleton->CheckFinished(); | 142 distro_state_singleton->CheckFinished(); |
139 return linux_distro; | 143 return linux_distro; |
140 } else if (STATE_CHECK_STARTED == state) { | 144 } else if (STATE_CHECK_STARTED == state) { |
141 // If the distro check above is in progress in some other thread, we're | 145 // If the distro check above is in progress in some other thread, we're |
142 // not going to wait for the results. | 146 // not going to wait for the results. |
143 return "Unknown"; | 147 return "Unknown"; |
144 } else { | 148 } else { |
145 // In STATE_CHECK_FINISHED, no more writing to |linux_distro|. | 149 // In STATE_CHECK_FINISHED, no more writing to |linux_distro|. |
146 return linux_distro; | 150 return linux_distro; |
147 } | 151 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 return "KDE4"; | 193 return "KDE4"; |
190 } | 194 } |
191 return NULL; | 195 return NULL; |
192 } | 196 } |
193 | 197 |
194 const char* GetDesktopEnvironmentName(EnvironmentVariableGetter* env) { | 198 const char* GetDesktopEnvironmentName(EnvironmentVariableGetter* env) { |
195 return GetDesktopEnvironmentName(GetDesktopEnvironment(env)); | 199 return GetDesktopEnvironmentName(GetDesktopEnvironment(env)); |
196 } | 200 } |
197 | 201 |
198 } // namespace base | 202 } // namespace base |
OLD | NEW |