Added llvm into exceptions as we can't add README.chromium into 3rd party repository
[chromium-blink-merge.git] / ash / wm / screen_dimmer.h
bloba0b3fa57b8d2d67c15a2cf0c8ab933f427901c3d
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
3 // found in the LICENSE file.
5 #ifndef ASH_WM_SCREEN_DIMMER_H_
6 #define ASH_WM_SCREEN_DIMMER_H_
8 #include "ash/ash_export.h"
9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "ui/aura/window_observer.h"
14 namespace ui {
15 class Layer;
18 namespace ash {
20 // ScreenDimmer displays a partially-opaque layer above everything
21 // else in the root window to darken the display. It shouldn't be used
22 // for long-term brightness adjustments due to performance
23 // considerations -- it's only intended for cases where we want to
24 // briefly dim the screen (e.g. to indicate to the user that we're
25 // about to suspend a machine that lacks an internal backlight that
26 // can be adjusted).
27 class ASH_EXPORT ScreenDimmer : public aura::WindowObserver {
28 public:
29 class TestApi {
30 public:
31 explicit TestApi(ScreenDimmer* dimmer) : dimmer_(dimmer) {}
33 ui::Layer* layer() { return dimmer_->dimming_layer_.get(); }
35 private:
36 ScreenDimmer* dimmer_; // not owned
38 DISALLOW_COPY_AND_ASSIGN(TestApi);
41 explicit ScreenDimmer(aura::Window* root_window);
42 ~ScreenDimmer() override;
44 // Dim or undim the root window.
45 void SetDimming(bool should_dim);
47 // aura::WindowObserver overrides:
48 void OnWindowBoundsChanged(aura::Window* root_window,
49 const gfx::Rect& old_bounds,
50 const gfx::Rect& new_bounds) override;
52 private:
53 friend class TestApi;
55 aura::Window* root_window_;
57 // Partially-opaque layer that's stacked above all of the root window's
58 // children and used to dim the screen. NULL until the first time we dim.
59 scoped_ptr<ui::Layer> dimming_layer_;
61 // Are we currently dimming the screen?
62 bool currently_dimming_;
64 DISALLOW_COPY_AND_ASSIGN(ScreenDimmer);
67 } // namespace ash
69 #endif // ASH_WM_SCREEN_DIMMER_H_