OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/display/fake_display_snapshot.h" | 5 #include "ui/display/fake_display_snapshot.h" |
6 | 6 |
7 #include <inttypes.h> | 7 #include <inttypes.h> |
8 | 8 |
9 #include <sstream> | 9 #include <sstream> |
10 #include <utility> | 10 #include <utility> |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 int height = 0; | 90 int height = 0; |
91 std::string refresh_rate_str; | 91 std::string refresh_rate_str; |
92 | 92 |
93 // Check against regex and extract values. | 93 // Check against regex and extract values. |
94 if (!RE2::FullMatch(str, "(\\d+)x(\\d+)(?:%(\\d+\\.?\\d*))?", &width, &height, | 94 if (!RE2::FullMatch(str, "(\\d+)x(\\d+)(?:%(\\d+\\.?\\d*))?", &width, &height, |
95 &refresh_rate_str)) { | 95 &refresh_rate_str)) { |
96 LOG(ERROR) << "Invalid display mode string \"" << str << "\""; | 96 LOG(ERROR) << "Invalid display mode string \"" << str << "\""; |
97 return nullptr; | 97 return nullptr; |
98 } | 98 } |
99 | 99 |
| 100 if (width <= 0 || height <= 0) { |
| 101 LOG(ERROR) << "Resolution " << width << "x" << height << " is invalid"; |
| 102 return nullptr; |
| 103 } |
| 104 |
100 // Refresh rate is optional and will be be 60 if not specified. | 105 // Refresh rate is optional and will be be 60 if not specified. |
101 double refresh_rate = 60.0f; | 106 double refresh_rate = 60.0f; |
102 if (!refresh_rate_str.empty() && | 107 if (!refresh_rate_str.empty() && |
103 !base::StringToDouble(refresh_rate_str, &refresh_rate)) { | 108 !base::StringToDouble(refresh_rate_str, &refresh_rate)) { |
104 LOG(ERROR) << "Unable to parse display mode \"" << str << "\""; | 109 LOG(ERROR) << "Unable to parse display mode \"" << str << "\""; |
105 return nullptr; | 110 return nullptr; |
106 } | 111 } |
107 | 112 |
108 return base::MakeUnique<ui::DisplayMode>(gfx::Size(width, height), false, | 113 return base::MakeUnique<ui::DisplayMode>(gfx::Size(width, height), false, |
109 static_cast<float>(refresh_rate)); | 114 static_cast<float>(refresh_rate)); |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 " physical_size=%s, type=%s name=\"%s\" modes=(%s)", | 377 " physical_size=%s, type=%s name=\"%s\" modes=(%s)", |
373 display_id_, | 378 display_id_, |
374 current_mode_ ? current_mode_->ToString().c_str() : "nullptr", | 379 current_mode_ ? current_mode_->ToString().c_str() : "nullptr", |
375 native_mode_ ? native_mode_->ToString().c_str() : "nullptr", | 380 native_mode_ ? native_mode_->ToString().c_str() : "nullptr", |
376 origin_.ToString().c_str(), physical_size_.ToString().c_str(), | 381 origin_.ToString().c_str(), physical_size_.ToString().c_str(), |
377 DisplayConnectionTypeString(type_).c_str(), display_name_.c_str(), | 382 DisplayConnectionTypeString(type_).c_str(), display_name_.c_str(), |
378 ModeListString(modes_).c_str()); | 383 ModeListString(modes_).c_str()); |
379 } | 384 } |
380 | 385 |
381 } // namespace display | 386 } // namespace display |
OLD | NEW |