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/platform_screen_stub.h" | 5 #include "services/ui/display/screen_manager_stub.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/interface_registry.h" |
14 #include "ui/display/display.h" | 14 #include "ui/display/display.h" |
15 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
(...skipping 16 matching lines...) Expand all Loading... |
32 | 32 |
33 metrics.bounds = gfx::Rect(scaled_size); | 33 metrics.bounds = gfx::Rect(scaled_size); |
34 metrics.work_area = gfx::Rect(scaled_size); | 34 metrics.work_area = gfx::Rect(scaled_size); |
35 | 35 |
36 return metrics; | 36 return metrics; |
37 } | 37 } |
38 | 38 |
39 } // namespace | 39 } // namespace |
40 | 40 |
41 // static | 41 // static |
42 std::unique_ptr<PlatformScreen> PlatformScreen::Create() { | 42 std::unique_ptr<ScreenManager> ScreenManager::Create() { |
43 return base::MakeUnique<PlatformScreenStub>(); | 43 return base::MakeUnique<ScreenManagerStub>(); |
44 } | 44 } |
45 | 45 |
46 PlatformScreenStub::PlatformScreenStub() | 46 ScreenManagerStub::ScreenManagerStub() : weak_ptr_factory_(this) {} |
47 : weak_ptr_factory_(this) {} | |
48 | 47 |
49 PlatformScreenStub::~PlatformScreenStub() {} | 48 ScreenManagerStub::~ScreenManagerStub() {} |
50 | 49 |
51 void PlatformScreenStub::FixedSizeScreenConfiguration() { | 50 void ScreenManagerStub::FixedSizeScreenConfiguration() { |
52 delegate_->OnDisplayAdded(display_id_, display_metrics_); | 51 delegate_->OnDisplayAdded(display_id_, display_metrics_); |
53 } | 52 } |
54 | 53 |
55 void PlatformScreenStub::AddInterfaces( | 54 void ScreenManagerStub::AddInterfaces( |
56 service_manager::InterfaceRegistry* registry) {} | 55 service_manager::InterfaceRegistry* registry) {} |
57 | 56 |
58 void PlatformScreenStub::Init(PlatformScreenDelegate* delegate) { | 57 void ScreenManagerStub::Init(ScreenManagerDelegate* delegate) { |
59 DCHECK(delegate); | 58 DCHECK(delegate); |
60 delegate_ = delegate; | 59 delegate_ = delegate; |
61 display_metrics_ = DefaultViewportMetrics(); | 60 display_metrics_ = DefaultViewportMetrics(); |
62 base::ThreadTaskRunnerHandle::Get()->PostTask( | 61 base::ThreadTaskRunnerHandle::Get()->PostTask( |
63 FROM_HERE, base::Bind(&PlatformScreenStub::FixedSizeScreenConfiguration, | 62 FROM_HERE, base::Bind(&ScreenManagerStub::FixedSizeScreenConfiguration, |
64 weak_ptr_factory_.GetWeakPtr())); | 63 weak_ptr_factory_.GetWeakPtr())); |
65 } | 64 } |
66 | 65 |
67 void PlatformScreenStub::RequestCloseDisplay(int64_t display_id) { | 66 void ScreenManagerStub::RequestCloseDisplay(int64_t display_id) { |
68 if (display_id == display_id_) { | 67 if (display_id == display_id_) { |
69 base::ThreadTaskRunnerHandle::Get()->PostTask( | 68 base::ThreadTaskRunnerHandle::Get()->PostTask( |
70 FROM_HERE, base::Bind(&PlatformScreenDelegate::OnDisplayRemoved, | 69 FROM_HERE, base::Bind(&ScreenManagerDelegate::OnDisplayRemoved, |
71 base::Unretained(delegate_), display_id)); | 70 base::Unretained(delegate_), display_id)); |
72 } | 71 } |
73 } | 72 } |
74 | 73 |
75 int64_t PlatformScreenStub::GetPrimaryDisplayId() const { | 74 int64_t ScreenManagerStub::GetPrimaryDisplayId() const { |
76 return display_id_; | 75 return display_id_; |
77 } | 76 } |
78 | 77 |
79 } // namespace display | 78 } // namespace display |
OLD | NEW |