| 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.app.Activity; | 8 import android.app.Activity; |
| 9 import android.app.SearchManager; | 9 import android.app.SearchManager; |
| 10 import android.content.ClipboardManager; | 10 import android.content.ClipboardManager; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 import org.chromium.content.browser.input.PastePopupMenu.PastePopupMenuDelegate; | 69 import org.chromium.content.browser.input.PastePopupMenu.PastePopupMenuDelegate; |
| 70 import org.chromium.content.browser.input.PopupTouchHandleDrawable; | 70 import org.chromium.content.browser.input.PopupTouchHandleDrawable; |
| 71 import org.chromium.content.browser.input.PopupTouchHandleDrawable.PopupTouchHan
dleDrawableDelegate; | 71 import org.chromium.content.browser.input.PopupTouchHandleDrawable.PopupTouchHan
dleDrawableDelegate; |
| 72 import org.chromium.content.browser.input.SelectPopup; | 72 import org.chromium.content.browser.input.SelectPopup; |
| 73 import org.chromium.content.browser.input.SelectPopupDialog; | 73 import org.chromium.content.browser.input.SelectPopupDialog; |
| 74 import org.chromium.content.browser.input.SelectPopupDropdown; | 74 import org.chromium.content.browser.input.SelectPopupDropdown; |
| 75 import org.chromium.content.browser.input.SelectPopupItem; | 75 import org.chromium.content.browser.input.SelectPopupItem; |
| 76 import org.chromium.content.browser.input.SelectionEventType; | 76 import org.chromium.content.browser.input.SelectionEventType; |
| 77 import org.chromium.content.common.ContentSwitches; | 77 import org.chromium.content.common.ContentSwitches; |
| 78 import org.chromium.content_public.browser.GestureStateListener; | 78 import org.chromium.content_public.browser.GestureStateListener; |
| 79 import org.chromium.content_public.browser.JavaScriptCallback; |
| 79 import org.chromium.content_public.browser.WebContents; | 80 import org.chromium.content_public.browser.WebContents; |
| 80 import org.chromium.ui.base.DeviceFormFactor; | 81 import org.chromium.ui.base.DeviceFormFactor; |
| 81 import org.chromium.ui.base.ViewAndroid; | 82 import org.chromium.ui.base.ViewAndroid; |
| 82 import org.chromium.ui.base.ViewAndroidDelegate; | 83 import org.chromium.ui.base.ViewAndroidDelegate; |
| 83 import org.chromium.ui.base.WindowAndroid; | 84 import org.chromium.ui.base.WindowAndroid; |
| 84 import org.chromium.ui.gfx.DeviceDisplayInfo; | 85 import org.chromium.ui.gfx.DeviceDisplayInfo; |
| 85 | 86 |
| 86 import java.lang.annotation.Annotation; | 87 import java.lang.annotation.Annotation; |
| 87 import java.lang.reflect.Field; | 88 import java.lang.reflect.Field; |
| 88 import java.util.ArrayList; | 89 import java.util.ArrayList; |
| (...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1347 | 1348 |
| 1348 /** | 1349 /** |
| 1349 * Requests the renderer insert a link to the specified stylesheet in the | 1350 * Requests the renderer insert a link to the specified stylesheet in the |
| 1350 * main frame's document. | 1351 * main frame's document. |
| 1351 */ | 1352 */ |
| 1352 public void addStyleSheetByURL(String url) { | 1353 public void addStyleSheetByURL(String url) { |
| 1353 assert mWebContents != null; | 1354 assert mWebContents != null; |
| 1354 mWebContents.addStyleSheetByURL(url); | 1355 mWebContents.addStyleSheetByURL(url); |
| 1355 } | 1356 } |
| 1356 | 1357 |
| 1357 /** Callback interface for evaluateJavaScript(). */ | |
| 1358 public interface JavaScriptCallback { | |
| 1359 void handleJavaScriptResult(String jsonResult); | |
| 1360 } | |
| 1361 | |
| 1362 /** | 1358 /** |
| 1363 * Injects the passed Javascript code in the current page and evaluates it. | 1359 * Injects the passed Javascript code in the current page and evaluates it. |
| 1364 * If a result is required, pass in a callback. | 1360 * If a result is required, pass in a callback. |
| 1365 * Used in automation tests. | 1361 * Used in automation tests. |
| 1366 * | 1362 * |
| 1367 * @param script The Javascript to execute. | 1363 * @param script The Javascript to execute. |
| 1368 * @param callback The callback to be fired off when a result is ready. The
script's | 1364 * @param callback The callback to be fired off when a result is ready. The
script's |
| 1369 * result will be json encoded and passed as the parameter,
and the call | 1365 * result will be json encoded and passed as the parameter,
and the call |
| 1370 * will be made on the main thread. | 1366 * will be made on the main thread. |
| 1371 * If no result is required, pass null. | 1367 * If no result is required, pass null. |
| 1372 */ | 1368 */ |
| 1373 public void evaluateJavaScript(String script, JavaScriptCallback callback) { | 1369 public void evaluateJavaScript(String script, JavaScriptCallback callback) { |
| 1374 if (mNativeContentViewCore == 0) return; | 1370 assert mWebContents != null; |
| 1375 nativeEvaluateJavaScript(mNativeContentViewCore, script, callback, false
); | 1371 mWebContents.evaluateJavaScript(script, callback, false); |
| 1376 } | 1372 } |
| 1377 | 1373 |
| 1378 /** | 1374 /** |
| 1379 * Injects the passed Javascript code in the current page and evaluates it. | 1375 * Injects the passed Javascript code in the current page and evaluates it. |
| 1380 * If there is no page existing, a new one will be created. | 1376 * If there is no page existing, a new one will be created. |
| 1381 * | 1377 * |
| 1382 * @param script The Javascript to execute. | 1378 * @param script The Javascript to execute. |
| 1383 */ | 1379 */ |
| 1384 public void evaluateJavaScriptEvenIfNotYetNavigated(String script) { | 1380 public void evaluateJavaScriptEvenIfNotYetNavigated(String script) { |
| 1385 if (mNativeContentViewCore == 0) return; | 1381 assert mWebContents != null; |
| 1386 nativeEvaluateJavaScript(mNativeContentViewCore, script, null, true); | 1382 mWebContents.evaluateJavaScript(script, null, true); |
| 1387 } | 1383 } |
| 1388 | 1384 |
| 1389 /** | 1385 /** |
| 1390 * Post a message to a frame. | 1386 * Post a message to a frame. |
| 1391 * TODO(sgurun) also add support for transferring a message channel port. | 1387 * TODO(sgurun) also add support for transferring a message channel port. |
| 1392 * | 1388 * |
| 1393 * @param frameName The name of the frame. If the name is null the message i
s posted | 1389 * @param frameName The name of the frame. If the name is null the message i
s posted |
| 1394 * to the main frame. | 1390 * to the main frame. |
| 1395 * @param message The message | 1391 * @param message The message |
| 1396 * @param sourceOrigin The source origin | 1392 * @param sourceOrigin The source origin |
| (...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2403 | 2399 |
| 2404 @SuppressWarnings("unused") | 2400 @SuppressWarnings("unused") |
| 2405 @CalledByNative | 2401 @CalledByNative |
| 2406 private void onSelectionChanged(String text) { | 2402 private void onSelectionChanged(String text) { |
| 2407 mLastSelectedText = text; | 2403 mLastSelectedText = text; |
| 2408 getContentViewClient().onSelectionChanged(text); | 2404 getContentViewClient().onSelectionChanged(text); |
| 2409 } | 2405 } |
| 2410 | 2406 |
| 2411 @SuppressWarnings("unused") | 2407 @SuppressWarnings("unused") |
| 2412 @CalledByNative | 2408 @CalledByNative |
| 2413 private static void onEvaluateJavaScriptResult( | |
| 2414 String jsonResult, JavaScriptCallback callback) { | |
| 2415 callback.handleJavaScriptResult(jsonResult); | |
| 2416 } | |
| 2417 | |
| 2418 @SuppressWarnings("unused") | |
| 2419 @CalledByNative | |
| 2420 private void showPastePopup(int xDip, int yDip) { | 2409 private void showPastePopup(int xDip, int yDip) { |
| 2421 if (!mHasInsertion || !canPaste()) return; | 2410 if (!mHasInsertion || !canPaste()) return; |
| 2422 final float contentOffsetYPix = mRenderCoordinates.getContentOffsetYPix(
); | 2411 final float contentOffsetYPix = mRenderCoordinates.getContentOffsetYPix(
); |
| 2423 getPastePopup().showAt( | 2412 getPastePopup().showAt( |
| 2424 (int) mRenderCoordinates.fromDipToPix(xDip), | 2413 (int) mRenderCoordinates.fromDipToPix(xDip), |
| 2425 (int) (mRenderCoordinates.fromDipToPix(yDip) + contentOffsetYPix)); | 2414 (int) (mRenderCoordinates.fromDipToPix(yDip) + contentOffsetYPix)); |
| 2426 } | 2415 } |
| 2427 | 2416 |
| 2428 private PastePopupMenu getPastePopup() { | 2417 private PastePopupMenu getPastePopup() { |
| 2429 if (mPastePopupMenu == null) { | 2418 if (mPastePopupMenu == null) { |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3168 private native void nativeSetDoubleTapSupportEnabled( | 3157 private native void nativeSetDoubleTapSupportEnabled( |
| 3169 long nativeContentViewCoreImpl, boolean enabled); | 3158 long nativeContentViewCoreImpl, boolean enabled); |
| 3170 | 3159 |
| 3171 private native void nativeSetMultiTouchZoomSupportEnabled( | 3160 private native void nativeSetMultiTouchZoomSupportEnabled( |
| 3172 long nativeContentViewCoreImpl, boolean enabled); | 3161 long nativeContentViewCoreImpl, boolean enabled); |
| 3173 | 3162 |
| 3174 private native void nativeSelectPopupMenuItems(long nativeContentViewCoreImp
l, int[] indices); | 3163 private native void nativeSelectPopupMenuItems(long nativeContentViewCoreImp
l, int[] indices); |
| 3175 | 3164 |
| 3176 private native void nativeClearHistory(long nativeContentViewCoreImpl); | 3165 private native void nativeClearHistory(long nativeContentViewCoreImpl); |
| 3177 | 3166 |
| 3178 private native void nativeEvaluateJavaScript(long nativeContentViewCoreImpl, | |
| 3179 String script, JavaScriptCallback callback, boolean startRenderer); | |
| 3180 | |
| 3181 private native void nativePostMessageToFrame(long nativeContentViewCoreImpl,
String frameId, | 3167 private native void nativePostMessageToFrame(long nativeContentViewCoreImpl,
String frameId, |
| 3182 String message, String sourceOrigin, String targetOrigin); | 3168 String message, String sourceOrigin, String targetOrigin); |
| 3183 | 3169 |
| 3184 private native long nativeGetNativeImeAdapter(long nativeContentViewCoreImpl
); | 3170 private native long nativeGetNativeImeAdapter(long nativeContentViewCoreImpl
); |
| 3185 | 3171 |
| 3186 private native int nativeGetCurrentRenderProcessId(long nativeContentViewCor
eImpl); | 3172 private native int nativeGetCurrentRenderProcessId(long nativeContentViewCor
eImpl); |
| 3187 | 3173 |
| 3188 private native void nativeSetUseDesktopUserAgent(long nativeContentViewCoreI
mpl, | 3174 private native void nativeSetUseDesktopUserAgent(long nativeContentViewCoreI
mpl, |
| 3189 boolean enabled, boolean reloadOnChange); | 3175 boolean enabled, boolean reloadOnChange); |
| 3190 | 3176 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3212 private native void nativeWasResized(long nativeContentViewCoreImpl); | 3198 private native void nativeWasResized(long nativeContentViewCoreImpl); |
| 3213 | 3199 |
| 3214 private native void nativeSetAccessibilityEnabled( | 3200 private native void nativeSetAccessibilityEnabled( |
| 3215 long nativeContentViewCoreImpl, boolean enabled); | 3201 long nativeContentViewCoreImpl, boolean enabled); |
| 3216 | 3202 |
| 3217 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp
l, | 3203 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp
l, |
| 3218 int x, int y, int w, int h); | 3204 int x, int y, int w, int h); |
| 3219 | 3205 |
| 3220 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl
, boolean opaque); | 3206 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl
, boolean opaque); |
| 3221 } | 3207 } |
| OLD | NEW |