| OLD | NEW | 
|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "mojo/services/native_viewport/platform_viewport.h" | 5 #include "mojo/services/native_viewport/platform_viewport.h" | 
| 6 | 6 | 
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" | 
| 8 #include "ui/gfx/rect.h" | 8 #include "ui/gfx/rect.h" | 
| 9 #include "ui/platform_window/platform_window_delegate.h" | 9 #include "ui/platform_window/platform_window_delegate.h" | 
| 10 #include "ui/platform_window/win/win_window.h" | 10 #include "ui/platform_window/win/win_window.h" | 
| 11 | 11 | 
| 12 namespace mojo { | 12 namespace mojo { | 
| 13 | 13 | 
| 14 class PlatformViewportWin : public PlatformViewport, | 14 class PlatformViewportWin : public PlatformViewport, | 
| 15                             public ui::PlatformWindowDelegate { | 15                             public ui::PlatformWindowDelegate { | 
| 16  public: | 16  public: | 
| 17   explicit PlatformViewportWin(Delegate* delegate) | 17   explicit PlatformViewportWin(Delegate* delegate) | 
| 18       : delegate_(delegate) { | 18       : delegate_(delegate) { | 
| 19   } | 19   } | 
| 20 | 20 | 
| 21   virtual ~PlatformViewportWin() { | 21   virtual ~PlatformViewportWin() { | 
| 22     // Destroy the platform-window while |this| is still alive. | 22     // Destroy the platform-window while |this| is still alive. | 
| 23     platform_window_.reset(); | 23     platform_window_.reset(); | 
| 24   } | 24   } | 
| 25 | 25 | 
| 26  private: | 26  private: | 
| 27   // Overridden from PlatformViewport: | 27   // Overridden from PlatformViewport: | 
| 28   virtual void Init(const gfx::Rect& bounds) OVERRIDE { | 28   virtual void Init(const gfx::Rect& bounds) override { | 
| 29     platform_window_.reset(new ui::WinWindow(this, bounds)); | 29     platform_window_.reset(new ui::WinWindow(this, bounds)); | 
| 30   } | 30   } | 
| 31 | 31 | 
| 32   virtual void Show() OVERRIDE { | 32   virtual void Show() override { | 
| 33     platform_window_->Show(); | 33     platform_window_->Show(); | 
| 34   } | 34   } | 
| 35 | 35 | 
| 36   virtual void Hide() OVERRIDE { | 36   virtual void Hide() override { | 
| 37     platform_window_->Hide(); | 37     platform_window_->Hide(); | 
| 38   } | 38   } | 
| 39 | 39 | 
| 40   virtual void Close() OVERRIDE { | 40   virtual void Close() override { | 
| 41     platform_window_->Close(); | 41     platform_window_->Close(); | 
| 42   } | 42   } | 
| 43 | 43 | 
| 44   virtual gfx::Size GetSize() OVERRIDE { | 44   virtual gfx::Size GetSize() override { | 
| 45     return platform_window_->GetBounds().size(); | 45     return platform_window_->GetBounds().size(); | 
| 46   } | 46   } | 
| 47 | 47 | 
| 48   virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE { | 48   virtual void SetBounds(const gfx::Rect& bounds) override { | 
| 49     platform_window_->SetBounds(bounds); | 49     platform_window_->SetBounds(bounds); | 
| 50   } | 50   } | 
| 51 | 51 | 
| 52   virtual void SetCapture() OVERRIDE { | 52   virtual void SetCapture() override { | 
| 53     platform_window_->SetCapture(); | 53     platform_window_->SetCapture(); | 
| 54   } | 54   } | 
| 55 | 55 | 
| 56   virtual void ReleaseCapture() OVERRIDE { | 56   virtual void ReleaseCapture() override { | 
| 57     platform_window_->ReleaseCapture(); | 57     platform_window_->ReleaseCapture(); | 
| 58   } | 58   } | 
| 59 | 59 | 
| 60   // ui::PlatformWindowDelegate: | 60   // ui::PlatformWindowDelegate: | 
| 61   virtual void OnBoundsChanged(const gfx::Rect& new_bounds) OVERRIDE { | 61   virtual void OnBoundsChanged(const gfx::Rect& new_bounds) override { | 
| 62     delegate_->OnBoundsChanged(new_bounds); | 62     delegate_->OnBoundsChanged(new_bounds); | 
| 63   } | 63   } | 
| 64 | 64 | 
| 65   virtual void OnDamageRect(const gfx::Rect& damaged_region) OVERRIDE { | 65   virtual void OnDamageRect(const gfx::Rect& damaged_region) override { | 
| 66   } | 66   } | 
| 67 | 67 | 
| 68   virtual void DispatchEvent(ui::Event* event) OVERRIDE { | 68   virtual void DispatchEvent(ui::Event* event) override { | 
| 69     delegate_->OnEvent(event); | 69     delegate_->OnEvent(event); | 
| 70   } | 70   } | 
| 71 | 71 | 
| 72   virtual void OnCloseRequest() OVERRIDE { | 72   virtual void OnCloseRequest() override { | 
| 73     platform_window_->Close(); | 73     platform_window_->Close(); | 
| 74   } | 74   } | 
| 75 | 75 | 
| 76   virtual void OnClosed() OVERRIDE { | 76   virtual void OnClosed() override { | 
| 77     delegate_->OnDestroyed(); | 77     delegate_->OnDestroyed(); | 
| 78   } | 78   } | 
| 79 | 79 | 
| 80   virtual void OnWindowStateChanged(ui::PlatformWindowState state) OVERRIDE { | 80   virtual void OnWindowStateChanged(ui::PlatformWindowState state) override { | 
| 81   } | 81   } | 
| 82 | 82 | 
| 83   virtual void OnLostCapture() OVERRIDE { | 83   virtual void OnLostCapture() override { | 
| 84   } | 84   } | 
| 85 | 85 | 
| 86   virtual void OnAcceleratedWidgetAvailable( | 86   virtual void OnAcceleratedWidgetAvailable( | 
| 87       gfx::AcceleratedWidget widget) OVERRIDE { | 87       gfx::AcceleratedWidget widget) override { | 
| 88     delegate_->OnAcceleratedWidgetAvailable(widget); | 88     delegate_->OnAcceleratedWidgetAvailable(widget); | 
| 89   } | 89   } | 
| 90 | 90 | 
| 91   virtual void OnActivationChanged(bool active) OVERRIDE {} | 91   virtual void OnActivationChanged(bool active) override {} | 
| 92 | 92 | 
| 93   scoped_ptr<ui::PlatformWindow> platform_window_; | 93   scoped_ptr<ui::PlatformWindow> platform_window_; | 
| 94   Delegate* delegate_; | 94   Delegate* delegate_; | 
| 95 | 95 | 
| 96   DISALLOW_COPY_AND_ASSIGN(PlatformViewportWin); | 96   DISALLOW_COPY_AND_ASSIGN(PlatformViewportWin); | 
| 97 }; | 97 }; | 
| 98 | 98 | 
| 99 // static | 99 // static | 
| 100 scoped_ptr<PlatformViewport> PlatformViewport::Create(Delegate* delegate) { | 100 scoped_ptr<PlatformViewport> PlatformViewport::Create(Delegate* delegate) { | 
| 101   return scoped_ptr<PlatformViewport>(new PlatformViewportWin(delegate)).Pass(); | 101   return scoped_ptr<PlatformViewport>(new PlatformViewportWin(delegate)).Pass(); | 
| 102 } | 102 } | 
| 103 | 103 | 
| 104 }  // namespace mojo | 104 }  // namespace mojo | 
| OLD | NEW | 
|---|