Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(618)

Side by Side Diff: services/native_viewport/platform_viewport_win.cc

Issue 878933005: Remove NativeViewportClient (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 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.
4
5 #include "services/native_viewport/platform_viewport.h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "mojo/converters/geometry/geometry_type_converters.h"
9 #include "ui/gfx/rect.h"
10 #include "ui/platform_window/platform_window_delegate.h"
11 #include "ui/platform_window/win/win_window.h"
12
13 namespace mojo {
14
15 class PlatformViewportWin : public PlatformViewport,
16 public ui::PlatformWindowDelegate {
17 public:
18 explicit PlatformViewportWin(Delegate* delegate)
19 : delegate_(delegate) {
20 }
21
22 virtual ~PlatformViewportWin() {
23 // Destroy the platform-window while |this| is still alive.
24 platform_window_.reset();
25 }
26
27 private:
28 // Overridden from PlatformViewport:
29 virtual void Init(const gfx::Rect& bounds) override {
30 platform_window_.reset(new ui::WinWindow(this, bounds));
31 }
32
33 virtual void Show() override {
34 platform_window_->Show();
35 }
36
37 virtual void Hide() override {
38 platform_window_->Hide();
39 }
40
41 virtual void Close() override {
42 platform_window_->Close();
43 }
44
45 virtual gfx::Size GetSize() override {
46 return platform_window_->GetBounds().size();
47 }
48
49 virtual void SetBounds(const gfx::Rect& bounds) override {
50 platform_window_->SetBounds(bounds);
51 }
52
53 virtual void SetCapture() override {
54 platform_window_->SetCapture();
55 }
56
57 virtual void ReleaseCapture() override {
58 platform_window_->ReleaseCapture();
59 }
60
61 // ui::PlatformWindowDelegate:
62 virtual void OnBoundsChanged(const gfx::Rect& new_bounds) override {
63 mojo::ViewportMetricsPtr metrics = mojo::ViewportMetrics::New();
64 metrics->size = new_bounds.size();
65 delegate_->OnMetricsChanged(metrics.Pass());
66 }
67
68 virtual void OnDamageRect(const gfx::Rect& damaged_region) override {
69 }
70
71 virtual void DispatchEvent(ui::Event* event) override {
72 delegate_->OnEvent(event);
73 }
74
75 virtual void OnCloseRequest() override {
76 platform_window_->Close();
77 }
78
79 virtual void OnClosed() override {
80 delegate_->OnDestroyed();
81 }
82
83 virtual void OnWindowStateChanged(ui::PlatformWindowState state) override {
84 }
85
86 virtual void OnLostCapture() override {
87 }
88
89 virtual void OnAcceleratedWidgetAvailable(
90 gfx::AcceleratedWidget widget) override {
91 delegate_->OnAcceleratedWidgetAvailable(widget);
92 }
93
94 virtual void OnActivationChanged(bool active) override {}
95
96 scoped_ptr<ui::PlatformWindow> platform_window_;
97 Delegate* delegate_;
98
99 DISALLOW_COPY_AND_ASSIGN(PlatformViewportWin);
100 };
101
102 // static
103 scoped_ptr<PlatformViewport> PlatformViewport::Create(Delegate* delegate) {
104 return scoped_ptr<PlatformViewport>(new PlatformViewportWin(delegate)).Pass();
105 }
106
107 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698