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

Side by Side Diff: mojo/services/native_viewport/native_viewport_win.cc

Issue 403263002: platform-window: Add a PlatformWindowFactory for creating windows. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 5 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 | Annotate | Revision Log
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 "mojo/services/native_viewport/native_viewport.h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "ui/gfx/rect.h"
9 #include "ui/platform_window/platform_window_delegate.h"
10 #include "ui/platform_window/win/win_window.h"
11
12 namespace mojo {
13 namespace services {
14
15 class NativeViewportWin : public NativeViewport,
16 public ui::PlatformWindowDelegate {
17 public:
18 explicit NativeViewportWin(NativeViewportDelegate* delegate)
19 : delegate_(delegate) {
20 }
21
22 virtual ~NativeViewportWin() {
23 // Destroy the platform-window while |this| is still alive.
24 platform_window_.reset();
25 }
26
27 private:
28 // Overridden from NativeViewport:
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 delegate_->OnBoundsChanged(new_bounds);
64 }
65
66 virtual void OnDamageRect(const gfx::Rect& damaged_region) OVERRIDE {
67 }
68
69 virtual void DispatchEvent(ui::Event* event) OVERRIDE {
70 delegate_->OnEvent(event);
71 }
72
73 virtual void OnCloseRequest() OVERRIDE {
74 platform_window_->Close();
75 }
76
77 virtual void OnClosed() OVERRIDE {
78 delegate_->OnDestroyed();
79 }
80
81 virtual void OnWindowStateChanged(ui::PlatformWindowState state) OVERRIDE {
82 }
83
84 virtual void OnLostCapture() OVERRIDE {
85 }
86
87 virtual void OnAcceleratedWidgetAvailable(
88 gfx::AcceleratedWidget widget) OVERRIDE {
89 delegate_->OnAcceleratedWidgetAvailable(widget);
90 }
91
92 virtual void OnActivationChanged(bool active) OVERRIDE {}
93
94 scoped_ptr<ui::PlatformWindow> platform_window_;
95 NativeViewportDelegate* delegate_;
96
97 DISALLOW_COPY_AND_ASSIGN(NativeViewportWin);
98 };
99
100 // static
101 scoped_ptr<NativeViewport> NativeViewport::Create(
102 NativeViewportDelegate* delegate) {
103 return scoped_ptr<NativeViewport>(new NativeViewportWin(delegate)).Pass();
104 }
105
106 } // namespace services
107 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/native_viewport/native_viewport_ozone.cc ('k') | mojo/services/native_viewport/native_viewport_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698