OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "services/ui/display/screen_manager_stub_internal.h" | 5 #include "services/ui/display/screen_manager_stub_internal.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
13 #include "services/service_manager/public/cpp/interface_registry.h" | 13 #include "services/service_manager/public/cpp/binder_registry.h" |
14 #include "services/ui/display/viewport_metrics.h" | 14 #include "services/ui/display/viewport_metrics.h" |
15 #include "ui/gfx/geometry/dip_util.h" | 15 #include "ui/gfx/geometry/dip_util.h" |
16 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
17 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
18 | 18 |
19 namespace display { | 19 namespace display { |
20 namespace { | 20 namespace { |
21 | 21 |
22 constexpr gfx::Size kDisplayPixelSize(1024, 768); | 22 constexpr gfx::Size kDisplayPixelSize(1024, 768); |
23 | 23 |
(...skipping 29 matching lines...) Expand all Loading... |
53 void ScreenManagerStubInternal::FixedSizeScreenConfiguration() { | 53 void ScreenManagerStubInternal::FixedSizeScreenConfiguration() { |
54 ViewportMetrics metrics; | 54 ViewportMetrics metrics; |
55 metrics.bounds_in_pixels = gfx::Rect(kDisplayPixelSize); | 55 metrics.bounds_in_pixels = gfx::Rect(kDisplayPixelSize); |
56 metrics.device_scale_factor = display_.device_scale_factor(); | 56 metrics.device_scale_factor = display_.device_scale_factor(); |
57 metrics.ui_scale_factor = 1.f; | 57 metrics.ui_scale_factor = 1.f; |
58 | 58 |
59 delegate_->OnDisplayAdded(display_, metrics); | 59 delegate_->OnDisplayAdded(display_, metrics); |
60 } | 60 } |
61 | 61 |
62 void ScreenManagerStubInternal::AddInterfaces( | 62 void ScreenManagerStubInternal::AddInterfaces( |
63 service_manager::InterfaceRegistry* registry) {} | 63 service_manager::BinderRegistry* registry) {} |
64 | 64 |
65 void ScreenManagerStubInternal::Init(ScreenManagerDelegate* delegate) { | 65 void ScreenManagerStubInternal::Init(ScreenManagerDelegate* delegate) { |
66 DCHECK(delegate); | 66 DCHECK(delegate); |
67 delegate_ = delegate; | 67 delegate_ = delegate; |
68 display_ = DefaultDisplay(); | 68 display_ = DefaultDisplay(); |
69 base::ThreadTaskRunnerHandle::Get()->PostTask( | 69 base::ThreadTaskRunnerHandle::Get()->PostTask( |
70 FROM_HERE, | 70 FROM_HERE, |
71 base::Bind(&ScreenManagerStubInternal::FixedSizeScreenConfiguration, | 71 base::Bind(&ScreenManagerStubInternal::FixedSizeScreenConfiguration, |
72 weak_ptr_factory_.GetWeakPtr())); | 72 weak_ptr_factory_.GetWeakPtr())); |
73 } | 73 } |
74 | 74 |
75 void ScreenManagerStubInternal::RequestCloseDisplay(int64_t display_id) { | 75 void ScreenManagerStubInternal::RequestCloseDisplay(int64_t display_id) { |
76 if (display_id == display_.id()) { | 76 if (display_id == display_.id()) { |
77 base::ThreadTaskRunnerHandle::Get()->PostTask( | 77 base::ThreadTaskRunnerHandle::Get()->PostTask( |
78 FROM_HERE, base::Bind(&ScreenManagerDelegate::OnDisplayRemoved, | 78 FROM_HERE, base::Bind(&ScreenManagerDelegate::OnDisplayRemoved, |
79 base::Unretained(delegate_), display_id)); | 79 base::Unretained(delegate_), display_id)); |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 } // namespace display | 83 } // namespace display |
OLD | NEW |