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

Unified Diff: services/ui/ws/user_display_manager.cc

Issue 2692863009: Remove usage of ws::Display in ws::UserDisplayManager. (Closed)
Patch Set: Fix mash_browser_tests. Created 3 years, 10 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/ui/ws/user_display_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/user_display_manager.cc
diff --git a/services/ui/ws/user_display_manager.cc b/services/ui/ws/user_display_manager.cc
index 344b892e5cfe7ed3c221011562289ba6a7166c65..9eb5a8558cf97a11055011c0f72cf0c7bf663551 100644
--- a/services/ui/ws/user_display_manager.cc
+++ b/services/ui/ws/user_display_manager.cc
@@ -6,10 +6,9 @@
#include <utility>
-#include "services/ui/display/screen_manager.h"
-#include "services/ui/ws/display.h"
-#include "services/ui/ws/display_manager.h"
#include "services/ui/ws/user_display_manager_delegate.h"
+#include "ui/display/display.h"
+#include "ui/display/screen.h"
#include "ui/display/types/display_constants.h"
namespace ui {
@@ -26,13 +25,18 @@ std::vector<mojom::WsDisplayPtr> CloneDisplays(
return result;
}
+int64_t GetInternalDisplayId() {
+ if (!display::Display::HasInternalDisplay())
+ return display::kInvalidDisplayId;
+
+ return display::Display::InternalDisplayId();
+}
+
} // namespace
-UserDisplayManager::UserDisplayManager(ws::DisplayManager* display_manager,
- UserDisplayManagerDelegate* delegate,
+UserDisplayManager::UserDisplayManager(UserDisplayManagerDelegate* delegate,
const UserId& user_id)
- : display_manager_(display_manager),
- delegate_(delegate),
+ : delegate_(delegate),
user_id_(user_id),
got_valid_frame_decorations_(
delegate->GetFrameDecorationsForUser(user_id, nullptr)) {}
@@ -59,12 +63,12 @@ void UserDisplayManager::AddDisplayManagerBinding(
display_manager_bindings_.AddBinding(this, std::move(request));
}
-void UserDisplayManager::OnDisplayUpdate(Display* display) {
+void UserDisplayManager::OnDisplayUpdate(const display::Display& display) {
if (!got_valid_frame_decorations_)
return;
std::vector<mojom::WsDisplayPtr> displays(1);
- displays[0] = GetWsDisplayPtr(*display);
+ displays[0] = ToWsDisplayPtr(display);
display_manager_observers_.ForAllPtrs(
[&displays](mojom::DisplayManagerObserver* observer) {
@@ -72,13 +76,13 @@ void UserDisplayManager::OnDisplayUpdate(Display* display) {
});
}
-void UserDisplayManager::OnWillDestroyDisplay(Display* display) {
+void UserDisplayManager::OnWillDestroyDisplay(int64_t display_id) {
if (!got_valid_frame_decorations_)
return;
display_manager_observers_.ForAllPtrs(
- [&display](mojom::DisplayManagerObserver* observer) {
- observer->OnDisplayRemoved(display->GetId());
+ [display_id](mojom::DisplayManagerObserver* observer) {
+ observer->OnDisplayRemoved(display_id);
});
}
@@ -110,35 +114,32 @@ void UserDisplayManager::OnObserverAdded(
CallOnDisplays(observer);
}
-mojom::WsDisplayPtr UserDisplayManager::GetWsDisplayPtr(
- const Display& display) {
+mojom::WsDisplayPtr UserDisplayManager::ToWsDisplayPtr(
+ const display::Display& display) {
mojom::WsDisplayPtr ws_display = mojom::WsDisplay::New();
- ws_display->display = display.ToDisplay();
+ ws_display->display = display;
delegate_->GetFrameDecorationsForUser(user_id_,
&ws_display->frame_decoration_values);
return ws_display;
}
std::vector<mojom::WsDisplayPtr> UserDisplayManager::GetAllDisplays() {
- const auto& displays = display_manager_->displays();
- std::vector<mojom::WsDisplayPtr> display_ptrs;
- display_ptrs.reserve(displays.size());
+ const auto& displays = display::Screen::GetScreen()->GetAllDisplays();
- // TODO(sky): need ordering!
- for (Display* display : displays) {
- display_ptrs.push_back(GetWsDisplayPtr(*display));
- }
+ std::vector<mojom::WsDisplayPtr> ws_display;
+ ws_display.reserve(displays.size());
+
+ for (const auto& display : displays)
+ ws_display.push_back(ToWsDisplayPtr(display));
- return display_ptrs;
+ return ws_display;
}
void UserDisplayManager::CallOnDisplays(
mojom::DisplayManagerObserver* observer) {
- // TODO(kylechar): Pass internal display id to clients here.
- observer->OnDisplays(
- GetAllDisplays(),
- display::ScreenManager::GetInstance()->GetPrimaryDisplayId(),
- display::kInvalidDisplayId);
+ observer->OnDisplays(GetAllDisplays(),
+ display::Screen::GetScreen()->GetPrimaryDisplay().id(),
+ GetInternalDisplayId());
}
} // namespace ws
« no previous file with comments | « services/ui/ws/user_display_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698