Home | History | Annotate | Download | only in native_viewport
      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 #ifndef MOJO_SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_H_
      6 #define MOJO_SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_H_
      7 
      8 #include "base/memory/scoped_ptr.h"
      9 #include "ui/gfx/native_widget_types.h"
     10 #include "ui/gfx/size.h"
     11 
     12 namespace gfx {
     13 class Rect;
     14 }
     15 
     16 namespace ui {
     17 class Event;
     18 }
     19 
     20 namespace mojo {
     21 namespace shell {
     22 class Context;
     23 }
     24 
     25 namespace services {
     26 
     27 class NativeViewportDelegate {
     28  public:
     29   virtual ~NativeViewportDelegate() {}
     30 
     31   virtual void OnBoundsChanged(const gfx::Rect& size) = 0;
     32   virtual void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) = 0;
     33   virtual bool OnEvent(ui::Event* ui_event) = 0;
     34   virtual void OnDestroyed() = 0;
     35 };
     36 
     37 // Encapsulation of platform-specific Viewport.
     38 // TODO(abarth): Rename this class so that it doesn't conflict with the name of
     39 // the service.
     40 class NativeViewport {
     41  public:
     42   virtual ~NativeViewport() {}
     43 
     44   virtual void Init(const gfx::Rect& bounds) = 0;
     45   virtual void Show() = 0;
     46   virtual void Hide() = 0;
     47   virtual void Close() = 0;
     48   virtual gfx::Size GetSize() = 0;
     49   virtual void SetBounds(const gfx::Rect& bounds) = 0;
     50 
     51   virtual void SetCapture() = 0;
     52   virtual void ReleaseCapture() = 0;
     53 
     54   // |context| is NULL when loaded into separate process.
     55   static scoped_ptr<NativeViewport> Create(shell::Context* context,
     56                                            NativeViewportDelegate* delegate);
     57 };
     58 
     59 }  // namespace services
     60 }  // namespace mojo
     61 
     62 #endif  // MOJO_SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_H_
     63