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.content.Context; | 8 import android.content.Context; |
9 import android.content.Intent; | 9 import android.content.Intent; |
10 import android.content.res.Resources; | 10 import android.content.res.Resources; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 /** Whether or not this tab is an incognito tab. */ | 149 /** Whether or not this tab is an incognito tab. */ |
150 private final boolean mIncognito; | 150 private final boolean mIncognito; |
151 | 151 |
152 /** | 152 /** |
153 * An Application {@link Context}. Unlike {@link #mActivity}, this is the o nly one that is | 153 * An Application {@link Context}. Unlike {@link #mActivity}, this is the o nly one that is |
154 * publicly exposed to help prevent leaking the {@link Activity}. | 154 * publicly exposed to help prevent leaking the {@link Activity}. |
155 */ | 155 */ |
156 private final Context mThemedApplicationContext; | 156 private final Context mThemedApplicationContext; |
157 | 157 |
158 /** Gives {@link Tab} a way to interact with the Android window. */ | 158 /** Gives {@link Tab} a way to interact with the Android window. */ |
159 private final WindowAndroid mWindowAndroid; | 159 private WindowAndroid mWindowAndroid; |
160 | 160 |
161 /** Whether or not this {@link Tab} is initialized and should be interacted with. */ | 161 /** Whether or not this {@link Tab} is initialized and should be interacted with. */ |
162 private boolean mIsInitialized; | 162 private boolean mIsInitialized; |
163 | 163 |
164 /** The current native page (e.g. chrome-native://newtab), or {@code null} i f there is none. */ | 164 /** The current native page (e.g. chrome-native://newtab), or {@code null} i f there is none. */ |
165 private NativePage mNativePage; | 165 private NativePage mNativePage; |
166 | 166 |
167 /** InfoBar container to show InfoBars for this tab. */ | 167 /** InfoBar container to show InfoBars for this tab. */ |
168 private InfoBarContainer mInfoBarContainer; | 168 private InfoBarContainer mInfoBarContainer; |
169 | 169 |
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1351 } finally { | 1351 } finally { |
1352 if (mTimestampMillis == INVALID_TIMESTAMP) { | 1352 if (mTimestampMillis == INVALID_TIMESTAMP) { |
1353 mTimestampMillis = System.currentTimeMillis(); | 1353 mTimestampMillis = System.currentTimeMillis(); |
1354 } | 1354 } |
1355 | 1355 |
1356 TraceEvent.end("Tab.initialize"); | 1356 TraceEvent.end("Tab.initialize"); |
1357 } | 1357 } |
1358 } | 1358 } |
1359 | 1359 |
1360 /** | 1360 /** |
1361 * Detaches tab and related objects from an existing activity and attaches t o a new one. This | |
1362 * updates many delegates inside the tab and {@link ContentViewCore} both on java and native | |
1363 * sides. | |
1364 * @param activity The new activity this tab should be associated with. | |
1365 * @param tabDelegateFactory The new delegate factory this tab should be usi ng. | |
1366 */ | |
1367 public void reparentToActivity(ChromeActivity activity, TabDelegateFactory t abDelegateFactory) { | |
Ted C
2016/02/26 18:46:29
we might want this to be a two part call eventuall
Yusuf
2016/02/26 19:39:52
Acknowledged.
| |
1368 // TODO(yusufo): Share these calls with the construction related calls. | |
1369 | |
1370 // Update and propagate for the new WindowAndroid. | |
1371 mWindowAndroid = activity.getWindowAndroid(); | |
1372 mContentViewCore.updateWindowAndroid(mWindowAndroid); | |
1373 | |
1374 // Update for the controllers that need the Compositor from the new Acti vity. | |
1375 nativeAttachToTabContentManager(mNativeTabAndroid, activity.getTabConten tManager()); | |
1376 mFullscreenManager = activity.getFullscreenManager(); | |
1377 activity.getCompositorViewHolder().prepareForTabReparenting(); | |
1378 | |
1379 // Update the delegate factory, then recreate and propagate all delegate s. | |
1380 mDelegateFactory = tabDelegateFactory; | |
1381 mWebContentsDelegate = mDelegateFactory.createWebContentsDelegate(this); | |
1382 nativeUpdateDelegates(mNativeTabAndroid, | |
1383 mWebContentsDelegate, mDelegateFactory.createContextMenuPopulato r(this)); | |
1384 mTopControlsVisibilityDelegate = mDelegateFactory.createTopControlsVisib ilityDelegate(this); | |
1385 setInterceptNavigationDelegate(mDelegateFactory.createInterceptNavigatio nDelegate(this)); | |
1386 mAppBannerManager = mDelegateFactory.createAppBannerManager(this); | |
1387 } | |
1388 | |
1389 /** | |
1361 * @return The delegate factory for testing purposes only. | 1390 * @return The delegate factory for testing purposes only. |
1362 */ | 1391 */ |
1363 public TabDelegateFactory getDelegateFactory() { | 1392 public TabDelegateFactory getDelegateFactory() { |
1364 return mDelegateFactory; | 1393 return mDelegateFactory; |
1365 } | 1394 } |
1366 | 1395 |
1367 /** | 1396 /** |
1368 * Used to get a list of Android {@link View}s that represent both the norma l content as well as | 1397 * Used to get a list of Android {@link View}s that represent both the norma l content as well as |
1369 * overlays. This does not return {@link View}s for {@link NativePage}s. | 1398 * overlays. This does not return {@link View}s for {@link NativePage}s. |
1370 * @param content A {@link List} that will be populated with {@link View}s t hat represent all of | 1399 * @param content A {@link List} that will be populated with {@link View}s t hat represent all of |
(...skipping 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2942 String packageName = ApplicationStatus.getApplicationContext().getPackag eName(); | 2971 String packageName = ApplicationStatus.getApplicationContext().getPackag eName(); |
2943 return getLaunchType() == TabLaunchType.FROM_EXTERNAL_APP | 2972 return getLaunchType() == TabLaunchType.FROM_EXTERNAL_APP |
2944 && !TextUtils.equals(getAppAssociatedWith(), packageName); | 2973 && !TextUtils.equals(getAppAssociatedWith(), packageName); |
2945 } | 2974 } |
2946 | 2975 |
2947 private native void nativeInit(); | 2976 private native void nativeInit(); |
2948 private native void nativeDestroy(long nativeTabAndroid); | 2977 private native void nativeDestroy(long nativeTabAndroid); |
2949 private native void nativeInitWebContents(long nativeTabAndroid, boolean inc ognito, | 2978 private native void nativeInitWebContents(long nativeTabAndroid, boolean inc ognito, |
2950 ContentViewCore contentViewCore, TabWebContentsDelegateAndroid deleg ate, | 2979 ContentViewCore contentViewCore, TabWebContentsDelegateAndroid deleg ate, |
2951 ContextMenuPopulator contextMenuPopulator); | 2980 ContextMenuPopulator contextMenuPopulator); |
2981 private native void nativeUpdateDelegates(long nativeTabAndroid, | |
2982 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator); | |
2952 private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative); | 2983 private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative); |
2953 private native Profile nativeGetProfileAndroid(long nativeTabAndroid); | 2984 private native Profile nativeGetProfileAndroid(long nativeTabAndroid); |
2954 private native int nativeLoadUrl(long nativeTabAndroid, String url, String e xtraHeaders, | 2985 private native int nativeLoadUrl(long nativeTabAndroid, String url, String e xtraHeaders, |
2955 byte[] postData, int transition, String referrerUrl, int referrerPol icy, | 2986 byte[] postData, int transition, String referrerUrl, int referrerPol icy, |
2956 boolean isRendererInitiated, boolean shoulReplaceCurrentEntry, | 2987 boolean isRendererInitiated, boolean shoulReplaceCurrentEntry, |
2957 long intentReceivedTimestamp, boolean hasUserGesture); | 2988 long intentReceivedTimestamp, boolean hasUserGesture); |
2958 private native void nativeSetActiveNavigationEntryTitleForUrl(long nativeTab Android, String url, | 2989 private native void nativeSetActiveNavigationEntryTitleForUrl(long nativeTab Android, String url, |
2959 String title); | 2990 String title); |
2960 private native boolean nativePrint(long nativeTabAndroid); | 2991 private native boolean nativePrint(long nativeTabAndroid); |
2961 private native Bitmap nativeGetFavicon(long nativeTabAndroid); | 2992 private native Bitmap nativeGetFavicon(long nativeTabAndroid); |
2962 private native void nativeCreateHistoricalTab(long nativeTabAndroid); | 2993 private native void nativeCreateHistoricalTab(long nativeTabAndroid); |
2963 private native void nativeUpdateTopControlsState( | 2994 private native void nativeUpdateTopControlsState( |
2964 long nativeTabAndroid, int constraints, int current, boolean animate ); | 2995 long nativeTabAndroid, int constraints, int current, boolean animate ); |
2965 private native void nativeLoadOriginalImage(long nativeTabAndroid); | 2996 private native void nativeLoadOriginalImage(long nativeTabAndroid); |
2966 private native long nativeGetBookmarkId(long nativeTabAndroid, boolean onlyE ditable); | 2997 private native long nativeGetBookmarkId(long nativeTabAndroid, boolean onlyE ditable); |
2967 private native boolean nativeHasOfflineCopy(long nativeTabAndroid); | 2998 private native boolean nativeHasOfflineCopy(long nativeTabAndroid); |
2968 private native boolean nativeIsOfflinePage(long nativeTabAndroid); | 2999 private native boolean nativeIsOfflinePage(long nativeTabAndroid); |
2969 private native String nativeGetOfflinePageOriginalUrl(long nativeTabAndroid) ; | 3000 private native String nativeGetOfflinePageOriginalUrl(long nativeTabAndroid) ; |
2970 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro id, | 3001 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro id, |
2971 InterceptNavigationDelegate delegate); | 3002 InterceptNavigationDelegate delegate); |
2972 private native void nativeAttachToTabContentManager(long nativeTabAndroid, | 3003 private native void nativeAttachToTabContentManager(long nativeTabAndroid, |
2973 TabContentManager tabContentManager); | 3004 TabContentManager tabContentManager); |
2974 private native void nativeAttachOverlayContentViewCore(long nativeTabAndroid , | 3005 private native void nativeAttachOverlayContentViewCore(long nativeTabAndroid , |
2975 ContentViewCore content, boolean visible); | 3006 ContentViewCore content, boolean visible); |
2976 private native void nativeDetachOverlayContentViewCore(long nativeTabAndroid , | 3007 private native void nativeDetachOverlayContentViewCore(long nativeTabAndroid , |
2977 ContentViewCore content); | 3008 ContentViewCore content); |
2978 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String url); | 3009 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String url); |
2979 } | 3010 } |
OLD | NEW |