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

Unified Diff: ash/display/screen_ash.cc

Issue 2294853003: Break dependency between ash::DisplayManager and ash::ScreenAsh (Closed)
Patch Set: rebased Created 4 years, 3 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 | « ash/display/screen_ash.h ('k') | ash/shell.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/display/screen_ash.cc
diff --git a/ash/display/screen_ash.cc b/ash/display/screen_ash.cc
index a0707b678bcc690c33acc11513f1d3e60ba933b6..3dbde43e10c9d7294e792b10e5cb06717f400841 100644
--- a/ash/display/screen_ash.cc
+++ b/ash/display/screen_ash.cc
@@ -24,13 +24,17 @@ namespace ash {
namespace {
+// We need to keep this in order for unittests to tell if
+// the object in display::Screen::GetScreenByType is for shutdown.
+display::Screen* screen_for_shutdown = nullptr;
+
DisplayManager* GetDisplayManager() {
return Shell::GetInstance()->display_manager();
}
class ScreenForShutdown : public display::Screen {
public:
- explicit ScreenForShutdown(ScreenAsh* screen_ash)
+ explicit ScreenForShutdown(display::Screen* screen_ash)
: display_list_(screen_ash->GetAllDisplays()),
primary_display_(screen_ash->GetPrimaryDisplay()) {}
@@ -80,22 +84,6 @@ ScreenAsh::ScreenAsh() {}
ScreenAsh::~ScreenAsh() {}
-void ScreenAsh::NotifyMetricsChanged(const display::Display& display,
- uint32_t metrics) {
- FOR_EACH_OBSERVER(display::DisplayObserver, observers_,
- OnDisplayMetricsChanged(display, metrics));
-}
-
-void ScreenAsh::NotifyDisplayAdded(const display::Display& display) {
- FOR_EACH_OBSERVER(display::DisplayObserver, observers_,
- OnDisplayAdded(display));
-}
-
-void ScreenAsh::NotifyDisplayRemoved(const display::Display& display) {
- FOR_EACH_OBSERVER(display::DisplayObserver, observers_,
- OnDisplayRemoved(display));
-}
-
gfx::Point ScreenAsh::GetCursorScreenPoint() {
return aura::Env::GetInstance()->last_mouse_location();
}
@@ -180,15 +168,31 @@ display::Display ScreenAsh::GetPrimaryDisplay() const {
}
void ScreenAsh::AddObserver(display::DisplayObserver* observer) {
- observers_.AddObserver(observer);
+ GetDisplayManager()->AddObserver(observer);
}
void ScreenAsh::RemoveObserver(display::DisplayObserver* observer) {
- observers_.RemoveObserver(observer);
+ GetDisplayManager()->RemoveObserver(observer);
+}
+
+// static
+DisplayManager* ScreenAsh::CreateDisplayManager() {
+ std::unique_ptr<ScreenAsh> screen(new ScreenAsh);
+
+ display::Screen* current = display::Screen::GetScreen();
+ // If there is no native, or the native was for shutdown,
+ // use ash's screen.
+ if (!current || current == screen_for_shutdown)
+ display::Screen::SetScreenInstance(screen.get());
+ return new DisplayManager(std::move(screen));
}
-display::Screen* ScreenAsh::CloneForShutdown() {
- return new ScreenForShutdown(this);
+// static
+void ScreenAsh::CreateScreenForShutdown() {
+ delete screen_for_shutdown;
+ // fix this up...
+ screen_for_shutdown = new ScreenForShutdown(display::Screen::GetScreen());
+ display::Screen::SetScreenInstance(screen_for_shutdown);
}
} // namespace ash
« no previous file with comments | « ash/display/screen_ash.h ('k') | ash/shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698