Chromium Code Reviews| 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" | |
| 9 #include "ui/events/platform/platform_event_source.h" | |
| 10 #include "ui/ozone/public/cursor_factory_ozone.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" | 8 #include "ui/platform_window/platform_window.h" |
| 15 #include "ui/platform_window/platform_window_delegate.h" | 9 #include "ui/platform_window/platform_window_delegate.h" |
| 10 #include "ui/platform_window/platform_window_factory.h" | |
| 11 | |
| 12 #if defined(USE_X11) | |
| 13 #include "ui/platform_window/x11/x11_window_factory.h" | |
| 14 #elif defined(USE_OZONE) | |
| 15 #include "ui/ozone/public/ozone_platform.h" | |
| 16 #endif | |
| 16 | 17 |
| 17 namespace mojo { | 18 namespace mojo { |
| 18 namespace services { | 19 namespace services { |
| 19 | 20 |
| 20 // TODO(spang): Deduplicate with NativeViewportX11.. but there's a hack | 21 class PlatformViewport : public NativeViewport, |
| 21 // in there that prevents this. | 22 public ui::PlatformWindowDelegate { |
| 22 class NativeViewportOzone : public NativeViewport, | |
| 23 public ui::PlatformWindowDelegate { | |
| 24 public: | 23 public: |
| 25 explicit NativeViewportOzone(NativeViewportDelegate* delegate) | 24 explicit PlatformViewport(NativeViewportDelegate* delegate) |
| 26 : delegate_(delegate) { | 25 : delegate_(delegate) {} |
| 27 ui::OzonePlatform::InitializeForUI(); | |
|
spang
2014/07/21 16:59:07
did this move somewhere?
sadrul
2014/07/21 17:39:54
I had this below after line 96, but it looks like
| |
| 28 } | |
| 29 | 26 |
| 30 virtual ~NativeViewportOzone() { | 27 virtual ~PlatformViewport() { |
| 31 // Destroy the platform-window while |this| is still alive. | 28 // Destroy the platform-window while |this| is still alive. |
| 32 platform_window_.reset(); | 29 platform_window_.reset(); |
| 33 } | 30 } |
| 34 | 31 |
| 35 private: | 32 private: |
| 36 // Overridden from NativeViewport: | 33 // Overridden from NativeViewport: |
| 37 virtual void Init(const gfx::Rect& bounds) OVERRIDE { | 34 virtual void Init(const gfx::Rect& bounds) OVERRIDE { |
| 35 CHECK(!platform_window_); | |
| 36 | |
| 38 platform_window_ = | 37 platform_window_ = |
| 39 ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds); | 38 ui::PlatformWindowFactory::GetInstance()->CreatePlatformWindow(this, |
| 39 bounds); | |
| 40 } | 40 } |
| 41 | 41 |
| 42 virtual void Show() OVERRIDE { platform_window_->Show(); } | 42 virtual void Show() OVERRIDE { platform_window_->Show(); } |
| 43 | 43 |
| 44 virtual void Hide() OVERRIDE { platform_window_->Hide(); } | 44 virtual void Hide() OVERRIDE { platform_window_->Hide(); } |
| 45 | 45 |
| 46 virtual void Close() OVERRIDE { platform_window_->Close(); } | 46 virtual void Close() OVERRIDE { platform_window_->Close(); } |
| 47 | 47 |
| 48 virtual gfx::Size GetSize() OVERRIDE { | 48 virtual gfx::Size GetSize() OVERRIDE { |
| 49 return platform_window_->GetBounds().size(); | 49 return platform_window_->GetBounds().size(); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 77 virtual void OnLostCapture() OVERRIDE {} | 77 virtual void OnLostCapture() OVERRIDE {} |
| 78 | 78 |
| 79 virtual void OnAcceleratedWidgetAvailable( | 79 virtual void OnAcceleratedWidgetAvailable( |
| 80 gfx::AcceleratedWidget widget) OVERRIDE { | 80 gfx::AcceleratedWidget widget) OVERRIDE { |
| 81 delegate_->OnAcceleratedWidgetAvailable(widget); | 81 delegate_->OnAcceleratedWidgetAvailable(widget); |
| 82 } | 82 } |
| 83 | 83 |
| 84 scoped_ptr<ui::PlatformWindow> platform_window_; | 84 scoped_ptr<ui::PlatformWindow> platform_window_; |
| 85 NativeViewportDelegate* delegate_; | 85 NativeViewportDelegate* delegate_; |
| 86 | 86 |
| 87 DISALLOW_COPY_AND_ASSIGN(NativeViewportOzone); | 87 DISALLOW_COPY_AND_ASSIGN(PlatformViewport); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 // static | 90 // static |
| 91 scoped_ptr<NativeViewport> NativeViewport::Create( | 91 scoped_ptr<NativeViewport> NativeViewport::Create( |
| 92 shell::Context* context, | 92 shell::Context* context, |
| 93 NativeViewportDelegate* delegate) { | 93 NativeViewportDelegate* delegate) { |
| 94 return scoped_ptr<NativeViewport>(new NativeViewportOzone(delegate)).Pass(); | 94 #if defined(USE_X11) |
| 95 ui::X11WindowFactory::CreateIfNecessary(); | |
| 96 #endif | |
| 97 return scoped_ptr<NativeViewport>(new PlatformViewport(delegate)).Pass(); | |
| 95 } | 98 } |
| 96 | 99 |
| 97 } // namespace services | 100 } // namespace services |
| 98 } // namespace mojo | 101 } // namespace mojo |
| OLD | NEW |