OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
8 import android.annotation.TargetApi; | 8 import android.annotation.TargetApi; |
9 import android.app.assist.AssistStructure.ViewNode; | 9 import android.app.assist.AssistStructure.ViewNode; |
10 import android.content.ClipData; | 10 import android.content.ClipData; |
(...skipping 2520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2531 | 2531 |
2532 public void setBackgroundOpaque(boolean opaque) { | 2532 public void setBackgroundOpaque(boolean opaque) { |
2533 if (mNativeContentViewCore != 0) { | 2533 if (mNativeContentViewCore != 0) { |
2534 nativeSetBackgroundOpaque(mNativeContentViewCore, opaque); | 2534 nativeSetBackgroundOpaque(mNativeContentViewCore, opaque); |
2535 } | 2535 } |
2536 } | 2536 } |
2537 | 2537 |
2538 /** | 2538 /** |
2539 * @see View#onDragEvent(DragEvent) | 2539 * @see View#onDragEvent(DragEvent) |
2540 */ | 2540 */ |
2541 @TargetApi(Build.VERSION_CODES.N) | 2541 // TODO(hush): uncomment below when we build with API 24. |
| 2542 // @TargetApi(Build.VERSION_CODES.N) |
2542 public boolean onDragEvent(DragEvent event) { | 2543 public boolean onDragEvent(DragEvent event) { |
2543 if (mNativeContentViewCore == 0 || Build.VERSION.SDK_INT <= Build.VERSIO
N_CODES.M) { | 2544 if (mNativeContentViewCore == 0 || Build.VERSION.SDK_INT <= Build.VERSIO
N_CODES.M) { |
2544 return false; | 2545 return false; |
2545 } | 2546 } |
2546 | 2547 |
2547 ClipDescription clipDescription = event.getClipDescription(); | 2548 ClipDescription clipDescription = event.getClipDescription(); |
2548 | 2549 |
2549 // text/* will match text/uri-list, text/html, text/plain. | 2550 // text/* will match text/uri-list, text/html, text/plain. |
2550 String[] mimeTypes = | 2551 String[] mimeTypes = |
2551 clipDescription == null ? new String[0] : clipDescription.filter
MimeTypes("text/*"); | 2552 clipDescription == null ? new String[0] : clipDescription.filter
MimeTypes("text/*"); |
2552 | 2553 |
2553 if (event.getAction() == DragEvent.ACTION_DRAG_STARTED) { | 2554 if (event.getAction() == DragEvent.ACTION_DRAG_STARTED) { |
2554 // TODO(hush): support dragging more than just text. | 2555 // TODO(hush): support dragging more than just text. |
2555 return mimeTypes != null && mimeTypes.length > 0 | 2556 return mimeTypes != null && mimeTypes.length > 0 |
2556 && nativeIsTouchDragDropEnabled(mNativeContentViewCore); | 2557 && nativeIsTouchDragDropEnabled(mNativeContentViewCore); |
2557 } | 2558 } |
2558 | 2559 |
2559 StringBuilder content = new StringBuilder(""); | 2560 StringBuilder content = new StringBuilder(""); |
2560 if (event.getAction() == DragEvent.ACTION_DROP) { | 2561 if (event.getAction() == DragEvent.ACTION_DROP) { |
2561 // TODO(hush): obtain dragdrop permissions, when dragging files into
Chrome/WebView is | 2562 // TODO(hush): obtain dragdrop permissions (via reflection?), when d
ragging files into |
2562 // supported. Not necessary to do so for now, because only text drag
ging is supported. | 2563 // Chrome/WebView is supported. Not necessary to do so for now, beca
use only text |
| 2564 // dragging is supported. |
2563 ClipData clipData = event.getClipData(); | 2565 ClipData clipData = event.getClipData(); |
2564 final int itemCount = clipData.getItemCount(); | 2566 final int itemCount = clipData.getItemCount(); |
2565 for (int i = 0; i < itemCount; i++) { | 2567 for (int i = 0; i < itemCount; i++) { |
2566 ClipData.Item item = clipData.getItemAt(i); | 2568 ClipData.Item item = clipData.getItemAt(i); |
2567 content.append(item.coerceToStyledText(mContainerView.getContext
())); | 2569 content.append(item.coerceToStyledText(mContainerView.getContext
())); |
2568 } | 2570 } |
2569 } | 2571 } |
2570 | 2572 |
2571 int[] locationOnScreen = new int[2]; | 2573 int[] locationOnScreen = new int[2]; |
2572 mContainerView.getLocationOnScreen(locationOnScreen); | 2574 mContainerView.getLocationOnScreen(locationOnScreen); |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2821 private native void nativeSetTextTrackSettings(long nativeContentViewCoreImp
l, | 2823 private native void nativeSetTextTrackSettings(long nativeContentViewCoreImp
l, |
2822 boolean textTracksEnabled, String textTrackBackgroundColor, String t
extTrackFontFamily, | 2824 boolean textTracksEnabled, String textTrackBackgroundColor, String t
extTrackFontFamily, |
2823 String textTrackFontStyle, String textTrackFontVariant, String textT
rackTextColor, | 2825 String textTrackFontStyle, String textTrackFontVariant, String textT
rackTextColor, |
2824 String textTrackTextShadow, String textTrackTextSize); | 2826 String textTrackTextShadow, String textTrackTextSize); |
2825 | 2827 |
2826 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl
, boolean opaque); | 2828 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl
, boolean opaque); |
2827 private native boolean nativeIsTouchDragDropEnabled(long nativeContentViewCo
reImpl); | 2829 private native boolean nativeIsTouchDragDropEnabled(long nativeContentViewCo
reImpl); |
2828 private native void nativeOnDragEvent(long nativeContentViewCoreImpl, int ac
tion, int x, int y, | 2830 private native void nativeOnDragEvent(long nativeContentViewCoreImpl, int ac
tion, int x, int y, |
2829 int screenX, int screenY, String[] mimeTypes, String content); | 2831 int screenX, int screenY, String[] mimeTypes, String content); |
2830 } | 2832 } |
OLD | NEW |