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

Unified Diff: ash/wm/screen_dimmer.cc

Issue 2320273002: Refactors DimWindow and moves to ash/common (Closed)
Patch Set: feedback and member initializer ordering 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/wm/screen_dimmer.h ('k') | ash/wm/screen_dimmer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/screen_dimmer.cc
diff --git a/ash/wm/screen_dimmer.cc b/ash/wm/screen_dimmer.cc
index c0bb3d84129f196706530b791342349b78474b88..e232bea33fd8a825a67dc67d00a4631d7448786e 100644
--- a/ash/wm/screen_dimmer.cc
+++ b/ash/wm/screen_dimmer.cc
@@ -4,9 +4,11 @@
#include "ash/wm/screen_dimmer.h"
+#include "ash/aura/wm_window_aura.h"
+#include "ash/common/wm/window_dimmer.h"
#include "ash/common/wm_shell.h"
+#include "ash/common/wm_window_user_data.h"
#include "ash/shell.h"
-#include "ash/wm/dim_window.h"
#include "base/time/time.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_property.h"
@@ -57,7 +59,8 @@ ScreenDimmer::ScreenDimmer(int container_id)
: container_id_(container_id),
target_opacity_(0.5f),
is_dimming_(false),
- at_bottom_(false) {
+ at_bottom_(false),
+ window_dimmers_(base::MakeUnique<WmWindowUserData<WindowDimmer>>()) {
WmShell::Get()->AddShellObserver(this);
}
@@ -90,23 +93,23 @@ void ScreenDimmer::OnRootWindowAdded(WmWindow* root_window) {
}
void ScreenDimmer::Update(bool should_dim) {
- for (aura::Window* container : GetAllContainers(container_id_)) {
- DimWindow* dim = DimWindow::Get(container);
+ for (aura::Window* aura_container : GetAllContainers(container_id_)) {
+ WmWindow* container = WmWindowAura::Get(aura_container);
+ WindowDimmer* window_dimmer = window_dimmers_->Get(container);
if (should_dim) {
- if (!dim) {
- dim = new DimWindow(container);
- dim->SetDimOpacity(target_opacity_);
+ if (!window_dimmer) {
+ window_dimmers_->Set(container,
+ base::MakeUnique<WindowDimmer>(container));
+ window_dimmer = window_dimmers_->Get(container);
+ window_dimmer->SetDimOpacity(target_opacity_);
}
if (at_bottom_)
- dim->parent()->StackChildAtBottom(dim);
+ container->StackChildAtBottom(window_dimmer->window());
else
- dim->parent()->StackChildAtTop(dim);
- dim->Show();
- } else {
- if (dim) {
- dim->Hide();
- delete dim;
- }
+ container->StackChildAtTop(window_dimmer->window());
+ window_dimmer->window()->Show();
+ } else if (window_dimmer) {
+ window_dimmers_->Set(container, nullptr);
}
}
}
« no previous file with comments | « ash/wm/screen_dimmer.h ('k') | ash/wm/screen_dimmer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698