OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/gpu_blacklist.h" | 5 #include "chrome/browser/gpu_blacklist.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 | 363 |
364 GpuFeatureFlags GpuBlacklist::DetermineGpuFeatureFlags( | 364 GpuFeatureFlags GpuBlacklist::DetermineGpuFeatureFlags( |
365 GpuBlacklist::OsType os, | 365 GpuBlacklist::OsType os, |
366 Version* os_version, | 366 Version* os_version, |
367 const GPUInfo& gpu_info) const { | 367 const GPUInfo& gpu_info) const { |
368 GpuFeatureFlags flags; | 368 GpuFeatureFlags flags; |
369 // No need to go through blacklist entries if GPUInfo isn't available. | 369 // No need to go through blacklist entries if GPUInfo isn't available. |
370 if (gpu_info.progress() == GPUInfo::kUninitialized) | 370 if (gpu_info.progress() == GPUInfo::kUninitialized) |
371 return flags; | 371 return flags; |
372 scoped_ptr<Version> driver_version( | 372 scoped_ptr<Version> driver_version( |
373 Version::GetVersionFromString(WideToASCII(gpu_info.driver_version()))); | 373 Version::GetVersionFromString(gpu_info.driver_version())); |
374 if (driver_version.get() == NULL) | 374 if (driver_version.get() == NULL) |
375 return flags; | 375 return flags; |
376 | 376 |
377 if (os == kOsAny) | 377 if (os == kOsAny) |
378 os = GetOsType(); | 378 os = GetOsType(); |
379 scoped_ptr<Version> my_os_version; | 379 scoped_ptr<Version> my_os_version; |
380 if (os_version == NULL) { | 380 if (os_version == NULL) { |
381 std::string version_string; | 381 std::string version_string; |
382 #if defined(OS_MACOSX) | 382 #if defined(OS_MACOSX) |
383 // Seems like base::SysInfo::OperatingSystemVersion() returns the wrong | 383 // Seems like base::SysInfo::OperatingSystemVersion() returns the wrong |
384 // version in MacOsx. | 384 // version in MacOsx. |
385 int32 version_major, version_minor, version_bugfix; | 385 int32 version_major, version_minor, version_bugfix; |
386 base::SysInfo::OperatingSystemVersionNumbers( | 386 base::SysInfo::OperatingSystemVersionNumbers( |
387 &version_major, &version_minor, &version_bugfix); | 387 &version_major, &version_minor, &version_bugfix); |
388 version_string = base::StringPrintf("%d.%d.%d", | 388 version_string = base::StringPrintf("%d.%d.%d", |
389 version_major, | 389 version_major, |
390 version_minor, | 390 version_minor, |
391 version_bugfix); | 391 version_bugfix); |
392 #else | 392 #else |
393 version_string = base::SysInfo::OperatingSystemVersion(); | 393 version_string = base::SysInfo::OperatingSystemVersion(); |
| 394 size_t pos = version_string.find_first_not_of("0123456789."); |
| 395 if (pos != std::string::npos) |
| 396 version_string = version_string.substr(0, pos); |
394 #endif | 397 #endif |
395 my_os_version.reset(Version::GetVersionFromString(version_string)); | 398 my_os_version.reset(Version::GetVersionFromString(version_string)); |
396 os_version = my_os_version.get(); | 399 os_version = my_os_version.get(); |
397 } | 400 } |
398 DCHECK(os_version != NULL); | 401 DCHECK(os_version != NULL); |
399 | 402 |
400 for (size_t i = 0; i < blacklist_.size(); ++i) { | 403 for (size_t i = 0; i < blacklist_.size(); ++i) { |
401 if (blacklist_[i]->Contains(os, *os_version, | 404 if (blacklist_[i]->Contains(os, *os_version, |
402 gpu_info.vendor_id(), gpu_info.device_id(), | 405 gpu_info.vendor_id(), gpu_info.device_id(), |
403 *driver_version)) { | 406 *driver_version)) { |
(...skipping 14 matching lines...) Expand all Loading... |
418 return kOsUnknown; | 421 return kOsUnknown; |
419 #endif | 422 #endif |
420 } | 423 } |
421 | 424 |
422 void GpuBlacklist::Clear() { | 425 void GpuBlacklist::Clear() { |
423 for (size_t i = 0; i < blacklist_.size(); ++i) | 426 for (size_t i = 0; i < blacklist_.size(); ++i) |
424 delete blacklist_[i]; | 427 delete blacklist_[i]; |
425 blacklist_.clear(); | 428 blacklist_.clear(); |
426 } | 429 } |
427 | 430 |
OLD | NEW |