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.ContentResolver; | 10 import android.content.ContentResolver; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 import org.chromium.base.CalledByNative; | 52 import org.chromium.base.CalledByNative; |
53 import org.chromium.base.CommandLine; | 53 import org.chromium.base.CommandLine; |
54 import org.chromium.base.JNINamespace; | 54 import org.chromium.base.JNINamespace; |
55 import org.chromium.base.ObserverList; | 55 import org.chromium.base.ObserverList; |
56 import org.chromium.base.ObserverList.RewindableIterator; | 56 import org.chromium.base.ObserverList.RewindableIterator; |
57 import org.chromium.base.TraceEvent; | 57 import org.chromium.base.TraceEvent; |
58 import org.chromium.content.R; | 58 import org.chromium.content.R; |
59 import org.chromium.content.browser.accessibility.AccessibilityInjector; | 59 import org.chromium.content.browser.accessibility.AccessibilityInjector; |
60 import org.chromium.content.browser.accessibility.BrowserAccessibilityManager; | 60 import org.chromium.content.browser.accessibility.BrowserAccessibilityManager; |
61 import org.chromium.content.browser.input.AdapterInputConnection; | 61 import org.chromium.content.browser.input.AdapterInputConnection; |
62 import org.chromium.content.browser.input.GamepadAdapter; | |
62 import org.chromium.content.browser.input.HandleView; | 63 import org.chromium.content.browser.input.HandleView; |
63 import org.chromium.content.browser.input.ImeAdapter; | 64 import org.chromium.content.browser.input.ImeAdapter; |
64 import org.chromium.content.browser.input.ImeAdapter.AdapterInputConnectionFacto ry; | 65 import org.chromium.content.browser.input.ImeAdapter.AdapterInputConnectionFacto ry; |
65 import org.chromium.content.browser.input.InputMethodManagerWrapper; | 66 import org.chromium.content.browser.input.InputMethodManagerWrapper; |
66 import org.chromium.content.browser.input.InsertionHandleController; | 67 import org.chromium.content.browser.input.InsertionHandleController; |
67 import org.chromium.content.browser.input.SelectPopupDialog; | 68 import org.chromium.content.browser.input.SelectPopupDialog; |
68 import org.chromium.content.browser.input.SelectPopupItem; | 69 import org.chromium.content.browser.input.SelectPopupItem; |
69 import org.chromium.content.browser.input.SelectionHandleController; | 70 import org.chromium.content.browser.input.SelectionHandleController; |
70 import org.chromium.content.common.ContentSwitches; | 71 import org.chromium.content.common.ContentSwitches; |
71 import org.chromium.content_public.browser.GestureStateListener; | 72 import org.chromium.content_public.browser.GestureStateListener; |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
440 deviceScaleFactor = Float.valueOf(forceScaleFactor); | 441 deviceScaleFactor = Float.valueOf(forceScaleFactor); |
441 } | 442 } |
442 mRenderCoordinates.setDeviceScaleFactor(deviceScaleFactor); | 443 mRenderCoordinates.setDeviceScaleFactor(deviceScaleFactor); |
443 mStartHandlePoint = mRenderCoordinates.createNormalizedPoint(); | 444 mStartHandlePoint = mRenderCoordinates.createNormalizedPoint(); |
444 mEndHandlePoint = mRenderCoordinates.createNormalizedPoint(); | 445 mEndHandlePoint = mRenderCoordinates.createNormalizedPoint(); |
445 mInsertionHandlePoint = mRenderCoordinates.createNormalizedPoint(); | 446 mInsertionHandlePoint = mRenderCoordinates.createNormalizedPoint(); |
446 mAccessibilityManager = (AccessibilityManager) | 447 mAccessibilityManager = (AccessibilityManager) |
447 getContext().getSystemService(Context.ACCESSIBILITY_SERVICE); | 448 getContext().getSystemService(Context.ACCESSIBILITY_SERVICE); |
448 mGestureStateListeners = new ObserverList<GestureStateListener>(); | 449 mGestureStateListeners = new ObserverList<GestureStateListener>(); |
449 mGestureStateListenersIterator = mGestureStateListeners.rewindableIterat or(); | 450 mGestureStateListenersIterator = mGestureStateListeners.rewindableIterat or(); |
451 GamepadAdapter.initialize(context); | |
450 } | 452 } |
451 | 453 |
452 /** | 454 /** |
453 * @return The context used for creating this ContentViewCore. | 455 * @return The context used for creating this ContentViewCore. |
454 */ | 456 */ |
455 @CalledByNative | 457 @CalledByNative |
456 public Context getContext() { | 458 public Context getContext() { |
457 return mContext; | 459 return mContext; |
458 } | 460 } |
459 | 461 |
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1364 /** | 1366 /** |
1365 * To be called when the ContentView is shown. | 1367 * To be called when the ContentView is shown. |
1366 */ | 1368 */ |
1367 public void onShow() { | 1369 public void onShow() { |
1368 assert mNativeContentViewCore != 0; | 1370 assert mNativeContentViewCore != 0; |
1369 if (!mInForeground) { | 1371 if (!mInForeground) { |
1370 int pid = nativeGetCurrentRenderProcessId(mNativeContentViewCore); | 1372 int pid = nativeGetCurrentRenderProcessId(mNativeContentViewCore); |
1371 ChildProcessLauncher.getBindingManager().setInForeground(pid, true); | 1373 ChildProcessLauncher.getBindingManager().setInForeground(pid, true); |
1372 } | 1374 } |
1373 mInForeground = true; | 1375 mInForeground = true; |
1376 GamepadAdapter.getInstance().resume(); | |
1374 nativeOnShow(mNativeContentViewCore); | 1377 nativeOnShow(mNativeContentViewCore); |
1375 setAccessibilityState(mAccessibilityManager.isEnabled()); | 1378 setAccessibilityState(mAccessibilityManager.isEnabled()); |
1376 } | 1379 } |
1377 | 1380 |
1378 /** | 1381 /** |
1379 * To be called when the ContentView is hidden. | 1382 * To be called when the ContentView is hidden. |
1380 */ | 1383 */ |
1381 public void onHide() { | 1384 public void onHide() { |
1382 assert mNativeContentViewCore != 0; | 1385 assert mNativeContentViewCore != 0; |
1383 if (mInForeground) { | 1386 if (mInForeground) { |
1384 int pid = nativeGetCurrentRenderProcessId(mNativeContentViewCore); | 1387 int pid = nativeGetCurrentRenderProcessId(mNativeContentViewCore); |
1385 ChildProcessLauncher.getBindingManager().setInForeground(pid, false) ; | 1388 ChildProcessLauncher.getBindingManager().setInForeground(pid, false) ; |
1386 } | 1389 } |
1387 mInForeground = false; | 1390 mInForeground = false; |
1388 hidePopupDialog(); | 1391 hidePopupDialog(); |
1389 setInjectedAccessibility(false); | 1392 setInjectedAccessibility(false); |
1393 GamepadAdapter.getInstance().pause(); | |
1390 nativeOnHide(mNativeContentViewCore); | 1394 nativeOnHide(mNativeContentViewCore); |
1391 } | 1395 } |
1392 | 1396 |
1393 /** | 1397 /** |
1394 * Return the ContentSettings object used to retrieve the settings for this | 1398 * Return the ContentSettings object used to retrieve the settings for this |
1395 * ContentViewCore. For modifications, ChromeNativePreferences is to be used . | 1399 * ContentViewCore. For modifications, ChromeNativePreferences is to be used . |
1396 * @return A ContentSettings object that can be used to retrieve this | 1400 * @return A ContentSettings object that can be used to retrieve this |
1397 * ContentViewCore's settings. | 1401 * ContentViewCore's settings. |
1398 */ | 1402 */ |
1399 public ContentSettings getContentSettings() { | 1403 public ContentSettings getContentSettings() { |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1683 return mContainerViewInternals.super_dispatchKeyEventPreIme(event); | 1687 return mContainerViewInternals.super_dispatchKeyEventPreIme(event); |
1684 } finally { | 1688 } finally { |
1685 TraceEvent.end(); | 1689 TraceEvent.end(); |
1686 } | 1690 } |
1687 } | 1691 } |
1688 | 1692 |
1689 /** | 1693 /** |
1690 * @see View#dispatchKeyEvent(KeyEvent) | 1694 * @see View#dispatchKeyEvent(KeyEvent) |
1691 */ | 1695 */ |
1692 public boolean dispatchKeyEvent(KeyEvent event) { | 1696 public boolean dispatchKeyEvent(KeyEvent event) { |
1697 | |
bulach
2014/03/05 12:34:39
nit: spurious?
| |
1693 if (getContentViewClient().shouldOverrideKeyEvent(event)) { | 1698 if (getContentViewClient().shouldOverrideKeyEvent(event)) { |
1694 return mContainerViewInternals.super_dispatchKeyEvent(event); | 1699 return mContainerViewInternals.super_dispatchKeyEvent(event); |
1695 } | 1700 } |
1696 | 1701 |
1702 if (GamepadAdapter.getInstance().handleKeyEvent(event)) return true; | |
1703 | |
1697 if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_CENTER) { | 1704 if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_CENTER) { |
1698 showImeIfNeeded(); | 1705 showImeIfNeeded(); |
1699 // Event is not consumed here, because ImeAdapter might interpret | 1706 // Event is not consumed here, because ImeAdapter might interpret |
1700 // it as "Enter". | 1707 // it as "Enter". |
1701 // showImeIfNeeded respects the policy of | 1708 // showImeIfNeeded respects the policy of |
1702 // InputMethodService.onEvaluateInputViewShown. So IME will not be | 1709 // InputMethodService.onEvaluateInputViewShown. So IME will not be |
1703 // shown if you have QWERTY physical keyboard attached. | 1710 // shown if you have QWERTY physical keyboard attached. |
1704 // Also, IME will not be shown if the focus is not on the input | 1711 // Also, IME will not be shown if the focus is not on the input |
1705 // field. See ImeAdapter.attachAndShowIfNeeded | 1712 // field. See ImeAdapter.attachAndShowIfNeeded |
1706 } | 1713 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1748 mFakeMouseMoveRunnable = new Runnable() { | 1755 mFakeMouseMoveRunnable = new Runnable() { |
1749 @Override | 1756 @Override |
1750 public void run() { | 1757 public void run() { |
1751 onHoverEvent(eventFakeMouseMove); | 1758 onHoverEvent(eventFakeMouseMove); |
1752 } | 1759 } |
1753 }; | 1760 }; |
1754 mContainerView.postDelayed(mFakeMouseMoveRunnable, 250); | 1761 mContainerView.postDelayed(mFakeMouseMoveRunnable, 250); |
1755 return true; | 1762 return true; |
1756 } | 1763 } |
1757 } | 1764 } |
1765 | |
1766 if (GamepadAdapter.getInstance().handleMotionEvent(event)) return true; | |
1767 | |
1758 return mContainerViewInternals.super_onGenericMotionEvent(event); | 1768 return mContainerViewInternals.super_onGenericMotionEvent(event); |
1759 } | 1769 } |
1760 | 1770 |
1761 /** | 1771 /** |
1762 * @see View#scrollBy(int, int) | 1772 * @see View#scrollBy(int, int) |
1763 * Currently the ContentView scrolling happens in the native side. In | 1773 * Currently the ContentView scrolling happens in the native side. In |
1764 * the Java view system, it is always pinned at (0, 0). scrollBy() and scrol lTo() | 1774 * the Java view system, it is always pinned at (0, 0). scrollBy() and scrol lTo() |
1765 * are overridden, so that View's mScrollX and mScrollY will be unchanged at | 1775 * are overridden, so that View's mScrollX and mScrollY will be unchanged at |
1766 * (0, 0). This is critical for drawing ContentView correctly. | 1776 * (0, 0). This is critical for drawing ContentView correctly. |
1767 */ | 1777 */ |
(...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3290 boolean enableHiding, boolean enableShowing, boolean animate); | 3300 boolean enableHiding, boolean enableShowing, boolean animate); |
3291 | 3301 |
3292 private native void nativeShowImeIfNeeded(long nativeContentViewCoreImpl); | 3302 private native void nativeShowImeIfNeeded(long nativeContentViewCoreImpl); |
3293 | 3303 |
3294 private native void nativeSetAccessibilityEnabled( | 3304 private native void nativeSetAccessibilityEnabled( |
3295 long nativeContentViewCoreImpl, boolean enabled); | 3305 long nativeContentViewCoreImpl, boolean enabled); |
3296 | 3306 |
3297 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l, | 3307 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l, |
3298 int x, int y, int w, int h); | 3308 int x, int y, int w, int h); |
3299 } | 3309 } |
OLD | NEW |