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

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

Issue 133943002: Gamepad API support for chrome on android (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 6 years, 10 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 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.app.Activity; 7 import android.app.Activity;
8 import android.app.SearchManager; 8 import android.app.SearchManager;
9 import android.content.ContentResolver; 9 import android.content.ContentResolver;
10 import android.content.Context; 10 import android.content.Context;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 private final Map<String, Object> mJavaScriptInterfaces = new HashMap<String , Object>(); 122 private final Map<String, Object> mJavaScriptInterfaces = new HashMap<String , Object>();
123 123
124 // Additionally, we keep track of all Java bound JS objects that are in use on the 124 // Additionally, we keep track of all Java bound JS objects that are in use on the
125 // current page to ensure that they are not garbage collected until the page is 125 // current page to ensure that they are not garbage collected until the page is
126 // navigated. This includes interface objects that have been removed 126 // navigated. This includes interface objects that have been removed
127 // via the removeJavaScriptInterface API and transient objects returned from methods 127 // via the removeJavaScriptInterface API and transient objects returned from methods
128 // on the interface object. Note we use HashSet rather than Set as the nativ e side 128 // on the interface object. Note we use HashSet rather than Set as the nativ e side
129 // expects HashSet (no bindings for interfaces). 129 // expects HashSet (no bindings for interfaces).
130 private final HashSet<Object> mRetainedJavaScriptObjects = new HashSet<Objec t>(); 130 private final HashSet<Object> mRetainedJavaScriptObjects = new HashSet<Objec t>();
131 131
132 private GamepadList mGamepadList;
133
132 /** 134 /**
133 * Interface that consumers of {@link ContentViewCore} must implement to all ow the proper 135 * Interface that consumers of {@link ContentViewCore} must implement to all ow the proper
134 * dispatching of view methods through the containing view. 136 * dispatching of view methods through the containing view.
135 * 137 *
136 * <p> 138 * <p>
137 * All methods with the "super_" prefix should be routed to the parent of th e 139 * All methods with the "super_" prefix should be routed to the parent of th e
138 * implementing container view. 140 * implementing container view.
139 */ 141 */
140 @SuppressWarnings("javadoc") 142 @SuppressWarnings("javadoc")
141 public interface InternalAccessDelegate { 143 public interface InternalAccessDelegate {
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 mRenderCoordinates = new RenderCoordinates(); 476 mRenderCoordinates = new RenderCoordinates();
475 mRenderCoordinates.setDeviceScaleFactor( 477 mRenderCoordinates.setDeviceScaleFactor(
476 getContext().getResources().getDisplayMetrics().density); 478 getContext().getResources().getDisplayMetrics().density);
477 mStartHandlePoint = mRenderCoordinates.createNormalizedPoint(); 479 mStartHandlePoint = mRenderCoordinates.createNormalizedPoint();
478 mEndHandlePoint = mRenderCoordinates.createNormalizedPoint(); 480 mEndHandlePoint = mRenderCoordinates.createNormalizedPoint();
479 mInsertionHandlePoint = mRenderCoordinates.createNormalizedPoint(); 481 mInsertionHandlePoint = mRenderCoordinates.createNormalizedPoint();
480 mAccessibilityManager = (AccessibilityManager) 482 mAccessibilityManager = (AccessibilityManager)
481 getContext().getSystemService(Context.ACCESSIBILITY_SERVICE); 483 getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
482 mGestureStateListeners = new ObserverList<GestureStateListener>(); 484 mGestureStateListeners = new ObserverList<GestureStateListener>();
483 mGestureStateListenersIterator = mGestureStateListeners.rewindableIterat or(); 485 mGestureStateListenersIterator = mGestureStateListeners.rewindableIterat or();
486 mGamepadList = GamepadList.createInstance(context);
484 } 487 }
485 488
486 /** 489 /**
487 * @return The context used for creating this ContentViewCore. 490 * @return The context used for creating this ContentViewCore.
488 */ 491 */
489 @CalledByNative 492 @CalledByNative
490 public Context getContext() { 493 public Context getContext() {
491 return mContext; 494 return mContext;
492 } 495 }
493 496
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1822 return mContainerViewInternals.super_dispatchKeyEventPreIme(event); 1825 return mContainerViewInternals.super_dispatchKeyEventPreIme(event);
1823 } finally { 1826 } finally {
1824 TraceEvent.end(); 1827 TraceEvent.end();
1825 } 1828 }
1826 } 1829 }
1827 1830
1828 /** 1831 /**
1829 * @see View#dispatchKeyEvent(KeyEvent) 1832 * @see View#dispatchKeyEvent(KeyEvent)
1830 */ 1833 */
1831 public boolean dispatchKeyEvent(KeyEvent event) { 1834 public boolean dispatchKeyEvent(KeyEvent event) {
1835 if (mGamepadList.isGamepadAccessed() && mGamepadList.isGamepadEvent(even t)) {
kbalazs 2014/02/20 00:48:24 I would move both checks to the callee and remove
1836 return mGamepadList.updateForEvent(event);
1837 }
1832 if (getContentViewClient().shouldOverrideKeyEvent(event)) { 1838 if (getContentViewClient().shouldOverrideKeyEvent(event)) {
1833 return mContainerViewInternals.super_dispatchKeyEvent(event); 1839 return mContainerViewInternals.super_dispatchKeyEvent(event);
1834 } 1840 }
1835 1841
1836 if (mImeAdapter.dispatchKeyEvent(event)) return true; 1842 if (mImeAdapter.dispatchKeyEvent(event)) return true;
1837 1843
1838 return mContainerViewInternals.super_dispatchKeyEvent(event); 1844 return mContainerViewInternals.super_dispatchKeyEvent(event);
1839 } 1845 }
1840 1846
1847 public void onPause() {
1848 if (mGamepadList != null) {
1849 mGamepadList.onPause();
1850 }
1851 }
1852
1853 public void onResume() {
1854 if (mGamepadList != null) {
1855 mGamepadList.onResume();
1856 }
1857 }
1858
1841 /** 1859 /**
1842 * @see View#onHoverEvent(MotionEvent) 1860 * @see View#onHoverEvent(MotionEvent)
1843 * Mouse move events are sent on hover enter, hover move and hover exit. 1861 * Mouse move events are sent on hover enter, hover move and hover exit.
1844 * They are sent on hover exit because sometimes it acts as both a hover 1862 * They are sent on hover exit because sometimes it acts as both a hover
1845 * move and hover exit. 1863 * move and hover exit.
1846 */ 1864 */
1847 public boolean onHoverEvent(MotionEvent event) { 1865 public boolean onHoverEvent(MotionEvent event) {
1848 TraceEvent.begin("onHoverEvent"); 1866 TraceEvent.begin("onHoverEvent");
1849 mContainerView.removeCallbacks(mFakeMouseMoveRunnable); 1867 mContainerView.removeCallbacks(mFakeMouseMoveRunnable);
1850 if (mBrowserAccessibilityManager != null) { 1868 if (mBrowserAccessibilityManager != null) {
1851 return mBrowserAccessibilityManager.onHoverEvent(event); 1869 return mBrowserAccessibilityManager.onHoverEvent(event);
1852 } 1870 }
1853 if (mNativeContentViewCore != 0) { 1871 if (mNativeContentViewCore != 0) {
1854 nativeSendMouseMoveEvent(mNativeContentViewCore, event.getEventTime( ), 1872 nativeSendMouseMoveEvent(mNativeContentViewCore, event.getEventTime( ),
1855 event.getX(), event.getY()); 1873 event.getX(), event.getY());
1856 } 1874 }
1857 TraceEvent.end("onHoverEvent"); 1875 TraceEvent.end("onHoverEvent");
1858 return true; 1876 return true;
1859 } 1877 }
1860 1878
1861 /** 1879 /**
1862 * @see View#onGenericMotionEvent(MotionEvent) 1880 * @see View#onGenericMotionEvent(MotionEvent)
1863 */ 1881 */
1864 public boolean onGenericMotionEvent(MotionEvent event) { 1882 public boolean onGenericMotionEvent(MotionEvent event) {
1883 if (mGamepadList.isGamepadAccessed() && mGamepadList.isGamepadEvent(even t)) {
kbalazs 2014/02/20 00:48:24 Ditto.
1884 return mGamepadList.updateForEvent(event);
1885 }
1865 if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { 1886 if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
1866 switch (event.getAction()) { 1887 switch (event.getAction()) {
1867 case MotionEvent.ACTION_SCROLL: 1888 case MotionEvent.ACTION_SCROLL:
1868 nativeSendMouseWheelEvent(mNativeContentViewCore, event.getE ventTime(), 1889 nativeSendMouseWheelEvent(mNativeContentViewCore, event.getE ventTime(),
1869 event.getX(), event.getY(), 1890 event.getX(), event.getY(),
1870 event.getAxisValue(MotionEvent.AXIS_VSCROLL)); 1891 event.getAxisValue(MotionEvent.AXIS_VSCROLL));
1871 1892
1872 mContainerView.removeCallbacks(mFakeMouseMoveRunnable); 1893 mContainerView.removeCallbacks(mFakeMouseMoveRunnable);
1873 // Send a delayed onMouseMove event so that we end 1894 // Send a delayed onMouseMove event so that we end
1874 // up hovering over the right position after the scroll. 1895 // up hovering over the right position after the scroll.
(...skipping 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after
3488 3509
3489 private native void nativeSendSingleTapUma(long nativeContentViewCoreImpl, 3510 private native void nativeSendSingleTapUma(long nativeContentViewCoreImpl,
3490 int type, int count); 3511 int type, int count);
3491 3512
3492 private native void nativeSendActionAfterDoubleTapUma(long nativeContentView CoreImpl, 3513 private native void nativeSendActionAfterDoubleTapUma(long nativeContentView CoreImpl,
3493 int type, boolean hasDelay, int count); 3514 int type, boolean hasDelay, int count);
3494 3515
3495 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l, 3516 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l,
3496 int x, int y, int w, int h); 3517 int x, int y, int w, int h);
3497 } 3518 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698