Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: ui/android/view_android.cc

Issue 2878403002: Support setting mouse cursor icon in Android N. (Closed)
Patch Set: Support setting mouse cursor icon in Android N Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/android/view_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ui/android/view_android.h" 5 #include "ui/android/view_android.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
11 #include "base/containers/adapters.h" 11 #include "base/containers/adapters.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "cc/layers/layer.h" 13 #include "cc/layers/layer.h"
14 #include "jni/ViewAndroidDelegate_jni.h" 14 #include "jni/ViewAndroidDelegate_jni.h"
15 #include "third_party/WebKit/public/platform/WebCursorInfo.h"
15 #include "ui/android/event_forwarder.h" 16 #include "ui/android/event_forwarder.h"
16 #include "ui/android/view_client.h" 17 #include "ui/android/view_client.h"
17 #include "ui/android/window_android.h" 18 #include "ui/android/window_android.h"
18 #include "ui/base/layout.h" 19 #include "ui/base/layout.h"
19 #include "ui/events/android/drag_event_android.h" 20 #include "ui/events/android/drag_event_android.h"
20 #include "ui/events/android/motion_event_android.h" 21 #include "ui/events/android/motion_event_android.h"
22 #include "ui/gfx/android/java_bitmap.h"
21 #include "url/gurl.h" 23 #include "url/gurl.h"
22 24
23 namespace ui { 25 namespace ui {
24 26
25 using base::android::ConvertUTF8ToJavaString; 27 using base::android::ConvertUTF8ToJavaString;
26 using base::android::JavaRef; 28 using base::android::JavaRef;
27 using base::android::ScopedJavaLocalRef; 29 using base::android::ScopedJavaLocalRef;
30 using blink::WebCursorInfo;
28 31
29 ViewAndroid::ScopedAnchorView::ScopedAnchorView( 32 ViewAndroid::ScopedAnchorView::ScopedAnchorView(
30 JNIEnv* env, 33 JNIEnv* env,
31 const JavaRef<jobject>& jview, 34 const JavaRef<jobject>& jview,
32 const JavaRef<jobject>& jdelegate) 35 const JavaRef<jobject>& jdelegate)
33 : view_(env, jview.obj()), delegate_(env, jdelegate.obj()) { 36 : view_(env, jview.obj()), delegate_(env, jdelegate.obj()) {
34 // If there's a view, then we need a delegate to remove it. 37 // If there's a view, then we need a delegate to remove it.
35 DCHECK(!jdelegate.is_null() || jview.is_null()); 38 DCHECK(!jdelegate.is_null() || jview.is_null());
36 } 39 }
37 40
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext, 284 bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext,
282 const JavaRef<jobject>& jimage) { 285 const JavaRef<jobject>& jimage) {
283 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); 286 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
284 if (delegate.is_null()) 287 if (delegate.is_null())
285 return false; 288 return false;
286 JNIEnv* env = base::android::AttachCurrentThread(); 289 JNIEnv* env = base::android::AttachCurrentThread();
287 return Java_ViewAndroidDelegate_startDragAndDrop(env, delegate, jtext, 290 return Java_ViewAndroidDelegate_startDragAndDrop(env, delegate, jtext,
288 jimage); 291 jimage);
289 } 292 }
290 293
294 void ViewAndroid::OnCursorChanged(int type,
295 const SkBitmap& custom_image,
296 const gfx::Point& hotspot) {
297 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
298 if (delegate.is_null())
299 return;
300 JNIEnv* env = base::android::AttachCurrentThread();
301 if (type == WebCursorInfo::kTypeCustom) {
302 ScopedJavaLocalRef<jobject> java_bitmap =
303 gfx::ConvertToJavaBitmap(&custom_image);
304 Java_ViewAndroidDelegate_onCursorChangedToCustom(env, delegate, java_bitmap,
305 hotspot.x(), hotspot.y());
306 } else {
307 Java_ViewAndroidDelegate_onCursorChanged(env, delegate, type);
308 }
309 }
310
291 void ViewAndroid::OnBackgroundColorChanged(unsigned int color) { 311 void ViewAndroid::OnBackgroundColorChanged(unsigned int color) {
292 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); 312 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
293 if (delegate.is_null()) 313 if (delegate.is_null())
294 return; 314 return;
295 JNIEnv* env = base::android::AttachCurrentThread(); 315 JNIEnv* env = base::android::AttachCurrentThread();
296 Java_ViewAndroidDelegate_onBackgroundColorChanged(env, delegate, color); 316 Java_ViewAndroidDelegate_onBackgroundColorChanged(env, delegate, color);
297 } 317 }
298 318
299 void ViewAndroid::OnTopControlsChanged(float top_controls_offset, 319 void ViewAndroid::OnTopControlsChanged(float top_controls_offset,
300 float top_content_offset) { 320 float top_content_offset) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 matched = bound.Contains(int_point); 435 matched = bound.Contains(int_point);
416 } 436 }
417 if (matched && child->HitTest(send_to_client, event, offset_point)) 437 if (matched && child->HitTest(send_to_client, event, offset_point))
418 return true; 438 return true;
419 } 439 }
420 } 440 }
421 return false; 441 return false;
422 } 442 }
423 443
424 } // namespace ui 444 } // namespace ui
OLDNEW
« no previous file with comments | « ui/android/view_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698