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

Side by Side Diff: ash/common/wm/screen_dimmer.cc

Issue 2359633003: Makes ScreenDimmer deal with the shell going away (Closed)
Patch Set: comment 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 unified diff | Download patch
« no previous file with comments | « no previous file | ash/wm/screen_dimmer_unittest.cc » ('j') | ash/wm/screen_dimmer_unittest.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
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
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
OLDNEW
« no previous file with comments | « no previous file | ash/wm/screen_dimmer_unittest.cc » ('j') | ash/wm/screen_dimmer_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698