| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 4 // found in the LICENSE file. |
| 4 | 5 |
| 5 package org.chromium.content.browser; | 6 package org.chromium.content.browser; |
| 6 | 7 |
| 7 import android.app.Activity; | 8 import android.app.Activity; |
| 8 import android.app.SearchManager; | 9 import android.app.SearchManager; |
| 9 import android.content.ContentResolver; | 10 import android.content.ContentResolver; |
| 10 import android.content.Context; | 11 import android.content.Context; |
| 11 import android.content.Intent; | 12 import android.content.Intent; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 private final Map<String, Object> mJavaScriptInterfaces = new HashMap<String
, Object>(); | 120 private final Map<String, Object> mJavaScriptInterfaces = new HashMap<String
, Object>(); |
| 120 | 121 |
| 121 // Additionally, we keep track of all Java bound JS objects that are in use
on the | 122 // Additionally, we keep track of all Java bound JS objects that are in use
on the |
| 122 // current page to ensure that they are not garbage collected until the page
is | 123 // current page to ensure that they are not garbage collected until the page
is |
| 123 // navigated. This includes interface objects that have been removed | 124 // navigated. This includes interface objects that have been removed |
| 124 // via the removeJavaScriptInterface API and transient objects returned from
methods | 125 // via the removeJavaScriptInterface API and transient objects returned from
methods |
| 125 // on the interface object. Note we use HashSet rather than Set as the nativ
e side | 126 // on the interface object. Note we use HashSet rather than Set as the nativ
e side |
| 126 // expects HashSet (no bindings for interfaces). | 127 // expects HashSet (no bindings for interfaces). |
| 127 private final HashSet<Object> mRetainedJavaScriptObjects = new HashSet<Objec
t>(); | 128 private final HashSet<Object> mRetainedJavaScriptObjects = new HashSet<Objec
t>(); |
| 128 | 129 |
| 130 private GamepadList mGamepadList; |
| 131 |
| 129 /** | 132 /** |
| 130 * Interface that consumers of {@link ContentViewCore} must implement to all
ow the proper | 133 * Interface that consumers of {@link ContentViewCore} must implement to all
ow the proper |
| 131 * dispatching of view methods through the containing view. | 134 * dispatching of view methods through the containing view. |
| 132 * | 135 * |
| 133 * <p> | 136 * <p> |
| 134 * All methods with the "super_" prefix should be routed to the parent of th
e | 137 * All methods with the "super_" prefix should be routed to the parent of th
e |
| 135 * implementing container view. | 138 * implementing container view. |
| 136 */ | 139 */ |
| 137 @SuppressWarnings("javadoc") | 140 @SuppressWarnings("javadoc") |
| 138 public interface InternalAccessDelegate { | 141 public interface InternalAccessDelegate { |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 mAdapterInputConnectionFactory = new AdapterInputConnectionFactory(); | 500 mAdapterInputConnectionFactory = new AdapterInputConnectionFactory(); |
| 498 | 501 |
| 499 mRenderCoordinates = new RenderCoordinates(); | 502 mRenderCoordinates = new RenderCoordinates(); |
| 500 mRenderCoordinates.setDeviceScaleFactor( | 503 mRenderCoordinates.setDeviceScaleFactor( |
| 501 getContext().getResources().getDisplayMetrics().density); | 504 getContext().getResources().getDisplayMetrics().density); |
| 502 mStartHandlePoint = mRenderCoordinates.createNormalizedPoint(); | 505 mStartHandlePoint = mRenderCoordinates.createNormalizedPoint(); |
| 503 mEndHandlePoint = mRenderCoordinates.createNormalizedPoint(); | 506 mEndHandlePoint = mRenderCoordinates.createNormalizedPoint(); |
| 504 mInsertionHandlePoint = mRenderCoordinates.createNormalizedPoint(); | 507 mInsertionHandlePoint = mRenderCoordinates.createNormalizedPoint(); |
| 505 mAccessibilityManager = (AccessibilityManager) | 508 mAccessibilityManager = (AccessibilityManager) |
| 506 getContext().getSystemService(Context.ACCESSIBILITY_SERVICE); | 509 getContext().getSystemService(Context.ACCESSIBILITY_SERVICE); |
| 510 mGamepadList = GamepadList.createInstance(context); |
| 507 } | 511 } |
| 508 | 512 |
| 509 /** | 513 /** |
| 510 * @return The context used for creating this ContentViewCore. | 514 * @return The context used for creating this ContentViewCore. |
| 511 */ | 515 */ |
| 512 @CalledByNative | 516 @CalledByNative |
| 513 public Context getContext() { | 517 public Context getContext() { |
| 514 return mContext; | 518 return mContext; |
| 515 } | 519 } |
| 516 | 520 |
| (...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1850 return mContainerViewInternals.super_dispatchKeyEventPreIme(event); | 1854 return mContainerViewInternals.super_dispatchKeyEventPreIme(event); |
| 1851 } finally { | 1855 } finally { |
| 1852 TraceEvent.end(); | 1856 TraceEvent.end(); |
| 1853 } | 1857 } |
| 1854 } | 1858 } |
| 1855 | 1859 |
| 1856 /** | 1860 /** |
| 1857 * @see View#dispatchKeyEvent(KeyEvent) | 1861 * @see View#dispatchKeyEvent(KeyEvent) |
| 1858 */ | 1862 */ |
| 1859 public boolean dispatchKeyEvent(KeyEvent event) { | 1863 public boolean dispatchKeyEvent(KeyEvent event) { |
| 1864 if (mGamepadList.isGamepadAccessed() && mGamepadList.isGamepadEvent(even
t)) { |
| 1865 return mGamepadList.updateForEvent(event); |
| 1866 } |
| 1860 if (getContentViewClient().shouldOverrideKeyEvent(event)) { | 1867 if (getContentViewClient().shouldOverrideKeyEvent(event)) { |
| 1861 return mContainerViewInternals.super_dispatchKeyEvent(event); | 1868 return mContainerViewInternals.super_dispatchKeyEvent(event); |
| 1862 } | 1869 } |
| 1863 | 1870 |
| 1864 if (mImeAdapter.dispatchKeyEvent(event)) return true; | 1871 if (mImeAdapter.dispatchKeyEvent(event)) return true; |
| 1865 | 1872 |
| 1866 return mContainerViewInternals.super_dispatchKeyEvent(event); | 1873 return mContainerViewInternals.super_dispatchKeyEvent(event); |
| 1867 } | 1874 } |
| 1868 | 1875 |
| 1876 public void onPause() { |
| 1877 if (mGamepadList != null) { |
| 1878 mGamepadList.onPause(); |
| 1879 } |
| 1880 } |
| 1881 |
| 1882 public void onResume() { |
| 1883 if (mGamepadList != null) { |
| 1884 mGamepadList.onResume(); |
| 1885 } |
| 1886 } |
| 1887 |
| 1869 /** | 1888 /** |
| 1870 * @see View#onHoverEvent(MotionEvent) | 1889 * @see View#onHoverEvent(MotionEvent) |
| 1871 * Mouse move events are sent on hover enter, hover move and hover exit. | 1890 * Mouse move events are sent on hover enter, hover move and hover exit. |
| 1872 * They are sent on hover exit because sometimes it acts as both a hover | 1891 * They are sent on hover exit because sometimes it acts as both a hover |
| 1873 * move and hover exit. | 1892 * move and hover exit. |
| 1874 */ | 1893 */ |
| 1875 public boolean onHoverEvent(MotionEvent event) { | 1894 public boolean onHoverEvent(MotionEvent event) { |
| 1876 TraceEvent.begin("onHoverEvent"); | 1895 TraceEvent.begin("onHoverEvent"); |
| 1877 mContainerView.removeCallbacks(mFakeMouseMoveRunnable); | 1896 mContainerView.removeCallbacks(mFakeMouseMoveRunnable); |
| 1878 if (mBrowserAccessibilityManager != null) { | 1897 if (mBrowserAccessibilityManager != null) { |
| 1879 return mBrowserAccessibilityManager.onHoverEvent(event); | 1898 return mBrowserAccessibilityManager.onHoverEvent(event); |
| 1880 } | 1899 } |
| 1881 if (mNativeContentViewCore != 0) { | 1900 if (mNativeContentViewCore != 0) { |
| 1882 nativeSendMouseMoveEvent(mNativeContentViewCore, event.getEventTime(
), | 1901 nativeSendMouseMoveEvent(mNativeContentViewCore, event.getEventTime(
), |
| 1883 event.getX(), event.getY()); | 1902 event.getX(), event.getY()); |
| 1884 } | 1903 } |
| 1885 TraceEvent.end("onHoverEvent"); | 1904 TraceEvent.end("onHoverEvent"); |
| 1886 return true; | 1905 return true; |
| 1887 } | 1906 } |
| 1888 | 1907 |
| 1889 /** | 1908 /** |
| 1890 * @see View#onGenericMotionEvent(MotionEvent) | 1909 * @see View#onGenericMotionEvent(MotionEvent) |
| 1891 */ | 1910 */ |
| 1892 public boolean onGenericMotionEvent(MotionEvent event) { | 1911 public boolean onGenericMotionEvent(MotionEvent event) { |
| 1912 if (mGamepadList.isGamepadAccessed() && mGamepadList.isGamepadEvent(even
t)) { |
| 1913 return mGamepadList.updateForEvent(event); |
| 1914 } |
| 1893 if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { | 1915 if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { |
| 1894 switch (event.getAction()) { | 1916 switch (event.getAction()) { |
| 1895 case MotionEvent.ACTION_SCROLL: | 1917 case MotionEvent.ACTION_SCROLL: |
| 1896 nativeSendMouseWheelEvent(mNativeContentViewCore, event.getE
ventTime(), | 1918 nativeSendMouseWheelEvent(mNativeContentViewCore, event.getE
ventTime(), |
| 1897 event.getX(), event.getY(), | 1919 event.getX(), event.getY(), |
| 1898 event.getAxisValue(MotionEvent.AXIS_VSCROLL)); | 1920 event.getAxisValue(MotionEvent.AXIS_VSCROLL)); |
| 1899 | 1921 |
| 1900 mContainerView.removeCallbacks(mFakeMouseMoveRunnable); | 1922 mContainerView.removeCallbacks(mFakeMouseMoveRunnable); |
| 1901 // Send a delayed onMouseMove event so that we end | 1923 // Send a delayed onMouseMove event so that we end |
| 1902 // up hovering over the right position after the scroll. | 1924 // up hovering over the right position after the scroll. |
| (...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3431 | 3453 |
| 3432 private native void nativeSendSingleTapUma(long nativeContentViewCoreImpl, | 3454 private native void nativeSendSingleTapUma(long nativeContentViewCoreImpl, |
| 3433 int type, int count); | 3455 int type, int count); |
| 3434 | 3456 |
| 3435 private native void nativeSendActionAfterDoubleTapUma(long nativeContentView
CoreImpl, | 3457 private native void nativeSendActionAfterDoubleTapUma(long nativeContentView
CoreImpl, |
| 3436 int type, boolean hasDelay, int count); | 3458 int type, boolean hasDelay, int count); |
| 3437 | 3459 |
| 3438 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp
l, | 3460 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp
l, |
| 3439 int x, int y, int w, int h); | 3461 int x, int y, int w, int h); |
| 3440 } | 3462 } |
| OLD | NEW |