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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java

Issue 2842653004: Add back Rect parcelable to onSmartClipDataExtracted. (Closed)
Patch Set: Avoid coordinate conversion Created 3 years, 7 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
OLDNEW
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 package org.chromium.content.browser.webcontents; 5 package org.chromium.content.browser.webcontents;
6 6
7 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.graphics.Bitmap; 8 import android.graphics.Bitmap;
9 import android.graphics.Rect; 9 import android.graphics.Rect;
10 import android.os.Bundle; 10 import android.os.Bundle;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 private NavigationController mNavigationController; 99 private NavigationController mNavigationController;
100 private RenderFrameHost mMainFrame; 100 private RenderFrameHost mMainFrame;
101 101
102 // Lazily created proxy observer for handling all Java-based WebContentsObse rvers. 102 // Lazily created proxy observer for handling all Java-based WebContentsObse rvers.
103 private WebContentsObserverProxy mObserverProxy; 103 private WebContentsObserverProxy mObserverProxy;
104 104
105 // The media session for this WebContents. It is constructed by the native M ediaSession and has 105 // The media session for this WebContents. It is constructed by the native M ediaSession and has
106 // the same life time as native MediaSession. 106 // the same life time as native MediaSession.
107 private MediaSessionImpl mMediaSession; 107 private MediaSessionImpl mMediaSession;
108 108
109 private SmartClipCallback mSmartClipCallback; 109 class SmartClipCallbackImpl implements SmartClipCallback {
110 public SmartClipCallbackImpl(final Handler smartClipHandler) {
111 mHandler = smartClipHandler;
112 }
113 public void storeRequestRect(Rect rect) {
114 mRect = rect;
115 }
116
117 @Override
118 public void onSmartClipDataExtracted(String text, String html) {
119 Bundle bundle = new Bundle();
120 bundle.putString("url", getVisibleUrl());
121 bundle.putString("title", getTitle());
122 bundle.putString("text", text);
123 bundle.putString("html", html);
124 bundle.putParcelable("rect", mRect);
125
126 Message msg = Message.obtain(mHandler, 0);
127 msg.setData(bundle);
128 msg.sendToTarget();
129 }
130
131 Rect mRect;
132 final Handler mHandler;
133 }
134 private SmartClipCallbackImpl mSmartClipCallback;
110 135
111 private EventForwarder mEventForwarder; 136 private EventForwarder mEventForwarder;
112 137
113 private WebContentsImpl( 138 private WebContentsImpl(
114 long nativeWebContentsAndroid, NavigationController navigationContro ller) { 139 long nativeWebContentsAndroid, NavigationController navigationContro ller) {
115 mNativeWebContentsAndroid = nativeWebContentsAndroid; 140 mNativeWebContentsAndroid = nativeWebContentsAndroid;
116 mNavigationController = navigationController; 141 mNavigationController = navigationController;
117 } 142 }
118 143
119 @CalledByNative 144 @CalledByNative
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 String jsonResult, JavaScriptCallback callback) { 418 String jsonResult, JavaScriptCallback callback) {
394 callback.handleJavaScriptResult(jsonResult); 419 callback.handleJavaScriptResult(jsonResult);
395 } 420 }
396 421
397 @Override 422 @Override
398 public int getThemeColor() { 423 public int getThemeColor() {
399 return nativeGetThemeColor(mNativeWebContentsAndroid); 424 return nativeGetThemeColor(mNativeWebContentsAndroid);
400 } 425 }
401 426
402 @Override 427 @Override
403 public void requestSmartClipExtract(int x, int y, int width, int height) { 428 public void requestSmartClipExtract(Rect originalRect, int x, int y, int wid th, int height) {
404 if (mSmartClipCallback == null) return; 429 if (mSmartClipCallback == null) return;
430 mSmartClipCallback.storeRequestRect(originalRect);
David Trainor- moved to gerrit 2017/04/26 20:58:17 Should we just build the rect here and do the dpi
aelias_OOO_until_Jul13 2017/04/26 23:18:15 OK, done. I needed to pass in the RenderCoordinat
405 nativeRequestSmartClipExtract( 431 nativeRequestSmartClipExtract(
406 mNativeWebContentsAndroid, mSmartClipCallback, x, y, width, heig ht); 432 mNativeWebContentsAndroid, mSmartClipCallback, x, y, width, heig ht);
407 } 433 }
408 434
409 @Override 435 @Override
410 public void setSmartClipResultHandler(final Handler smartClipHandler) { 436 public void setSmartClipResultHandler(final Handler smartClipHandler) {
411 if (smartClipHandler == null) { 437 if (smartClipHandler == null) {
412 mSmartClipCallback = null; 438 mSmartClipCallback = null;
413 return; 439 return;
414 } 440 }
415 mSmartClipCallback = new SmartClipCallback() { 441 mSmartClipCallback = new SmartClipCallbackImpl(smartClipHandler);
416 @Override
417 public void onSmartClipDataExtracted(String text, String html) {
418 Bundle bundle = new Bundle();
419 bundle.putString("url", getVisibleUrl());
420 bundle.putString("title", getTitle());
421 bundle.putString("text", text);
422 bundle.putString("html", html);
423
424 Message msg = Message.obtain(smartClipHandler, 0);
425 msg.setData(bundle);
426 msg.sendToTarget();
427 }
428 };
429 } 442 }
430 443
431 @CalledByNative 444 @CalledByNative
432 private static void onSmartClipDataExtracted( 445 private static void onSmartClipDataExtracted(
433 String text, String html, SmartClipCallback callback) { 446 String text, String html, SmartClipCallback callback) {
434 callback.onSmartClipDataExtracted(text, html); 447 callback.onSmartClipDataExtracted(text, html);
435 } 448 }
436 449
437 @Override 450 @Override
438 public void requestAccessibilitySnapshot(AccessibilitySnapshotCallback callb ack) { 451 public void requestAccessibilitySnapshot(AccessibilitySnapshotCallback callb ack) {
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 private native void nativeReloadLoFiImages(long nativeWebContentsAndroid); 659 private native void nativeReloadLoFiImages(long nativeWebContentsAndroid);
647 private native int nativeDownloadImage(long nativeWebContentsAndroid, 660 private native int nativeDownloadImage(long nativeWebContentsAndroid,
648 String url, boolean isFavicon, int maxBitmapSize, 661 String url, boolean isFavicon, int maxBitmapSize,
649 boolean bypassCache, ImageDownloadCallback callback); 662 boolean bypassCache, ImageDownloadCallback callback);
650 private native void nativeDismissTextHandles(long nativeWebContentsAndroid); 663 private native void nativeDismissTextHandles(long nativeWebContentsAndroid);
651 private native void nativeShowContextMenuAtPoint(long nativeWebContentsAndro id, int x, int y); 664 private native void nativeShowContextMenuAtPoint(long nativeWebContentsAndro id, int x, int y);
652 private native void nativeSetHasPersistentVideo(long nativeWebContentsAndroi d, boolean value); 665 private native void nativeSetHasPersistentVideo(long nativeWebContentsAndroi d, boolean value);
653 private native boolean nativeHasActiveEffectivelyFullscreenVideo(long native WebContentsAndroid); 666 private native boolean nativeHasActiveEffectivelyFullscreenVideo(long native WebContentsAndroid);
654 private native EventForwarder nativeGetOrCreateEventForwarder(long nativeWeb ContentsAndroid); 667 private native EventForwarder nativeGetOrCreateEventForwarder(long nativeWeb ContentsAndroid);
655 } 668 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698