native_viewport_impl.h revision 03b57e008b61dfcb1fbad3aea950ae0e001748b0
1// Copyright 2014 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#ifndef MOJO_SERVICES_NATIVE_VIEWPORT_IMPL_H_
6#define MOJO_SERVICES_NATIVE_VIEWPORT_IMPL_H_
7
8#include "base/memory/weak_ptr.h"
9#include "mojo/services/native_viewport/platform_viewport.h"
10#include "mojo/services/public/interfaces/native_viewport/native_viewport.mojom.h"
11
12namespace ui {
13class Event;
14}
15
16namespace mojo {
17
18class NativeViewportImpl : public InterfaceImpl<NativeViewport>,
19                           public PlatformViewport::Delegate {
20 public:
21  NativeViewportImpl();
22  virtual ~NativeViewportImpl();
23
24  // InterfaceImpl<NativeViewport> implementation.
25  virtual void Create(RectPtr bounds) OVERRIDE;
26  virtual void Show() OVERRIDE;
27  virtual void Hide() OVERRIDE;
28  virtual void Close() OVERRIDE;
29  virtual void SetBounds(RectPtr bounds) OVERRIDE;
30
31  // PlatformViewport::Delegate implementation.
32  virtual void OnBoundsChanged(const gfx::Rect& bounds) OVERRIDE;
33  virtual void OnAcceleratedWidgetAvailable(
34      gfx::AcceleratedWidget widget) OVERRIDE;
35  virtual bool OnEvent(ui::Event* ui_event) OVERRIDE;
36  virtual void OnDestroyed() OVERRIDE;
37
38  void AckEvent();
39
40 private:
41
42  gfx::AcceleratedWidget widget_;
43  scoped_ptr<PlatformViewport> platform_viewport_;
44  bool waiting_for_event_ack_;
45  base::WeakPtrFactory<NativeViewportImpl> weak_factory_;
46};
47
48}  // namespace mojo
49
50#endif  // MOJO_SERVICES_NATIVE_VIEWPORT_IMPL_H_
51