| 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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) { |
| 1693 if (getContentViewClient().shouldOverrideKeyEvent(event)) { | 1697 if (getContentViewClient().shouldOverrideKeyEvent(event)) { |
| 1694 return mContainerViewInternals.super_dispatchKeyEvent(event); | 1698 return mContainerViewInternals.super_dispatchKeyEvent(event); |
| 1695 } | 1699 } |
| 1696 | 1700 |
| 1701 if (GamepadAdapter.getInstance().handleKeyEvent(event)) return true; |
| 1702 |
| 1697 if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_CENTER) { | 1703 if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_CENTER) { |
| 1698 showImeIfNeeded(); | 1704 showImeIfNeeded(); |
| 1699 // Event is not consumed here, because ImeAdapter might interpret | 1705 // Event is not consumed here, because ImeAdapter might interpret |
| 1700 // it as "Enter". | 1706 // it as "Enter". |
| 1701 // showImeIfNeeded respects the policy of | 1707 // showImeIfNeeded respects the policy of |
| 1702 // InputMethodService.onEvaluateInputViewShown. So IME will not be | 1708 // InputMethodService.onEvaluateInputViewShown. So IME will not be |
| 1703 // shown if you have QWERTY physical keyboard attached. | 1709 // shown if you have QWERTY physical keyboard attached. |
| 1704 // Also, IME will not be shown if the focus is not on the input | 1710 // Also, IME will not be shown if the focus is not on the input |
| 1705 // field. See ImeAdapter.attachAndShowIfNeeded | 1711 // field. See ImeAdapter.attachAndShowIfNeeded |
| 1706 } | 1712 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1748 mFakeMouseMoveRunnable = new Runnable() { | 1754 mFakeMouseMoveRunnable = new Runnable() { |
| 1749 @Override | 1755 @Override |
| 1750 public void run() { | 1756 public void run() { |
| 1751 onHoverEvent(eventFakeMouseMove); | 1757 onHoverEvent(eventFakeMouseMove); |
| 1752 } | 1758 } |
| 1753 }; | 1759 }; |
| 1754 mContainerView.postDelayed(mFakeMouseMoveRunnable, 250); | 1760 mContainerView.postDelayed(mFakeMouseMoveRunnable, 250); |
| 1755 return true; | 1761 return true; |
| 1756 } | 1762 } |
| 1757 } | 1763 } |
| 1764 |
| 1765 if (GamepadAdapter.getInstance().handleMotionEvent(event)) return true; |
| 1766 |
| 1758 return mContainerViewInternals.super_onGenericMotionEvent(event); | 1767 return mContainerViewInternals.super_onGenericMotionEvent(event); |
| 1759 } | 1768 } |
| 1760 | 1769 |
| 1761 /** | 1770 /** |
| 1762 * @see View#scrollBy(int, int) | 1771 * @see View#scrollBy(int, int) |
| 1763 * Currently the ContentView scrolling happens in the native side. In | 1772 * 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() | 1773 * 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 | 1774 * are overridden, so that View's mScrollX and mScrollY will be unchanged at |
| 1766 * (0, 0). This is critical for drawing ContentView correctly. | 1775 * (0, 0). This is critical for drawing ContentView correctly. |
| 1767 */ | 1776 */ |
| (...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3290 boolean enableHiding, boolean enableShowing, boolean animate); | 3299 boolean enableHiding, boolean enableShowing, boolean animate); |
| 3291 | 3300 |
| 3292 private native void nativeShowImeIfNeeded(long nativeContentViewCoreImpl); | 3301 private native void nativeShowImeIfNeeded(long nativeContentViewCoreImpl); |
| 3293 | 3302 |
| 3294 private native void nativeSetAccessibilityEnabled( | 3303 private native void nativeSetAccessibilityEnabled( |
| 3295 long nativeContentViewCoreImpl, boolean enabled); | 3304 long nativeContentViewCoreImpl, boolean enabled); |
| 3296 | 3305 |
| 3297 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp
l, | 3306 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp
l, |
| 3298 int x, int y, int w, int h); | 3307 int x, int y, int w, int h); |
| 3299 } | 3308 } |
| OLD | NEW |