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 #ifndef ASH_COMMON_WM_SCREEN_DIMMER_H_ | 5 #ifndef ASH_COMMON_WM_SCREEN_DIMMER_H_ |
6 #define ASH_COMMON_WM_SCREEN_DIMMER_H_ | 6 #define ASH_COMMON_WM_SCREEN_DIMMER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
12 #include "ash/common/shell_observer.h" | 12 #include "ash/common/shell_observer.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 | 14 |
15 namespace aura { | |
16 class Window; | |
17 } | |
18 | |
15 namespace ash { | 19 namespace ash { |
20 | |
21 class WindowDimmer; | |
22 | |
16 namespace test { | 23 namespace test { |
17 class ScreenDimmerTest; | 24 class ScreenDimmerTest; |
18 } | 25 } |
19 | 26 |
20 class WindowDimmer; | |
21 | |
22 template <typename UserData> | |
23 class WmWindowUserData; | |
24 | |
25 // ScreenDimmer displays a partially-opaque layer above everything | 27 // ScreenDimmer displays a partially-opaque layer above everything |
26 // else in the given container window to darken the display. It shouldn't be | 28 // else in the given container window to darken the display. It shouldn't be |
27 // used for long-term brightness adjustments due to performance | 29 // used for long-term brightness adjustments due to performance |
28 // considerations -- it's only intended for cases where we want to | 30 // considerations -- it's only intended for cases where we want to |
29 // briefly dim the screen (e.g. to indicate to the user that we're | 31 // briefly dim the screen (e.g. to indicate to the user that we're |
30 // about to suspend a machine that lacks an internal backlight that | 32 // about to suspend a machine that lacks an internal backlight that |
31 // can be adjusted). | 33 // can be adjusted). |
32 class ASH_EXPORT ScreenDimmer : public ShellObserver { | 34 class ASH_EXPORT ScreenDimmer : public ShellObserver { |
33 public: | 35 public: |
34 // Indicates the container ScreenDimmer operates on. | 36 // Indicates the container ScreenDimmer operates on. |
(...skipping 11 matching lines...) Expand all Loading... | |
46 void set_at_bottom(bool at_bottom) { at_bottom_ = at_bottom; } | 48 void set_at_bottom(bool at_bottom) { at_bottom_ = at_bottom; } |
47 | 49 |
48 bool is_dimming() const { return is_dimming_; } | 50 bool is_dimming() const { return is_dimming_; } |
49 | 51 |
50 // Find a ScreenDimmer in the container, or nullptr if it does not exist. | 52 // Find a ScreenDimmer in the container, or nullptr if it does not exist. |
51 static ScreenDimmer* FindForTest(int container_id); | 53 static ScreenDimmer* FindForTest(int container_id); |
52 | 54 |
53 private: | 55 private: |
54 friend class test::ScreenDimmerTest; | 56 friend class test::ScreenDimmerTest; |
55 | 57 |
56 // Returns the WmWindows (one per display) that correspond to |container_|. | 58 // Returns the WindowDimmer for |window|. This used in tests. |
James Cook
2017/03/09 18:39:27
ForTesting, then?
sky
2017/03/09 20:39:04
This has been nuked.
| |
57 std::vector<WmWindow*> GetAllContainers(); | 59 static WindowDimmer* GetWindowDimmer(aura::Window* window); |
60 | |
61 // Returns the aura::Windows (one per display) that correspond to | |
62 // |container_|. | |
63 std::vector<aura::Window*> GetAllContainers(); | |
58 | 64 |
59 // ShellObserver: | 65 // ShellObserver: |
60 void OnRootWindowAdded(WmWindow* root_window) override; | 66 void OnRootWindowAdded(WmWindow* root_window) override; |
61 | 67 |
62 // Update the dimming state. This will also create a new DimWindow | 68 // Update the dimming state. This will also create a new DimWindow |
63 // if necessary. (Used when a new display is connected) | 69 // if necessary. (Used when a new display is connected) |
64 void Update(bool should_dim); | 70 void Update(bool should_dim); |
65 | 71 |
66 const Container container_; | 72 const Container container_; |
67 | 73 |
68 // Are we currently dimming the screen? | 74 // Are we currently dimming the screen? |
69 bool is_dimming_; | 75 bool is_dimming_; |
70 bool at_bottom_; | 76 bool at_bottom_; |
71 | 77 |
72 // Owns the WindowDimmers. | |
73 std::unique_ptr<WmWindowUserData<WindowDimmer>> window_dimmers_; | |
74 | |
75 DISALLOW_COPY_AND_ASSIGN(ScreenDimmer); | 78 DISALLOW_COPY_AND_ASSIGN(ScreenDimmer); |
76 }; | 79 }; |
77 | 80 |
78 } // namespace ash | 81 } // namespace ash |
79 | 82 |
80 #endif // ASH_COMMON_WM_SCREEN_DIMMER_H_ | 83 #endif // ASH_COMMON_WM_SCREEN_DIMMER_H_ |
OLD | NEW |