Add a basic settings page with a Polymer paper element which loads at chrome://md...
[chromium-blink-merge.git] / ui / gfx / screen_android.cc
blob1f2f5f8bfd10a6495af16f6abfbb75c5eef9c3fc
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 #include "ui/gfx/screen.h"
7 #include "base/logging.h"
8 #include "ui/gfx/android/device_display_info.h"
9 #include "ui/gfx/display.h"
10 #include "ui/gfx/geometry/size_conversions.h"
12 namespace gfx {
14 class ScreenAndroid : public Screen {
15 public:
16 ScreenAndroid() {}
18 virtual gfx::Point GetCursorScreenPoint() override { return gfx::Point(); }
20 virtual gfx::NativeWindow GetWindowUnderCursor() override {
21 NOTIMPLEMENTED();
22 return NULL;
25 virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point)
26 override {
27 NOTIMPLEMENTED();
28 return NULL;
31 virtual gfx::Display GetPrimaryDisplay() const override {
32 gfx::DeviceDisplayInfo device_info;
33 const float device_scale_factor = device_info.GetDIPScale();
34 // Note: GetPhysicalDisplayWidth/Height() does not subtract window
35 // decorations etc. Use it instead of GetDisplayWidth/Height() when
36 // available.
37 const gfx::Rect bounds_in_pixels =
38 gfx::Rect(device_info.GetPhysicalDisplayWidth()
39 ? device_info.GetPhysicalDisplayWidth()
40 : device_info.GetDisplayWidth(),
41 device_info.GetPhysicalDisplayHeight()
42 ? device_info.GetPhysicalDisplayHeight()
43 : device_info.GetDisplayHeight());
44 const gfx::Rect bounds_in_dip =
45 gfx::Rect(gfx::ToCeiledSize(gfx::ScaleSize(
46 bounds_in_pixels.size(), 1.0f / device_scale_factor)));
47 gfx::Display display(0, bounds_in_dip);
48 if (!gfx::Display::HasForceDeviceScaleFactor())
49 display.set_device_scale_factor(device_scale_factor);
50 display.SetRotationAsDegree(device_info.GetRotationDegrees());
51 return display;
54 virtual gfx::Display GetDisplayNearestWindow(
55 gfx::NativeView view) const override {
56 return GetPrimaryDisplay();
59 virtual gfx::Display GetDisplayNearestPoint(
60 const gfx::Point& point) const override {
61 return GetPrimaryDisplay();
64 virtual int GetNumDisplays() const override { return 1; }
66 virtual std::vector<gfx::Display> GetAllDisplays() const override {
67 return std::vector<gfx::Display>(1, GetPrimaryDisplay());
70 virtual gfx::Display GetDisplayMatching(
71 const gfx::Rect& match_rect) const override {
72 return GetPrimaryDisplay();
75 virtual void AddObserver(DisplayObserver* observer) override {
76 // no display change on Android.
79 virtual void RemoveObserver(DisplayObserver* observer) override {
80 // no display change on Android.
83 private:
84 DISALLOW_COPY_AND_ASSIGN(ScreenAndroid);
87 Screen* CreateNativeScreen() {
88 return new ScreenAndroid;
91 } // namespace gfx