| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.chrome.browser.tab; | 5 package org.chromium.chrome.browser.tab; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.app.Application; | 8 import android.app.Application; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.content.Intent; | 10 import android.content.Intent; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 import org.chromium.content_public.common.Referrer; | 107 import org.chromium.content_public.common.Referrer; |
| 108 import org.chromium.content_public.common.ResourceRequestBody; | 108 import org.chromium.content_public.common.ResourceRequestBody; |
| 109 import org.chromium.content_public.common.TopControlsState; | 109 import org.chromium.content_public.common.TopControlsState; |
| 110 import org.chromium.printing.PrintManagerDelegateImpl; | 110 import org.chromium.printing.PrintManagerDelegateImpl; |
| 111 import org.chromium.printing.PrintingController; | 111 import org.chromium.printing.PrintingController; |
| 112 import org.chromium.printing.PrintingControllerImpl; | 112 import org.chromium.printing.PrintingControllerImpl; |
| 113 import org.chromium.ui.WindowOpenDisposition; | 113 import org.chromium.ui.WindowOpenDisposition; |
| 114 import org.chromium.ui.base.DeviceFormFactor; | 114 import org.chromium.ui.base.DeviceFormFactor; |
| 115 import org.chromium.ui.base.LocalizationUtils; | 115 import org.chromium.ui.base.LocalizationUtils; |
| 116 import org.chromium.ui.base.PageTransition; | 116 import org.chromium.ui.base.PageTransition; |
| 117 import org.chromium.ui.base.ViewAndroidDelegate; |
| 117 import org.chromium.ui.base.WindowAndroid; | 118 import org.chromium.ui.base.WindowAndroid; |
| 118 | 119 |
| 119 import java.lang.ref.WeakReference; | 120 import java.lang.ref.WeakReference; |
| 120 import java.nio.ByteBuffer; | 121 import java.nio.ByteBuffer; |
| 121 import java.util.ArrayList; | 122 import java.util.ArrayList; |
| 122 import java.util.List; | 123 import java.util.List; |
| 123 | 124 |
| 124 /** | 125 /** |
| 125 * The basic Java representation of a tab. Contains and manages a {@link Conten
tView}. | 126 * The basic Java representation of a tab. Contains and manages a {@link Conten
tView}. |
| 126 * <p> | 127 * <p> |
| (...skipping 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1779 * rely on the native class to create the JNI association. | 1780 * rely on the native class to create the JNI association. |
| 1780 * | 1781 * |
| 1781 * TODO(dfalcantara): Make this function harder to access. | 1782 * TODO(dfalcantara): Make this function harder to access. |
| 1782 */ | 1783 */ |
| 1783 public void initializeNative() { | 1784 public void initializeNative() { |
| 1784 if (mNativeTabAndroid == 0) nativeInit(); | 1785 if (mNativeTabAndroid == 0) nativeInit(); |
| 1785 assert mNativeTabAndroid != 0; | 1786 assert mNativeTabAndroid != 0; |
| 1786 mIsInitialized = true; | 1787 mIsInitialized = true; |
| 1787 } | 1788 } |
| 1788 | 1789 |
| 1790 private static class ChromeViewAndroidDelegate extends ViewAndroidDelegate { |
| 1791 private final ViewGroup mContainerView; |
| 1792 |
| 1793 private ChromeViewAndroidDelegate(ViewGroup containerView) { |
| 1794 mContainerView = containerView; |
| 1795 } |
| 1796 |
| 1797 @Override |
| 1798 public ViewGroup getContainerView() { |
| 1799 return mContainerView; |
| 1800 } |
| 1801 }; |
| 1802 |
| 1789 /** | 1803 /** |
| 1790 * Creates and initializes the {@link ContentViewCore}. | 1804 * Creates and initializes the {@link ContentViewCore}. |
| 1791 * | 1805 * |
| 1792 * @param webContents The WebContents object that will be used to build the | 1806 * @param webContents The WebContents object that will be used to build the |
| 1793 * {@link ContentViewCore}. | 1807 * {@link ContentViewCore}. |
| 1794 */ | 1808 */ |
| 1795 protected void initContentViewCore(WebContents webContents) { | 1809 protected void initContentViewCore(WebContents webContents) { |
| 1796 ContentViewCore cvc = new ContentViewCore(mThemedApplicationContext); | 1810 ContentViewCore cvc = new ContentViewCore(mThemedApplicationContext); |
| 1797 ContentView cv = ContentView.createContentView(mThemedApplicationContext
, cvc); | 1811 ContentView cv = ContentView.createContentView(mThemedApplicationContext
, cvc); |
| 1798 cv.setContentDescription(mThemedApplicationContext.getResources().getStr
ing( | 1812 cv.setContentDescription(mThemedApplicationContext.getResources().getStr
ing( |
| 1799 R.string.accessibility_content_view)); | 1813 R.string.accessibility_content_view)); |
| 1800 cvc.initialize(cv, cv, webContents, getWindowAndroid()); | 1814 cvc.initialize(cv, new ChromeViewAndroidDelegate(cv), cv, webContents, g
etWindowAndroid()); |
| 1801 setContentViewCore(cvc); | 1815 setContentViewCore(cvc); |
| 1802 if (getTabModelSelector() instanceof SingleTabModelSelector) { | 1816 if (getTabModelSelector() instanceof SingleTabModelSelector) { |
| 1803 getContentViewCore().setFullscreenRequiredForOrientationLock(false); | 1817 getContentViewCore().setFullscreenRequiredForOrientationLock(false); |
| 1804 } | 1818 } |
| 1805 } | 1819 } |
| 1806 | 1820 |
| 1807 /** | 1821 /** |
| 1808 * Completes the {@link ContentViewCore} specific initialization around a na
tive WebContents | 1822 * Completes the {@link ContentViewCore} specific initialization around a na
tive WebContents |
| 1809 * pointer. {@link #getNativePage()} will still return the {@link NativePage
} if there is one. | 1823 * pointer. {@link #getNativePage()} will still return the {@link NativePage
} if there is one. |
| 1810 * All initialization that needs to reoccur after a web contents swap should
be added here. | 1824 * All initialization that needs to reoccur after a web contents swap should
be added here. |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2472 | 2486 |
| 2473 /** This is currently called when committing a pre-rendered page. */ | 2487 /** This is currently called when committing a pre-rendered page. */ |
| 2474 @VisibleForTesting | 2488 @VisibleForTesting |
| 2475 @CalledByNative | 2489 @CalledByNative |
| 2476 public void swapWebContents( | 2490 public void swapWebContents( |
| 2477 WebContents webContents, boolean didStartLoad, boolean didFinishLoad
) { | 2491 WebContents webContents, boolean didStartLoad, boolean didFinishLoad
) { |
| 2478 ContentViewCore cvc = new ContentViewCore(mThemedApplicationContext); | 2492 ContentViewCore cvc = new ContentViewCore(mThemedApplicationContext); |
| 2479 ContentView cv = ContentView.createContentView(mThemedApplicationContext
, cvc); | 2493 ContentView cv = ContentView.createContentView(mThemedApplicationContext
, cvc); |
| 2480 cv.setContentDescription(mThemedApplicationContext.getResources().getStr
ing( | 2494 cv.setContentDescription(mThemedApplicationContext.getResources().getStr
ing( |
| 2481 R.string.accessibility_content_view)); | 2495 R.string.accessibility_content_view)); |
| 2482 cvc.initialize(cv, cv, webContents, getWindowAndroid()); | 2496 cvc.initialize(cv, new ChromeViewAndroidDelegate(cv), cv, webContents, g
etWindowAndroid()); |
| 2483 swapContentViewCore(cvc, false, didStartLoad, didFinishLoad); | 2497 swapContentViewCore(cvc, false, didStartLoad, didFinishLoad); |
| 2484 } | 2498 } |
| 2485 | 2499 |
| 2486 /** | 2500 /** |
| 2487 * Called to swap out the current view with the one passed in. | 2501 * Called to swap out the current view with the one passed in. |
| 2488 * | 2502 * |
| 2489 * @param newContentViewCore The content view that should be swapped into th
e tab. | 2503 * @param newContentViewCore The content view that should be swapped into th
e tab. |
| 2490 * @param deleteOldNativeWebContents Whether to delete the native web | 2504 * @param deleteOldNativeWebContents Whether to delete the native web |
| 2491 * contents of old view. | 2505 * contents of old view. |
| 2492 * @param didStartLoad Whether | 2506 * @param didStartLoad Whether |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3273 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro
id, | 3287 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro
id, |
| 3274 InterceptNavigationDelegate delegate); | 3288 InterceptNavigationDelegate delegate); |
| 3275 private native void nativeAttachToTabContentManager(long nativeTabAndroid, | 3289 private native void nativeAttachToTabContentManager(long nativeTabAndroid, |
| 3276 TabContentManager tabContentManager); | 3290 TabContentManager tabContentManager); |
| 3277 private native void nativeAttachOverlayContentViewCore(long nativeTabAndroid
, | 3291 private native void nativeAttachOverlayContentViewCore(long nativeTabAndroid
, |
| 3278 ContentViewCore content, boolean visible); | 3292 ContentViewCore content, boolean visible); |
| 3279 private native void nativeDetachOverlayContentViewCore(long nativeTabAndroid
, | 3293 private native void nativeDetachOverlayContentViewCore(long nativeTabAndroid
, |
| 3280 ContentViewCore content); | 3294 ContentViewCore content); |
| 3281 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String
url); | 3295 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String
url); |
| 3282 } | 3296 } |
| OLD | NEW |