Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Side by Side Diff: ui/display/manager/display_manager.cc

Issue 2523873002: Remove DisplayChangeObserver ash dependencies. (Closed)
Patch Set: Remove comment. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 122 }
123 123
124 } // namespace 124 } // namespace
125 125
126 using std::string; 126 using std::string;
127 using std::vector; 127 using std::vector;
128 128
129 // static 129 // static
130 int64_t DisplayManager::kUnifiedDisplayId = -10; 130 int64_t DisplayManager::kUnifiedDisplayId = -10;
131 131
132 DisplayManager::DisplayManager(std::unique_ptr<Screen> screen) 132 DisplayManager::DisplayManager(
133 std::unique_ptr<Screen> screen,
134 std::unique_ptr<DisplayStringProvider> string_provider)
133 : screen_(std::move(screen)), 135 : screen_(std::move(screen)),
136 string_provider_(std::move(string_provider)),
134 layout_store_(new DisplayLayoutStore), 137 layout_store_(new DisplayLayoutStore),
135 weak_ptr_factory_(this) { 138 weak_ptr_factory_(this) {
136 #if defined(OS_CHROMEOS) 139 #if defined(OS_CHROMEOS)
137 change_display_upon_host_resize_ = !base::SysInfo::IsRunningOnChromeOS(); 140 change_display_upon_host_resize_ = !base::SysInfo::IsRunningOnChromeOS();
138 unified_desktop_enabled_ = base::CommandLine::ForCurrentProcess()->HasSwitch( 141 unified_desktop_enabled_ = base::CommandLine::ForCurrentProcess()->HasSwitch(
139 ::switches::kEnableUnifiedDesktop); 142 ::switches::kEnableUnifiedDesktop);
140 #endif 143 #endif
141 } 144 }
142 145
143 DisplayManager::~DisplayManager() { 146 DisplayManager::~DisplayManager() {
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 else if (display_modes_.find(iter->id()) != display_modes_.end()) 578 else if (display_modes_.find(iter->id()) != display_modes_.end())
576 display_modes_[iter->id()] = *display_modes_iter; 579 display_modes_[iter->id()] = *display_modes_iter;
577 } 580 }
578 if (Display::HasInternalDisplay() && !internal_display_connected) { 581 if (Display::HasInternalDisplay() && !internal_display_connected) {
579 if (display_info_.find(Display::InternalDisplayId()) == 582 if (display_info_.find(Display::InternalDisplayId()) ==
580 display_info_.end()) { 583 display_info_.end()) {
581 // Create a dummy internal display if the chrome restarted 584 // Create a dummy internal display if the chrome restarted
582 // in docked mode. 585 // in docked mode.
583 ManagedDisplayInfo internal_display_info( 586 ManagedDisplayInfo internal_display_info(
584 Display::InternalDisplayId(), 587 Display::InternalDisplayId(),
585 delegate_->GetInternalDisplayNameString(), 588 string_provider_->GetInternalDisplayNameString(),
586 false /*Internal display must not have overscan */); 589 false /*Internal display must not have overscan */);
587 internal_display_info.SetBounds(gfx::Rect(0, 0, 800, 600)); 590 internal_display_info.SetBounds(gfx::Rect(0, 0, 800, 600));
588 display_info_[Display::InternalDisplayId()] = internal_display_info; 591 display_info_[Display::InternalDisplayId()] = internal_display_info;
589 } else { 592 } else {
590 // Internal display is no longer active. Reset its rotation to user 593 // Internal display is no longer active. Reset its rotation to user
591 // preference, so that it is restored when the internal display becomes 594 // preference, so that it is restored when the internal display becomes
592 // active again. 595 // active again.
593 Display::Rotation user_rotation = 596 Display::Rotation user_rotation =
594 display_info_[Display::InternalDisplayId()].GetRotation( 597 display_info_[Display::InternalDisplayId()].GetRotation(
595 Display::ROTATION_SOURCE_USER); 598 Display::ROTATION_SOURCE_USER);
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 auto iter = std::find_if(software_mirroring_display_list_.begin(), 896 auto iter = std::find_if(software_mirroring_display_list_.begin(),
894 software_mirroring_display_list_.end(), 897 software_mirroring_display_list_.end(),
895 [display_id](const Display& display) { 898 [display_id](const Display& display) {
896 return display.id() == display_id; 899 return display.id() == display_id;
897 }); 900 });
898 return iter == software_mirroring_display_list_.end() ? Display() : *iter; 901 return iter == software_mirroring_display_list_.end() ? Display() : *iter;
899 } 902 }
900 903
901 std::string DisplayManager::GetDisplayNameForId(int64_t id) { 904 std::string DisplayManager::GetDisplayNameForId(int64_t id) {
902 if (id == kInvalidDisplayId) 905 if (id == kInvalidDisplayId)
903 return delegate_->GetInternalDisplayNameString(); 906 return string_provider_->GetInternalDisplayNameString();
904 907
905 std::map<int64_t, ManagedDisplayInfo>::const_iterator iter = 908 std::map<int64_t, ManagedDisplayInfo>::const_iterator iter =
906 display_info_.find(id); 909 display_info_.find(id);
907 if (iter != display_info_.end() && !iter->second.name().empty()) 910 if (iter != display_info_.end() && !iter->second.name().empty())
908 return iter->second.name(); 911 return iter->second.name();
909 912
910 return base::StringPrintf("Display %d", static_cast<int>(id)); 913 return base::StringPrintf("Display %d", static_cast<int>(id));
911 } 914 }
912 915
913 int64_t DisplayManager::GetDisplayIdForUIScaling() const { 916 int64_t DisplayManager::GetDisplayIdForUIScaling() const {
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 } 1396 }
1394 1397
1395 const Display& DisplayManager::GetSecondaryDisplay() const { 1398 const Display& DisplayManager::GetSecondaryDisplay() const {
1396 CHECK_LE(2U, GetNumDisplays()); 1399 CHECK_LE(2U, GetNumDisplays());
1397 return GetDisplayAt(0).id() == Screen::GetScreen()->GetPrimaryDisplay().id() 1400 return GetDisplayAt(0).id() == Screen::GetScreen()->GetPrimaryDisplay().id()
1398 ? GetDisplayAt(1) 1401 ? GetDisplayAt(1)
1399 : GetDisplayAt(0); 1402 : GetDisplayAt(0);
1400 } 1403 }
1401 1404
1402 } // namespace display 1405 } // namespace display
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698