Chromium Code Reviews| 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 "ash/common/wm/screen_dimmer.h" | 5 #include "ash/common/wm/screen_dimmer.h" |
| 6 | 6 |
| 7 #include "ash/common/shell_window_ids.h" | 7 #include "ash/common/shell_window_ids.h" |
| 8 #include "ash/common/wm/container_finder.h" | 8 #include "ash/common/wm/container_finder.h" |
| 9 #include "ash/common/wm/window_dimmer.h" | 9 #include "ash/common/wm/window_dimmer.h" |
| 10 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 | 25 |
| 26 ScreenDimmer::ScreenDimmer(Container container) | 26 ScreenDimmer::ScreenDimmer(Container container) |
| 27 : container_(container), | 27 : container_(container), |
| 28 is_dimming_(false), | 28 is_dimming_(false), |
| 29 at_bottom_(false), | 29 at_bottom_(false), |
| 30 window_dimmers_(base::MakeUnique<WmWindowUserData<WindowDimmer>>()) { | 30 window_dimmers_(base::MakeUnique<WmWindowUserData<WindowDimmer>>()) { |
| 31 WmShell::Get()->AddShellObserver(this); | 31 WmShell::Get()->AddShellObserver(this); |
| 32 } | 32 } |
| 33 | 33 |
| 34 ScreenDimmer::~ScreenDimmer() { | 34 ScreenDimmer::~ScreenDimmer() { |
| 35 WmShell::Get()->RemoveShellObserver(this); | 35 // Usage in chrome results in ScreenDimmer outliving the shell. |
| 36 if (WmShell::HasInstance()) | |
|
James Cook
2016/09/20 23:26:18
Does this mean we'll never clean up this observer
sky
2016/09/20 23:33:05
That is correct. The ObserverList does not enforce
| |
| 37 WmShell::Get()->RemoveShellObserver(this); | |
| 36 } | 38 } |
| 37 | 39 |
| 38 void ScreenDimmer::SetDimming(bool should_dim) { | 40 void ScreenDimmer::SetDimming(bool should_dim) { |
| 39 if (should_dim == is_dimming_) | 41 if (should_dim == is_dimming_) |
| 40 return; | 42 return; |
| 41 is_dimming_ = should_dim; | 43 is_dimming_ = should_dim; |
| 42 | 44 |
| 43 Update(should_dim); | 45 Update(should_dim); |
| 44 } | 46 } |
| 45 | 47 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 71 else | 73 else |
| 72 container->StackChildAtTop(window_dimmer->window()); | 74 container->StackChildAtTop(window_dimmer->window()); |
| 73 window_dimmer->window()->Show(); | 75 window_dimmer->window()->Show(); |
| 74 } else if (window_dimmer) { | 76 } else if (window_dimmer) { |
| 75 window_dimmers_->Set(container, nullptr); | 77 window_dimmers_->Set(container, nullptr); |
| 76 } | 78 } |
| 77 } | 79 } |
| 78 } | 80 } |
| 79 | 81 |
| 80 } // namespace ash | 82 } // namespace ash |
| OLD | NEW |