[Cronet] Handle redirects in CronetHttpURLConnection
[chromium-blink-merge.git] / ui / gfx / screen.h
bloba05866ab2365562997fe8256be8ffe4900735487
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 UI_GFX_SCREEN_H_
6 #define UI_GFX_SCREEN_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "ui/gfx/display.h"
12 #include "ui/gfx/gfx_export.h"
13 #include "ui/gfx/native_widget_types.h"
14 #include "ui/gfx/point.h"
15 #include "ui/gfx/screen_type_delegate.h"
17 namespace gfx {
18 class DisplayObserver;
19 class Rect;
21 // A utility class for getting various info about screen size, displays,
22 // cursor position, etc.
24 // Note that this class does not represent an individual display connected to a
25 // computer -- see the Display class for that. A single Screen object exists on
26 // most operating systems regardless of the number of connected displays. On
27 // Windows 8, two Screens exist: one for Metro UI and another for the desktop.
28 class GFX_EXPORT Screen {
29 public:
30 // Retrieves the Screen that the specified NativeView belongs to. A value of
31 // NULL is treated as |SCREEN_TYPE_NATIVE|.
32 static Screen* GetScreenFor(NativeView view);
34 // Returns the SCREEN_TYPE_NATIVE Screen. This should be used with caution,
35 // as it is likely to be incorrect for code that runs on Windows.
36 static Screen* GetNativeScreen();
38 // Sets the global screen for a particular screen type. Only the _NATIVE
39 // ScreenType must be provided.
40 static void SetScreenInstance(ScreenType type, Screen* instance);
42 // Returns the global screen for a particular type. Types other than _NATIVE
43 // may be NULL.
44 static Screen* GetScreenByType(ScreenType type);
46 // Sets the global ScreenTypeDelegate. May be left unset if the platform
47 // uses only the _NATIVE ScreenType.
48 static void SetScreenTypeDelegate(ScreenTypeDelegate* delegate);
50 Screen();
51 virtual ~Screen();
53 // Returns the current absolute position of the mouse pointer.
54 virtual gfx::Point GetCursorScreenPoint() = 0;
56 // Returns the window under the cursor.
57 virtual gfx::NativeWindow GetWindowUnderCursor() = 0;
59 // Returns the window at the given screen coordinate |point|.
60 virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) = 0;
62 // Returns the number of displays.
63 // Mirrored displays are excluded; this method is intended to return the
64 // number of distinct, usable displays.
65 virtual int GetNumDisplays() const = 0;
67 // Returns the list of displays that are currently available.
68 virtual std::vector<gfx::Display> GetAllDisplays() const = 0;
70 // Returns the display nearest the specified window.
71 // If the window is NULL or the window is not rooted to a display this will
72 // return the primary display.
73 virtual gfx::Display GetDisplayNearestWindow(NativeView view) const = 0;
75 // Returns the display nearest the specified point.
76 virtual gfx::Display GetDisplayNearestPoint(
77 const gfx::Point& point) const = 0;
79 // Returns the display that most closely intersects the provided bounds.
80 virtual gfx::Display GetDisplayMatching(
81 const gfx::Rect& match_rect) const = 0;
83 // Returns the primary display.
84 virtual gfx::Display GetPrimaryDisplay() const = 0;
86 // Adds/Removes display observers.
87 virtual void AddObserver(DisplayObserver* observer) = 0;
88 virtual void RemoveObserver(DisplayObserver* observer) = 0;
90 private:
91 DISALLOW_COPY_AND_ASSIGN(Screen);
94 Screen* CreateNativeScreen();
96 } // namespace gfx
98 #endif // UI_GFX_SCREEN_H_