Index: ui/aura/window_tree_host_android.cc |
diff --git a/ui/aura/window_tree_host_android.cc b/ui/aura/window_tree_host_android.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d77d0c384dc0b80d19a34ee51402ed2b7d61f05f |
--- /dev/null |
+++ b/ui/aura/window_tree_host_android.cc |
@@ -0,0 +1,146 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "ui/aura/window_tree_host_android.h" |
+ |
+#include "base/trace_event/trace_event.h" |
+#include "ui/aura/window_event_dispatcher.h" |
+#include "ui/base/ime/input_method.h" |
+#include "ui/compositor/compositor.h" |
+#include "ui/platform_window/android/platform_window_android.h" |
+ |
+namespace aura { |
+namespace { |
+WindowTreeHostAndroid* instance = nullptr; |
+} |
+ |
+WindowTreeHostAndroid::WindowTreeHostAndroid(const gfx::Rect& bounds) |
+ : widget_(gfx::kNullAcceleratedWidget), current_cursor_(ui::kCursorNull) { |
+ DCHECK(!instance); |
+ instance = this; |
+ CreateCompositor(); |
+ platform_window_.reset(new ui::PlatformWindowAndroid(this)); |
+ platform_window_->SetBounds(bounds); |
+ platform_window_->Show(); |
+} |
+ |
+// static |
+WindowTreeHostAndroid* WindowTreeHostAndroid::GetHost() { |
+ return instance; |
+} |
+ |
+ |
+WindowTreeHostAndroid::~WindowTreeHostAndroid() { |
+ DestroyCompositor(); |
+ DestroyDispatcher(); |
+} |
+ |
+ui::EventSource* WindowTreeHostAndroid::GetEventSource() { |
+ return this; |
+} |
+ |
+gfx::AcceleratedWidget WindowTreeHostAndroid::GetAcceleratedWidget() { |
+ return widget_; |
+} |
+ |
+void WindowTreeHostAndroid::ShowImpl() { |
+ platform_window_->Show(); |
+} |
+ |
+void WindowTreeHostAndroid::HideImpl() { |
+ platform_window_->Hide(); |
+} |
+ |
+gfx::Rect WindowTreeHostAndroid::GetBounds() const { |
+ return platform_window_->GetBounds(); |
+} |
+ |
+void WindowTreeHostAndroid::SetBounds(const gfx::Rect& bounds) { |
+ platform_window_->SetBounds(bounds); |
+} |
+ |
+gfx::Point WindowTreeHostAndroid::GetLocationOnNativeScreen() const { |
+ return platform_window_->GetBounds().origin(); |
+} |
+ |
+void WindowTreeHostAndroid::SetCapture() { |
+ platform_window_->SetCapture(); |
+} |
+ |
+void WindowTreeHostAndroid::ReleaseCapture() { |
+ platform_window_->ReleaseCapture(); |
+} |
+ |
+void WindowTreeHostAndroid::SetCursorNative(gfx::NativeCursor cursor) { |
+ if (cursor == current_cursor_) |
+ return; |
+ current_cursor_ = cursor; |
+ platform_window_->SetCursor(cursor.platform()); |
+} |
+ |
+void WindowTreeHostAndroid::MoveCursorToNative(const gfx::Point& location) { |
+ platform_window_->MoveCursorTo(location); |
+} |
+ |
+void WindowTreeHostAndroid::OnCursorVisibilityChangedNative(bool show) { |
+} |
+ |
+void WindowTreeHostAndroid::OnBoundsChanged(const gfx::Rect& new_bounds) { |
+ // TOOD(spang): Should we determine which parts changed? |
+ OnHostResized(new_bounds.size()); |
+ OnHostMoved(new_bounds.origin()); |
+} |
+ |
+void WindowTreeHostAndroid::OnDamageRect(const gfx::Rect& damaged_region) { |
+} |
+ |
+void WindowTreeHostAndroid::DispatchEvent(ui::Event* event) { |
+ TRACE_EVENT0("input", "WindowTreeHostAndroid::DispatchEvent"); |
+ SendEventToProcessor(event); |
+} |
+ |
+void WindowTreeHostAndroid::OnCloseRequest() { |
+ OnHostCloseRequested(); |
+} |
+ |
+void WindowTreeHostAndroid::OnClosed() { |
+} |
+ |
+void WindowTreeHostAndroid::OnWindowStateChanged( |
+ ui::PlatformWindowState new_state) { |
+} |
+ |
+void WindowTreeHostAndroid::OnLostCapture() { |
+} |
+ |
+void WindowTreeHostAndroid::OnAcceleratedWidgetAvailable( |
+ gfx::AcceleratedWidget widget, |
+ float device_pixel_ratio) { |
+ widget_ = widget; |
+ WindowTreeHost::OnAcceleratedWidgetAvailable(); |
+} |
+ |
+void WindowTreeHostAndroid::OnActivationChanged(bool active) { |
+ if (active) |
+ GetInputMethod()->OnFocus(); |
+ else |
+ GetInputMethod()->OnBlur(); |
+} |
+ |
+ui::InputMethod* WindowTreeHostAndroid::GetInputMethod2() { |
+ return GetInputMethod(); |
+} |
+ |
+// static |
+WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) { |
+ return new WindowTreeHostAndroid(bounds); |
+} |
+ |
+// static |
+gfx::Size WindowTreeHost::GetNativeScreenSize() { |
+ NOTIMPLEMENTED(); |
+ return gfx::Size(); |
+} |
+ |
+} // namespace aura |