| OLD | NEW |
| 1 // Copyright 2014 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/native_viewport.h" | 5 #include "mojo/services/native_viewport/native_viewport.h" |
| 6 | 6 |
| 7 #include "ui/events/event.h" | 7 #include "ui/gfx/rect.h" |
| 8 #include "ui/events/platform/platform_event_dispatcher.h" | 8 #include "ui/platform_window/platform_window_factory.h" |
| 9 #include "ui/events/platform/platform_event_source.h" | 9 #include "ui/platform_window/types/platform_window.h" |
| 10 #include "ui/ozone/public/cursor_factory_ozone.h" | 10 #include "ui/platform_window/types/platform_window_delegate.h" |
| 11 #include "ui/ozone/public/event_factory_ozone.h" | |
| 12 #include "ui/ozone/public/ozone_platform.h" | |
| 13 #include "ui/ozone/public/surface_factory_ozone.h" | |
| 14 #include "ui/platform_window/platform_window.h" | |
| 15 #include "ui/platform_window/platform_window_delegate.h" | |
| 16 | 11 |
| 17 namespace mojo { | 12 namespace mojo { |
| 18 namespace services { | 13 namespace services { |
| 19 | 14 |
| 20 // TODO(spang): Deduplicate with NativeViewportX11.. but there's a hack | 15 class PlatformViewport : public NativeViewport, |
| 21 // in there that prevents this. | 16 public ui::PlatformWindowDelegate { |
| 22 class NativeViewportOzone : public NativeViewport, | |
| 23 public ui::PlatformWindowDelegate { | |
| 24 public: | 17 public: |
| 25 explicit NativeViewportOzone(NativeViewportDelegate* delegate) | 18 explicit PlatformViewport(NativeViewportDelegate* delegate) |
| 26 : delegate_(delegate) { | 19 : delegate_(delegate) {} |
| 27 ui::OzonePlatform::InitializeForUI(); | |
| 28 } | |
| 29 | 20 |
| 30 virtual ~NativeViewportOzone() { | 21 virtual ~PlatformViewport() { |
| 31 // Destroy the platform-window while |this| is still alive. | 22 // Destroy the platform-window while |this| is still alive. |
| 32 platform_window_.reset(); | 23 platform_window_.reset(); |
| 33 } | 24 } |
| 34 | 25 |
| 35 private: | 26 private: |
| 36 // Overridden from NativeViewport: | 27 // Overridden from NativeViewport: |
| 37 virtual void Init(const gfx::Rect& bounds) OVERRIDE { | 28 virtual void Init(const gfx::Rect& bounds) OVERRIDE { |
| 29 CHECK(!platform_window_); |
| 30 |
| 38 platform_window_ = | 31 platform_window_ = |
| 39 ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds); | 32 ui::PlatformWindowFactory::GetInstance()->CreatePlatformWindow(this, |
| 33 bounds); |
| 40 } | 34 } |
| 41 | 35 |
| 42 virtual void Show() OVERRIDE { platform_window_->Show(); } | 36 virtual void Show() OVERRIDE { platform_window_->Show(); } |
| 43 | 37 |
| 44 virtual void Hide() OVERRIDE { platform_window_->Hide(); } | 38 virtual void Hide() OVERRIDE { platform_window_->Hide(); } |
| 45 | 39 |
| 46 virtual void Close() OVERRIDE { platform_window_->Close(); } | 40 virtual void Close() OVERRIDE { platform_window_->Close(); } |
| 47 | 41 |
| 48 virtual gfx::Size GetSize() OVERRIDE { | 42 virtual gfx::Size GetSize() OVERRIDE { |
| 49 return platform_window_->GetBounds().size(); | 43 return platform_window_->GetBounds().size(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 79 virtual void OnAcceleratedWidgetAvailable( | 73 virtual void OnAcceleratedWidgetAvailable( |
| 80 gfx::AcceleratedWidget widget) OVERRIDE { | 74 gfx::AcceleratedWidget widget) OVERRIDE { |
| 81 delegate_->OnAcceleratedWidgetAvailable(widget); | 75 delegate_->OnAcceleratedWidgetAvailable(widget); |
| 82 } | 76 } |
| 83 | 77 |
| 84 virtual void OnActivationChanged(bool active) OVERRIDE {} | 78 virtual void OnActivationChanged(bool active) OVERRIDE {} |
| 85 | 79 |
| 86 scoped_ptr<ui::PlatformWindow> platform_window_; | 80 scoped_ptr<ui::PlatformWindow> platform_window_; |
| 87 NativeViewportDelegate* delegate_; | 81 NativeViewportDelegate* delegate_; |
| 88 | 82 |
| 89 DISALLOW_COPY_AND_ASSIGN(NativeViewportOzone); | 83 DISALLOW_COPY_AND_ASSIGN(PlatformViewport); |
| 90 }; | 84 }; |
| 91 | 85 |
| 92 // static | 86 // static |
| 93 scoped_ptr<NativeViewport> NativeViewport::Create( | 87 scoped_ptr<NativeViewport> NativeViewport::Create( |
| 94 NativeViewportDelegate* delegate) { | 88 NativeViewportDelegate* delegate) { |
| 95 return scoped_ptr<NativeViewport>(new NativeViewportOzone(delegate)).Pass(); | 89 return scoped_ptr<NativeViewport>(new PlatformViewport(delegate)); |
| 96 } | 90 } |
| 97 | 91 |
| 98 } // namespace services | 92 } // namespace services |
| 99 } // namespace mojo | 93 } // namespace mojo |
| OLD | NEW |