Fix potential crash in CreateHBITMAPFromSkBitmap().
[chromium-blink-merge.git] / ash / screen_ash.h
blob649c3d9f5700fac3ceabec6b791e8a0f7b0e90f3
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_SCREEN_ASH_H_
6 #define ASH_SCREEN_ASH_H_
8 #include "ash/ash_export.h"
9 #include "base/compiler_specific.h"
10 #include "base/observer_list.h"
11 #include "ui/gfx/screen.h"
13 namespace gfx {
14 class Rect;
17 namespace ash {
19 // Aura implementation of gfx::Screen. Implemented here to avoid circular
20 // dependencies.
21 class ASH_EXPORT ScreenAsh : public gfx::Screen {
22 public:
23 ScreenAsh();
24 virtual ~ScreenAsh();
26 // Finds the display that contains |point| in screeen coordinates.
27 // Returns invalid display if there is no display that can satisfy
28 // the condition.
29 static gfx::Display FindDisplayContainingPoint(const gfx::Point& point);
31 // Returns the bounds for maximized windows in parent coordinates.
32 // Maximized windows trigger auto-hiding the shelf.
33 static gfx::Rect GetMaximizedWindowBoundsInParent(aura::Window* window);
35 // Returns the display bounds in parent coordinates.
36 static gfx::Rect GetDisplayBoundsInParent(aura::Window* window);
38 // Returns the display's work area bounds in parent coordinates.
39 static gfx::Rect GetDisplayWorkAreaBoundsInParent(aura::Window* window);
41 // Converts |rect| from |window|'s coordinates to the virtual screen
42 // coordinates.
43 static gfx::Rect ConvertRectToScreen(aura::Window* window,
44 const gfx::Rect& rect);
46 // Converts |rect| from virtual screen coordinates to the |window|'s
47 // coordinates.
48 static gfx::Rect ConvertRectFromScreen(aura::Window* window,
49 const gfx::Rect& rect);
51 // Returns a gfx::Display object for secondary display. Returns
52 // invalid display if there is no secondary display connected.
53 static const gfx::Display& GetSecondaryDisplay();
55 // Returns a gfx::Display object for the specified id. Returns
56 // invalid display if no such display is connected.
57 static const gfx::Display& GetDisplayForId(int64 display_id);
59 // Notifies observers of display configuration changes.
60 void NotifyBoundsChanged(const gfx::Display& display);
61 void NotifyDisplayAdded(const gfx::Display& display);
62 void NotifyDisplayRemoved(const gfx::Display& display);
64 protected:
65 // gfx::Screen overrides:
66 virtual bool IsDIPEnabled() OVERRIDE;
67 virtual gfx::Point GetCursorScreenPoint() OVERRIDE;
68 virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE;
69 virtual int GetNumDisplays() OVERRIDE;
70 virtual gfx::Display GetDisplayNearestWindow(
71 gfx::NativeView view) const OVERRIDE;
72 virtual gfx::Display GetDisplayNearestPoint(
73 const gfx::Point& point) const OVERRIDE;
74 virtual gfx::Display GetDisplayMatching(
75 const gfx::Rect& match_rect) const OVERRIDE;
76 virtual gfx::Display GetPrimaryDisplay() const OVERRIDE;
77 virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE;
78 virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE;
80 private:
81 ObserverList<gfx::DisplayObserver> observers_;
83 DISALLOW_COPY_AND_ASSIGN(ScreenAsh);
86 } // namespace ash
88 #endif // ASH_SCREEN_ASH_H_