OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/events/android/drag_event_android.h" |
| 6 #include "base/android/jni_android.h" |
| 7 |
| 8 using base::android::ScopedJavaLocalRef; |
| 9 using base::android::AttachCurrentThread; |
| 10 |
| 11 namespace ui { |
| 12 |
| 13 DragEventAndroid::DragEventAndroid( |
| 14 JNIEnv* env, |
| 15 int action, |
| 16 const gfx::PointF& location, |
| 17 const gfx::PointF& screen_location, |
| 18 const std::vector<base::string16>& mime_types, |
| 19 jstring content) |
| 20 : action_(action), |
| 21 location_(location), |
| 22 screen_location_(screen_location), |
| 23 mime_types_(mime_types) { |
| 24 content_.Reset(env, content); |
| 25 } |
| 26 |
| 27 DragEventAndroid::~DragEventAndroid() {} |
| 28 |
| 29 const gfx::Point DragEventAndroid::GetLocation() const { |
| 30 return gfx::ToFlooredPoint(location_); |
| 31 } |
| 32 |
| 33 const gfx::Point DragEventAndroid::GetScreenLocation() const { |
| 34 return gfx::ToFlooredPoint(screen_location_); |
| 35 } |
| 36 |
| 37 ScopedJavaLocalRef<jstring> DragEventAndroid::GetJavaContent() const { |
| 38 return ScopedJavaLocalRef<jstring>(content_); |
| 39 } |
| 40 |
| 41 std::unique_ptr<DragEventAndroid> DragEventAndroid::CreateFor( |
| 42 const gfx::PointF& new_location) const { |
| 43 gfx::PointF new_screen_location = |
| 44 new_location + (screen_location_f() - location_f()); |
| 45 JNIEnv* env = AttachCurrentThread(); |
| 46 return std::unique_ptr<DragEventAndroid>( |
| 47 new DragEventAndroid(env, action_, new_location, new_screen_location, |
| 48 mime_types_, content_.obj())); |
| 49 } |
| 50 |
| 51 } // namespace ui |
OLD | NEW |