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

Side by Side Diff: ash/wm/screen_dimmer.h

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 unified diff | Download patch
« no previous file with comments | « ash/wm/dim_window.cc ('k') | ash/wm/screen_dimmer.cc » ('j') | no next file with comments »
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 #ifndef ASH_WM_SCREEN_DIMMER_H_ 5 #ifndef ASH_WM_SCREEN_DIMMER_H_
6 #define ASH_WM_SCREEN_DIMMER_H_ 6 #define ASH_WM_SCREEN_DIMMER_H_
7 7
8 #include <memory>
9
8 #include "ash/ash_export.h" 10 #include "ash/ash_export.h"
9 #include "ash/common/shell_observer.h" 11 #include "ash/common/shell_observer.h"
10 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
11 #include "base/macros.h" 13 #include "base/macros.h"
12 #include "ui/aura/window_observer.h" 14 #include "ui/aura/window_observer.h"
13 15
14 namespace ui { 16 namespace ui {
15 class Layer; 17 class Layer;
16 } 18 }
17 19
18 namespace ash { 20 namespace ash {
19 class DimWindow; 21 namespace test {
22 class ScreenDimmerTest;
23 }
24
25 class WindowDimmer;
26
27 template <typename UserData>
28 class WmWindowUserData;
20 29
21 // ScreenDimmer displays a partially-opaque layer above everything 30 // ScreenDimmer displays a partially-opaque layer above everything
22 // else in the given container window to darken the display. It shouldn't be 31 // else in the given container window to darken the display. It shouldn't be
23 // used for long-term brightness adjustments due to performance 32 // used for long-term brightness adjustments due to performance
24 // considerations -- it's only intended for cases where we want to 33 // considerations -- it's only intended for cases where we want to
25 // briefly dim the screen (e.g. to indicate to the user that we're 34 // briefly dim the screen (e.g. to indicate to the user that we're
26 // about to suspend a machine that lacks an internal backlight that 35 // about to suspend a machine that lacks an internal backlight that
27 // can be adjusted). 36 // can be adjusted).
28 class ASH_EXPORT ScreenDimmer : ShellObserver { 37 class ASH_EXPORT ScreenDimmer : public ShellObserver {
29 public: 38 public:
30 // Creates a screen dimmer for the containers given by |container_id|. 39 // Creates a screen dimmer for the containers given by |container_id|.
31 // It's owned by the container in the primary root window and will be 40 // It's owned by the container in the primary root window and will be
32 // destroyed when the container is destroyed. 41 // destroyed when the container is destroyed.
33 static ScreenDimmer* GetForContainer(int container_id); 42 static ScreenDimmer* GetForContainer(int container_id);
34 43
35 // Creates a dimmer a root window level. This is used for suspend animation. 44 // Creates a dimmer a root window level. This is used for suspend animation.
36 static ScreenDimmer* GetForRoot(); 45 static ScreenDimmer* GetForRoot();
37 46
38 ~ScreenDimmer() override; 47 ~ScreenDimmer() override;
39 48
40 // Dim or undim the layers. 49 // Dim or undim the layers.
41 void SetDimming(bool should_dim); 50 void SetDimming(bool should_dim);
42 51
43 void set_at_bottom(bool at_bottom) { at_bottom_ = at_bottom; } 52 void set_at_bottom(bool at_bottom) { at_bottom_ = at_bottom; }
44 53
45 bool is_dimming() const { return is_dimming_; } 54 bool is_dimming() const { return is_dimming_; }
46 55
47 // Find a ScreenDimmer in the container, or nullptr if it does not exist. 56 // Find a ScreenDimmer in the container, or nullptr if it does not exist.
48 static ScreenDimmer* FindForTest(int container_id); 57 static ScreenDimmer* FindForTest(int container_id);
49 58
50 private: 59 private:
51 static aura::Window* FindContainer(int container_id); 60 friend class test::ScreenDimmerTest;
52 61
53 explicit ScreenDimmer(int container_id); 62 explicit ScreenDimmer(int container_id);
54 63
64 static aura::Window* FindContainer(int container_id);
65
55 // ShellObserver: 66 // ShellObserver:
56 void OnRootWindowAdded(WmWindow* root_window) override; 67 void OnRootWindowAdded(WmWindow* root_window) override;
57 68
58 // Update the dimming state. This will also create a new DimWindow 69 // Update the dimming state. This will also create a new DimWindow
59 // if necessary. (Used when a new display is connected) 70 // if necessary. (Used when a new display is connected)
60 void Update(bool should_dim); 71 void Update(bool should_dim);
61 72
62 int container_id_; 73 int container_id_;
63 float target_opacity_; 74 float target_opacity_;
64 75
65 // Are we currently dimming the screen? 76 // Are we currently dimming the screen?
66 bool is_dimming_; 77 bool is_dimming_;
67 bool at_bottom_; 78 bool at_bottom_;
68 79
80 // Owns the WindowDimmers.
81 std::unique_ptr<WmWindowUserData<WindowDimmer>> window_dimmers_;
82
69 DISALLOW_COPY_AND_ASSIGN(ScreenDimmer); 83 DISALLOW_COPY_AND_ASSIGN(ScreenDimmer);
70 }; 84 };
71 85
72 } // namespace ash 86 } // namespace ash
73 87
74 #endif // ASH_WM_SCREEN_DIMMER_H_ 88 #endif // ASH_WM_SCREEN_DIMMER_H_
OLDNEW
« no previous file with comments | « ash/wm/dim_window.cc ('k') | ash/wm/screen_dimmer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698