| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/manager/display_manager.h" | 5 #include "ui/display/manager/display_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <utility> | 13 #include <utility> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/auto_reset.h" | 16 #include "base/auto_reset.h" |
| 17 #include "base/bind.h" | 17 #include "base/bind.h" |
| 18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
| 19 #include "base/logging.h" | 19 #include "base/logging.h" |
| 20 #include "base/memory/ptr_util.h" | 20 #include "base/memory/ptr_util.h" |
| 21 #include "base/metrics/histogram.h" | 21 #include "base/metrics/histogram.h" |
| 22 #include "base/run_loop.h" | 22 #include "base/run_loop.h" |
| 23 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
| 24 #include "base/strings/string_split.h" | 24 #include "base/strings/string_split.h" |
| 25 #include "base/strings/stringprintf.h" | 25 #include "base/strings/stringprintf.h" |
| 26 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
| 27 #include "base/threading/thread_task_runner_handle.h" | 27 #include "base/threading/thread_task_runner_handle.h" |
| 28 #include "ui/base/l10n/l10n_util.h" |
| 28 #include "ui/display/display.h" | 29 #include "ui/display/display.h" |
| 29 #include "ui/display/display_observer.h" | 30 #include "ui/display/display_observer.h" |
| 30 #include "ui/display/display_switches.h" | 31 #include "ui/display/display_switches.h" |
| 31 #include "ui/display/manager/display_layout_store.h" | 32 #include "ui/display/manager/display_layout_store.h" |
| 32 #include "ui/display/manager/display_manager_utilities.h" | 33 #include "ui/display/manager/display_manager_utilities.h" |
| 33 #include "ui/display/manager/managed_display_info.h" | 34 #include "ui/display/manager/managed_display_info.h" |
| 34 #include "ui/display/screen.h" | 35 #include "ui/display/screen.h" |
| 35 #include "ui/gfx/font_render_params.h" | 36 #include "ui/gfx/font_render_params.h" |
| 36 #include "ui/gfx/geometry/rect.h" | 37 #include "ui/gfx/geometry/rect.h" |
| 37 #include "ui/gfx/geometry/size_conversions.h" | 38 #include "ui/gfx/geometry/size_conversions.h" |
| 39 #include "ui/strings/grit/ui_strings.h" |
| 38 | 40 |
| 39 #if defined(OS_CHROMEOS) | 41 #if defined(OS_CHROMEOS) |
| 40 #include "base/sys_info.h" | 42 #include "base/sys_info.h" |
| 41 #endif | 43 #endif |
| 42 | 44 |
| 43 #if defined(OS_WIN) | 45 #if defined(OS_WIN) |
| 44 #include "base/win/windows_version.h" | 46 #include "base/win/windows_version.h" |
| 45 #endif | 47 #endif |
| 46 | 48 |
| 47 namespace display { | 49 namespace display { |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 else if (display_modes_.find(iter->id()) != display_modes_.end()) | 577 else if (display_modes_.find(iter->id()) != display_modes_.end()) |
| 576 display_modes_[iter->id()] = *display_modes_iter; | 578 display_modes_[iter->id()] = *display_modes_iter; |
| 577 } | 579 } |
| 578 if (Display::HasInternalDisplay() && !internal_display_connected) { | 580 if (Display::HasInternalDisplay() && !internal_display_connected) { |
| 579 if (display_info_.find(Display::InternalDisplayId()) == | 581 if (display_info_.find(Display::InternalDisplayId()) == |
| 580 display_info_.end()) { | 582 display_info_.end()) { |
| 581 // Create a dummy internal display if the chrome restarted | 583 // Create a dummy internal display if the chrome restarted |
| 582 // in docked mode. | 584 // in docked mode. |
| 583 ManagedDisplayInfo internal_display_info( | 585 ManagedDisplayInfo internal_display_info( |
| 584 Display::InternalDisplayId(), | 586 Display::InternalDisplayId(), |
| 585 delegate_->GetInternalDisplayNameString(), | 587 l10n_util::GetStringUTF8(IDS_DISPLAY_NAME_INTERNAL), |
| 586 false /*Internal display must not have overscan */); | 588 false /*Internal display must not have overscan */); |
| 587 internal_display_info.SetBounds(gfx::Rect(0, 0, 800, 600)); | 589 internal_display_info.SetBounds(gfx::Rect(0, 0, 800, 600)); |
| 588 display_info_[Display::InternalDisplayId()] = internal_display_info; | 590 display_info_[Display::InternalDisplayId()] = internal_display_info; |
| 589 } else { | 591 } else { |
| 590 // Internal display is no longer active. Reset its rotation to user | 592 // Internal display is no longer active. Reset its rotation to user |
| 591 // preference, so that it is restored when the internal display becomes | 593 // preference, so that it is restored when the internal display becomes |
| 592 // active again. | 594 // active again. |
| 593 Display::Rotation user_rotation = | 595 Display::Rotation user_rotation = |
| 594 display_info_[Display::InternalDisplayId()].GetRotation( | 596 display_info_[Display::InternalDisplayId()].GetRotation( |
| 595 Display::ROTATION_SOURCE_USER); | 597 Display::ROTATION_SOURCE_USER); |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 auto iter = std::find_if(software_mirroring_display_list_.begin(), | 895 auto iter = std::find_if(software_mirroring_display_list_.begin(), |
| 894 software_mirroring_display_list_.end(), | 896 software_mirroring_display_list_.end(), |
| 895 [display_id](const Display& display) { | 897 [display_id](const Display& display) { |
| 896 return display.id() == display_id; | 898 return display.id() == display_id; |
| 897 }); | 899 }); |
| 898 return iter == software_mirroring_display_list_.end() ? Display() : *iter; | 900 return iter == software_mirroring_display_list_.end() ? Display() : *iter; |
| 899 } | 901 } |
| 900 | 902 |
| 901 std::string DisplayManager::GetDisplayNameForId(int64_t id) { | 903 std::string DisplayManager::GetDisplayNameForId(int64_t id) { |
| 902 if (id == kInvalidDisplayId) | 904 if (id == kInvalidDisplayId) |
| 903 return delegate_->GetInternalDisplayNameString(); | 905 return l10n_util::GetStringUTF8(IDS_DISPLAY_NAME_UNKNOWN); |
| 904 | 906 |
| 905 std::map<int64_t, ManagedDisplayInfo>::const_iterator iter = | 907 std::map<int64_t, ManagedDisplayInfo>::const_iterator iter = |
| 906 display_info_.find(id); | 908 display_info_.find(id); |
| 907 if (iter != display_info_.end() && !iter->second.name().empty()) | 909 if (iter != display_info_.end() && !iter->second.name().empty()) |
| 908 return iter->second.name(); | 910 return iter->second.name(); |
| 909 | 911 |
| 910 return base::StringPrintf("Display %d", static_cast<int>(id)); | 912 return base::StringPrintf("Display %d", static_cast<int>(id)); |
| 911 } | 913 } |
| 912 | 914 |
| 913 int64_t DisplayManager::GetDisplayIdForUIScaling() const { | 915 int64_t DisplayManager::GetDisplayIdForUIScaling() const { |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1393 } | 1395 } |
| 1394 | 1396 |
| 1395 const Display& DisplayManager::GetSecondaryDisplay() const { | 1397 const Display& DisplayManager::GetSecondaryDisplay() const { |
| 1396 CHECK_LE(2U, GetNumDisplays()); | 1398 CHECK_LE(2U, GetNumDisplays()); |
| 1397 return GetDisplayAt(0).id() == Screen::GetScreen()->GetPrimaryDisplay().id() | 1399 return GetDisplayAt(0).id() == Screen::GetScreen()->GetPrimaryDisplay().id() |
| 1398 ? GetDisplayAt(1) | 1400 ? GetDisplayAt(1) |
| 1399 : GetDisplayAt(0); | 1401 : GetDisplayAt(0); |
| 1400 } | 1402 } |
| 1401 | 1403 |
| 1402 } // namespace display | 1404 } // namespace display |
| OLD | NEW |