| 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/wm/container_finder.h" | 7 #include "ash/common/wm/container_finder.h" |
| 8 #include "ash/common/wm/window_dimmer.h" | 8 #include "ash/common/wm/window_dimmer.h" |
| 9 #include "ash/common/wm_shell.h" | 9 #include "ash/common/wm_shell.h" |
| 10 #include "ash/common/wm_window.h" | 10 #include "ash/common/wm_window.h" |
| 11 #include "ash/common/wm_window_user_data.h" | 11 #include "ash/common/wm_window_user_data.h" |
| 12 #include "ash/public/cpp/shell_window_ids.h" | 12 #include "ash/public/cpp/shell_window_ids.h" |
| 13 #include "ash/shell.h" |
| 13 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 14 | 15 |
| 15 namespace ash { | 16 namespace ash { |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 // Opacity when it's dimming the entire screen. | 19 // Opacity when it's dimming the entire screen. |
| 19 const float kDimmingLayerOpacityForRoot = 0.4f; | 20 const float kDimmingLayerOpacityForRoot = 0.4f; |
| 20 | 21 |
| 21 // Opacity for lock screen. | 22 // Opacity for lock screen. |
| 22 const float kDimmingLayerOpacityForLockScreen = 0.5f; | 23 const float kDimmingLayerOpacityForLockScreen = 0.5f; |
| 23 | 24 |
| 24 } // namespace | 25 } // namespace |
| 25 | 26 |
| 26 ScreenDimmer::ScreenDimmer(Container container) | 27 ScreenDimmer::ScreenDimmer(Container container) |
| 27 : container_(container), | 28 : container_(container), |
| 28 is_dimming_(false), | 29 is_dimming_(false), |
| 29 at_bottom_(false), | 30 at_bottom_(false), |
| 30 window_dimmers_(base::MakeUnique<WmWindowUserData<WindowDimmer>>()) { | 31 window_dimmers_(base::MakeUnique<WmWindowUserData<WindowDimmer>>()) { |
| 31 WmShell::Get()->AddShellObserver(this); | 32 Shell::GetInstance()->AddShellObserver(this); |
| 32 } | 33 } |
| 33 | 34 |
| 34 ScreenDimmer::~ScreenDimmer() { | 35 ScreenDimmer::~ScreenDimmer() { |
| 35 // Usage in chrome results in ScreenDimmer outliving the shell. | 36 // Usage in chrome results in ScreenDimmer outliving the shell. |
| 36 if (WmShell::HasInstance()) | 37 if (Shell::HasInstance()) |
| 37 WmShell::Get()->RemoveShellObserver(this); | 38 Shell::GetInstance()->RemoveShellObserver(this); |
| 38 } | 39 } |
| 39 | 40 |
| 40 void ScreenDimmer::SetDimming(bool should_dim) { | 41 void ScreenDimmer::SetDimming(bool should_dim) { |
| 41 if (should_dim == is_dimming_) | 42 if (should_dim == is_dimming_) |
| 42 return; | 43 return; |
| 43 is_dimming_ = should_dim; | 44 is_dimming_ = should_dim; |
| 44 | 45 |
| 45 Update(should_dim); | 46 Update(should_dim); |
| 46 } | 47 } |
| 47 | 48 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 73 else | 74 else |
| 74 container->StackChildAtTop(window_dimmer->window()); | 75 container->StackChildAtTop(window_dimmer->window()); |
| 75 window_dimmer->window()->Show(); | 76 window_dimmer->window()->Show(); |
| 76 } else if (window_dimmer) { | 77 } else if (window_dimmer) { |
| 77 window_dimmers_->Set(container, nullptr); | 78 window_dimmers_->Set(container, nullptr); |
| 78 } | 79 } |
| 79 } | 80 } |
| 80 } | 81 } |
| 81 | 82 |
| 82 } // namespace ash | 83 } // namespace ash |
| OLD | NEW |