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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 /** Whether or not this tab is an incognito tab. */ | 146 /** Whether or not this tab is an incognito tab. */ |
147 private final boolean mIncognito; | 147 private final boolean mIncognito; |
148 | 148 |
149 /** | 149 /** |
150 * An Application {@link Context}. Unlike {@link #mActivity}, this is the o nly one that is | 150 * An Application {@link Context}. Unlike {@link #mActivity}, this is the o nly one that is |
151 * publicly exposed to help prevent leaking the {@link Activity}. | 151 * publicly exposed to help prevent leaking the {@link Activity}. |
152 */ | 152 */ |
153 private final Context mThemedApplicationContext; | 153 private final Context mThemedApplicationContext; |
154 | 154 |
155 /** Gives {@link Tab} a way to interact with the Android window. */ | 155 /** Gives {@link Tab} a way to interact with the Android window. */ |
156 private final WindowAndroid mWindowAndroid; | 156 private WindowAndroid mWindowAndroid; |
157 | 157 |
158 /** Whether or not this {@link Tab} is initialized and should be interacted with. */ | 158 /** Whether or not this {@link Tab} is initialized and should be interacted with. */ |
159 private boolean mIsInitialized; | 159 private boolean mIsInitialized; |
160 | 160 |
161 /** The current native page (e.g. chrome-native://newtab), or {@code null} i f there is none. */ | 161 /** The current native page (e.g. chrome-native://newtab), or {@code null} i f there is none. */ |
162 private NativePage mNativePage; | 162 private NativePage mNativePage; |
163 | 163 |
164 /** InfoBar container to show InfoBars for this tab. */ | 164 /** InfoBar container to show InfoBars for this tab. */ |
165 private InfoBarContainer mInfoBarContainer; | 165 private InfoBarContainer mInfoBarContainer; |
166 | 166 |
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1348 } finally { | 1348 } finally { |
1349 if (mTimestampMillis == INVALID_TIMESTAMP) { | 1349 if (mTimestampMillis == INVALID_TIMESTAMP) { |
1350 mTimestampMillis = System.currentTimeMillis(); | 1350 mTimestampMillis = System.currentTimeMillis(); |
1351 } | 1351 } |
1352 | 1352 |
1353 TraceEvent.end("Tab.initialize"); | 1353 TraceEvent.end("Tab.initialize"); |
1354 } | 1354 } |
1355 } | 1355 } |
1356 | 1356 |
1357 /** | 1357 /** |
1358 * Detaches tab and related objects from an existing activity and attaches t o a new one. This | |
1359 * updates many delegates inside the tab and {@link ContentViewCore} both on java and native | |
1360 * sides. | |
1361 * @param activity The new activity this tab should be associated with. | |
1362 * @param tabDelegateFactory The new delegate factory this tab should be usi ng. | |
1363 */ | |
1364 public void reparentToActivity(ChromeActivity activity, TabDelegateFactory t abDelegateFactory) { | |
1365 ChromeActivity oldActivity = getActivity(); | |
1366 | |
1367 // Update and propagate for the new WindowAndroid. | |
1368 mWindowAndroid = activity.getWindowAndroid(); | |
1369 mContentViewCore.updateWindowAndroid(mWindowAndroid); | |
1370 | |
1371 // Update for the controllers that needs the Compositor from the new Act ivity. | |
gone
2016/02/24 18:40:37
needs -> need
Yusuf
2016/02/24 19:40:35
Done.
| |
1372 nativeAttachToTabContentManager(mNativeTabAndroid, activity.getTabConten tManager()); | |
1373 mFullscreenManager = activity.getFullscreenManager(); | |
1374 activity.getCompositorViewHolder().onActiveTabReparented(); | |
1375 | |
1376 // Update the delegate factory, then recreate and propagate all delegate s. | |
1377 mDelegateFactory = tabDelegateFactory; | |
1378 mWebContentsDelegate = mDelegateFactory.createWebContentsDelegate(this); | |
1379 nativeUpdateDelegates(mNativeTabAndroid, | |
1380 mWebContentsDelegate, mDelegateFactory.createContextMenuPopulato r(this)); | |
1381 mTopControlsVisibilityDelegate = mDelegateFactory.createTopControlsVisib ilityDelegate(this); | |
1382 setInterceptNavigationDelegate(mDelegateFactory.createInterceptNavigatio nDelegate(this)); | |
1383 mAppBannerManager = mDelegateFactory.createAppBannerManager(this); | |
gone
2016/02/24 18:40:37
You're not calling mAppBannerManager.destroy() on
Yusuf
2016/02/24 19:40:35
Done.
No, the appbannermanager is the only one. An
| |
1384 | |
1385 // Take down the old activity, which destroys all the remaining tabmodel s and tabs. | |
1386 if (oldActivity != null && !oldActivity.isActivityDestroyed()) oldActivi ty.finish(); | |
1387 } | |
1388 | |
1389 /** | |
1358 * @return The delegate factory for testing purposes only. | 1390 * @return The delegate factory for testing purposes only. |
1359 */ | 1391 */ |
1360 public TabDelegateFactory getDelegateFactory() { | 1392 public TabDelegateFactory getDelegateFactory() { |
1361 return mDelegateFactory; | 1393 return mDelegateFactory; |
1362 } | 1394 } |
1363 | 1395 |
1364 /** | 1396 /** |
1365 * 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 |
1366 * 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. |
1367 * @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 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2938 String packageName = ApplicationStatus.getApplicationContext().getPackag eName(); | 2970 String packageName = ApplicationStatus.getApplicationContext().getPackag eName(); |
2939 return getLaunchType() == TabLaunchType.FROM_EXTERNAL_APP | 2971 return getLaunchType() == TabLaunchType.FROM_EXTERNAL_APP |
2940 && !TextUtils.equals(getAppAssociatedWith(), packageName); | 2972 && !TextUtils.equals(getAppAssociatedWith(), packageName); |
2941 } | 2973 } |
2942 | 2974 |
2943 private native void nativeInit(); | 2975 private native void nativeInit(); |
2944 private native void nativeDestroy(long nativeTabAndroid); | 2976 private native void nativeDestroy(long nativeTabAndroid); |
2945 private native void nativeInitWebContents(long nativeTabAndroid, boolean inc ognito, | 2977 private native void nativeInitWebContents(long nativeTabAndroid, boolean inc ognito, |
2946 ContentViewCore contentViewCore, TabWebContentsDelegateAndroid deleg ate, | 2978 ContentViewCore contentViewCore, TabWebContentsDelegateAndroid deleg ate, |
2947 ContextMenuPopulator contextMenuPopulator); | 2979 ContextMenuPopulator contextMenuPopulator); |
2980 private native void nativeUpdateDelegates(long nativeTabAndroid, | |
2981 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator); | |
2948 private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative); | 2982 private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative); |
2949 private native Profile nativeGetProfileAndroid(long nativeTabAndroid); | 2983 private native Profile nativeGetProfileAndroid(long nativeTabAndroid); |
2950 private native int nativeLoadUrl(long nativeTabAndroid, String url, String e xtraHeaders, | 2984 private native int nativeLoadUrl(long nativeTabAndroid, String url, String e xtraHeaders, |
2951 byte[] postData, int transition, String referrerUrl, int referrerPol icy, | 2985 byte[] postData, int transition, String referrerUrl, int referrerPol icy, |
2952 boolean isRendererInitiated, boolean shoulReplaceCurrentEntry, | 2986 boolean isRendererInitiated, boolean shoulReplaceCurrentEntry, |
2953 long intentReceivedTimestamp, boolean hasUserGesture); | 2987 long intentReceivedTimestamp, boolean hasUserGesture); |
2954 private native void nativeSetActiveNavigationEntryTitleForUrl(long nativeTab Android, String url, | 2988 private native void nativeSetActiveNavigationEntryTitleForUrl(long nativeTab Android, String url, |
2955 String title); | 2989 String title); |
2956 private native boolean nativePrint(long nativeTabAndroid); | 2990 private native boolean nativePrint(long nativeTabAndroid); |
2957 private native Bitmap nativeGetFavicon(long nativeTabAndroid); | 2991 private native Bitmap nativeGetFavicon(long nativeTabAndroid); |
2958 private native void nativeCreateHistoricalTab(long nativeTabAndroid); | 2992 private native void nativeCreateHistoricalTab(long nativeTabAndroid); |
2959 private native void nativeUpdateTopControlsState( | 2993 private native void nativeUpdateTopControlsState( |
2960 long nativeTabAndroid, int constraints, int current, boolean animate ); | 2994 long nativeTabAndroid, int constraints, int current, boolean animate ); |
2961 private native void nativeLoadOriginalImage(long nativeTabAndroid); | 2995 private native void nativeLoadOriginalImage(long nativeTabAndroid); |
2962 private native long nativeGetBookmarkId(long nativeTabAndroid, boolean onlyE ditable); | 2996 private native long nativeGetBookmarkId(long nativeTabAndroid, boolean onlyE ditable); |
2963 private native boolean nativeHasOfflineCopy(long nativeTabAndroid); | 2997 private native boolean nativeHasOfflineCopy(long nativeTabAndroid); |
2964 private native boolean nativeIsOfflinePage(long nativeTabAndroid); | 2998 private native boolean nativeIsOfflinePage(long nativeTabAndroid); |
2965 private native String nativeGetOfflinePageOriginalUrl(long nativeTabAndroid) ; | 2999 private native String nativeGetOfflinePageOriginalUrl(long nativeTabAndroid) ; |
2966 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro id, | 3000 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro id, |
2967 InterceptNavigationDelegate delegate); | 3001 InterceptNavigationDelegate delegate); |
2968 private native void nativeAttachToTabContentManager(long nativeTabAndroid, | 3002 private native void nativeAttachToTabContentManager(long nativeTabAndroid, |
2969 TabContentManager tabContentManager); | 3003 TabContentManager tabContentManager); |
2970 private native void nativeAttachOverlayContentViewCore(long nativeTabAndroid , | 3004 private native void nativeAttachOverlayContentViewCore(long nativeTabAndroid , |
2971 ContentViewCore content, boolean visible); | 3005 ContentViewCore content, boolean visible); |
2972 private native void nativeDetachOverlayContentViewCore(long nativeTabAndroid , | 3006 private native void nativeDetachOverlayContentViewCore(long nativeTabAndroid , |
2973 ContentViewCore content); | 3007 ContentViewCore content); |
2974 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String url); | 3008 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String url); |
2975 } | 3009 } |
OLD | NEW |