| 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 "services/native_viewport/platform_viewport_android.h" | 5 #include "services/native_viewport/platform_viewport_android.h" |
| 6 | 6 |
| 7 #include <android/input.h> | 7 #include <android/input.h> |
| 8 #include <android/native_window_jni.h> | 8 #include <android/native_window_jni.h> |
| 9 | 9 |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "jni/PlatformViewportAndroid_jni.h" | 12 #include "jni/PlatformViewportAndroid_jni.h" |
| 13 #include "mojo/converters/geometry/geometry_type_converters.h" | 13 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 14 #include "mojo/converters/input_events/input_events_type_converters.h" | 14 #include "mojo/converters/input_events/input_events_type_converters.h" |
| 15 #include "mojo/public/cpp/application/application_impl.h" | 15 #include "mojo/public/cpp/application/application_impl.h" |
| 16 #include "mojo/public/cpp/application/connect.h" |
| 16 #include "services/native_viewport/native_viewport_support.mojom.h" | 17 #include "services/native_viewport/native_viewport_support.mojom.h" |
| 17 #include "ui/events/event.h" | 18 #include "ui/events/event.h" |
| 18 #include "ui/events/keycodes/keyboard_code_conversion_android.h" | 19 #include "ui/events/keycodes/keyboard_code_conversion_android.h" |
| 19 #include "ui/gfx/point.h" | 20 #include "ui/gfx/point.h" |
| 20 | 21 |
| 21 namespace native_viewport { | 22 namespace native_viewport { |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 mojo::EventType MotionEventActionToEventType(jint action) { | 25 mojo::EventType MotionEventActionToEventType(jint action) { |
| 25 switch (action) { | 26 switch (action) { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 } | 160 } |
| 160 | 161 |
| 161 //////////////////////////////////////////////////////////////////////////////// | 162 //////////////////////////////////////////////////////////////////////////////// |
| 162 // PlatformViewportAndroid, PlatformViewport implementation: | 163 // PlatformViewportAndroid, PlatformViewport implementation: |
| 163 | 164 |
| 164 void PlatformViewportAndroid::Init(const gfx::Rect& bounds) { | 165 void PlatformViewportAndroid::Init(const gfx::Rect& bounds) { |
| 165 JNIEnv* env = base::android::AttachCurrentThread(); | 166 JNIEnv* env = base::android::AttachCurrentThread(); |
| 166 Java_PlatformViewportAndroid_createRequest(env, | 167 Java_PlatformViewportAndroid_createRequest(env, |
| 167 reinterpret_cast<intptr_t>(this)); | 168 reinterpret_cast<intptr_t>(this)); |
| 168 | 169 |
| 169 application_->ConnectToServiceDeprecated("mojo:native_viewport_support", | 170 mojo::ConnectToService(application_->shell(), "mojo:native_viewport_support", |
| 170 &support_service_); | 171 GetProxy(&support_service_)); |
| 171 support_service_->CreateNewNativeWindow( | 172 support_service_->CreateNewNativeWindow( |
| 172 base::Bind(&PlatformViewportAndroid::Close, weak_factory_.GetWeakPtr())); | 173 base::Bind(&PlatformViewportAndroid::Close, weak_factory_.GetWeakPtr())); |
| 173 } | 174 } |
| 174 | 175 |
| 175 void PlatformViewportAndroid::Show() { | 176 void PlatformViewportAndroid::Show() { |
| 176 // Nothing to do. View is created visible. | 177 // Nothing to do. View is created visible. |
| 177 } | 178 } |
| 178 | 179 |
| 179 void PlatformViewportAndroid::Hide() { | 180 void PlatformViewportAndroid::Hide() { |
| 180 // Nothing to do. View is always visible. | 181 // Nothing to do. View is always visible. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 209 // static | 210 // static |
| 210 scoped_ptr<PlatformViewport> PlatformViewport::Create( | 211 scoped_ptr<PlatformViewport> PlatformViewport::Create( |
| 211 mojo::ApplicationImpl* application_, | 212 mojo::ApplicationImpl* application_, |
| 212 Delegate* delegate) { | 213 Delegate* delegate) { |
| 213 return scoped_ptr<PlatformViewport>( | 214 return scoped_ptr<PlatformViewport>( |
| 214 new PlatformViewportAndroid(application_, delegate)) | 215 new PlatformViewportAndroid(application_, delegate)) |
| 215 .Pass(); | 216 .Pass(); |
| 216 } | 217 } |
| 217 | 218 |
| 218 } // namespace native_viewport | 219 } // namespace native_viewport |
| OLD | NEW |