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/platform_screen_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/shell/public/cpp/interface_registry.h" | 13 #include "services/shell/public/cpp/interface_registry.h" |
14 #include "ui/gfx/geometry/rect.h" | 14 #include "ui/gfx/geometry/rect.h" |
15 | 15 |
16 namespace display { | 16 namespace display { |
17 namespace { | 17 namespace { |
18 | 18 |
19 const int64_t kDisplayId = 1; | 19 const int64_t kDisplayId = 1; |
| 20 constexpr gfx::Size kDisplaySize(1024, 768); |
20 | 21 |
21 } // namespace | 22 } // namespace |
22 | 23 |
23 // static | 24 // static |
24 std::unique_ptr<PlatformScreen> PlatformScreen::Create() { | 25 std::unique_ptr<PlatformScreen> PlatformScreen::Create() { |
25 return base::MakeUnique<PlatformScreenStub>(); | 26 return base::MakeUnique<PlatformScreenStub>(); |
26 } | 27 } |
27 | 28 |
28 PlatformScreenStub::PlatformScreenStub() : weak_ptr_factory_(this) {} | 29 PlatformScreenStub::PlatformScreenStub() : weak_ptr_factory_(this) {} |
29 | 30 |
30 PlatformScreenStub::~PlatformScreenStub() {} | 31 PlatformScreenStub::~PlatformScreenStub() {} |
31 | 32 |
32 void PlatformScreenStub::FixedSizeScreenConfiguration() { | 33 void PlatformScreenStub::FixedSizeScreenConfiguration() { |
33 delegate_->OnDisplayAdded(kDisplayId, gfx::Rect(1024, 768)); | 34 delegate_->OnDisplayAdded(kDisplayId, gfx::Rect(kDisplaySize), kDisplaySize, |
| 35 1.0f); |
34 } | 36 } |
35 | 37 |
36 void PlatformScreenStub::AddInterfaces(shell::InterfaceRegistry* registry) {} | 38 void PlatformScreenStub::AddInterfaces(shell::InterfaceRegistry* registry) {} |
37 | 39 |
38 void PlatformScreenStub::Init(PlatformScreenDelegate* delegate) { | 40 void PlatformScreenStub::Init(PlatformScreenDelegate* delegate) { |
39 DCHECK(delegate); | 41 DCHECK(delegate); |
40 delegate_ = delegate; | 42 delegate_ = delegate; |
41 base::ThreadTaskRunnerHandle::Get()->PostTask( | 43 base::ThreadTaskRunnerHandle::Get()->PostTask( |
42 FROM_HERE, base::Bind(&PlatformScreenStub::FixedSizeScreenConfiguration, | 44 FROM_HERE, base::Bind(&PlatformScreenStub::FixedSizeScreenConfiguration, |
43 weak_ptr_factory_.GetWeakPtr())); | 45 weak_ptr_factory_.GetWeakPtr())); |
44 } | 46 } |
45 | 47 |
46 void PlatformScreenStub::RequestCloseDisplay(int64_t display_id) { | 48 void PlatformScreenStub::RequestCloseDisplay(int64_t display_id) { |
47 if (display_id == kDisplayId) { | 49 if (display_id == kDisplayId) { |
48 base::ThreadTaskRunnerHandle::Get()->PostTask( | 50 base::ThreadTaskRunnerHandle::Get()->PostTask( |
49 FROM_HERE, base::Bind(&PlatformScreenDelegate::OnDisplayRemoved, | 51 FROM_HERE, base::Bind(&PlatformScreenDelegate::OnDisplayRemoved, |
50 base::Unretained(delegate_), display_id)); | 52 base::Unretained(delegate_), display_id)); |
51 } | 53 } |
52 } | 54 } |
53 | 55 |
54 int64_t PlatformScreenStub::GetPrimaryDisplayId() const { | 56 int64_t PlatformScreenStub::GetPrimaryDisplayId() const { |
55 return kDisplayId; | 57 return kDisplayId; |
56 } | 58 } |
57 | 59 |
58 } // namespace display | 60 } // namespace display |
OLD | NEW |