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 21 matching lines...) Expand all Loading... |
32 import org.chromium.base.ApplicationStatus; | 32 import org.chromium.base.ApplicationStatus; |
33 import org.chromium.base.ContextUtils; | 33 import org.chromium.base.ContextUtils; |
34 import org.chromium.base.ObserverList; | 34 import org.chromium.base.ObserverList; |
35 import org.chromium.base.ObserverList.RewindableIterator; | 35 import org.chromium.base.ObserverList.RewindableIterator; |
36 import org.chromium.base.ThreadUtils; | 36 import org.chromium.base.ThreadUtils; |
37 import org.chromium.base.TraceEvent; | 37 import org.chromium.base.TraceEvent; |
38 import org.chromium.base.VisibleForTesting; | 38 import org.chromium.base.VisibleForTesting; |
39 import org.chromium.base.annotations.CalledByNative; | 39 import org.chromium.base.annotations.CalledByNative; |
40 import org.chromium.base.metrics.RecordHistogram; | 40 import org.chromium.base.metrics.RecordHistogram; |
41 import org.chromium.base.metrics.RecordUserAction; | 41 import org.chromium.base.metrics.RecordUserAction; |
| 42 import org.chromium.blimp_public.contents.BlimpContents; |
42 import org.chromium.chrome.R; | 43 import org.chromium.chrome.R; |
43 import org.chromium.chrome.browser.ChromeActivity; | 44 import org.chromium.chrome.browser.ChromeActivity; |
44 import org.chromium.chrome.browser.ChromeApplication; | 45 import org.chromium.chrome.browser.ChromeApplication; |
45 import org.chromium.chrome.browser.ChromeFeatureList; | 46 import org.chromium.chrome.browser.ChromeFeatureList; |
46 import org.chromium.chrome.browser.ChromeVersionInfo; | 47 import org.chromium.chrome.browser.ChromeVersionInfo; |
47 import org.chromium.chrome.browser.FrozenNativePage; | 48 import org.chromium.chrome.browser.FrozenNativePage; |
48 import org.chromium.chrome.browser.IntentHandler; | 49 import org.chromium.chrome.browser.IntentHandler; |
49 import org.chromium.chrome.browser.IntentHandler.TabOpenType; | 50 import org.chromium.chrome.browser.IntentHandler.TabOpenType; |
50 import org.chromium.chrome.browser.NativePage; | 51 import org.chromium.chrome.browser.NativePage; |
51 import org.chromium.chrome.browser.SwipeRefreshHandler; | 52 import org.chromium.chrome.browser.SwipeRefreshHandler; |
52 import org.chromium.chrome.browser.TabState; | 53 import org.chromium.chrome.browser.TabState; |
53 import org.chromium.chrome.browser.TabState.WebContentsState; | 54 import org.chromium.chrome.browser.TabState.WebContentsState; |
54 import org.chromium.chrome.browser.UrlConstants; | 55 import org.chromium.chrome.browser.UrlConstants; |
55 import org.chromium.chrome.browser.WarmupManager; | 56 import org.chromium.chrome.browser.WarmupManager; |
56 import org.chromium.chrome.browser.WebContentsFactory; | 57 import org.chromium.chrome.browser.WebContentsFactory; |
57 import org.chromium.chrome.browser.banners.AppBannerManager; | 58 import org.chromium.chrome.browser.banners.AppBannerManager; |
| 59 import org.chromium.chrome.browser.blimp.BlimpClientContextFactory; |
58 import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; | 60 import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; |
59 import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator; | 61 import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator; |
60 import org.chromium.chrome.browser.contextualsearch.ContextualSearchTabHelper; | 62 import org.chromium.chrome.browser.contextualsearch.ContextualSearchTabHelper; |
61 import org.chromium.chrome.browser.crash.MinidumpDirectoryObserver; | 63 import org.chromium.chrome.browser.crash.MinidumpDirectoryObserver; |
62 import org.chromium.chrome.browser.crash.MinidumpUploadService; | 64 import org.chromium.chrome.browser.crash.MinidumpUploadService; |
63 import org.chromium.chrome.browser.customtabs.CustomTabActivity; | 65 import org.chromium.chrome.browser.customtabs.CustomTabActivity; |
64 import org.chromium.chrome.browser.download.ChromeDownloadDelegate; | 66 import org.chromium.chrome.browser.download.ChromeDownloadDelegate; |
65 import org.chromium.chrome.browser.fullscreen.FullscreenManager; | 67 import org.chromium.chrome.browser.fullscreen.FullscreenManager; |
66 import org.chromium.chrome.browser.help.HelpAndFeedback; | 68 import org.chromium.chrome.browser.help.HelpAndFeedback; |
67 import org.chromium.chrome.browser.infobar.InfoBarContainer; | 69 import org.chromium.chrome.browser.infobar.InfoBarContainer; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 private static final String TAG = "Tab"; | 162 private static final String TAG = "Tab"; |
161 | 163 |
162 private long mNativeTabAndroid; | 164 private long mNativeTabAndroid; |
163 | 165 |
164 /** Unique id of this tab (within its container). */ | 166 /** Unique id of this tab (within its container). */ |
165 private final int mId; | 167 private final int mId; |
166 | 168 |
167 /** Whether or not this tab is an incognito tab. */ | 169 /** Whether or not this tab is an incognito tab. */ |
168 private final boolean mIncognito; | 170 private final boolean mIncognito; |
169 | 171 |
| 172 /** Whether or not this tab is running in blimp mode. */ |
| 173 private boolean mBlimp; |
| 174 |
170 /** | 175 /** |
171 * An Application {@link Context}. Unlike {@link #mActivity}, this is the o
nly one that is | 176 * An Application {@link Context}. Unlike {@link #mActivity}, this is the o
nly one that is |
172 * publicly exposed to help prevent leaking the {@link Activity}. | 177 * publicly exposed to help prevent leaking the {@link Activity}. |
173 */ | 178 */ |
174 private final Context mThemedApplicationContext; | 179 private final Context mThemedApplicationContext; |
175 | 180 |
176 /** Gives {@link Tab} a way to interact with the Android window. */ | 181 /** Gives {@link Tab} a way to interact with the Android window. */ |
177 private WindowAndroid mWindowAndroid; | 182 private WindowAndroid mWindowAndroid; |
178 | 183 |
179 /** Whether or not this {@link Tab} is initialized and should be interacted
with. */ | 184 /** Whether or not this {@link Tab} is initialized and should be interacted
with. */ |
(...skipping 26 matching lines...) Expand all Loading... |
206 /** | 211 /** |
207 * A list of {@link ContentViewCore} overlay objects that are managed by ext
ernal components but | 212 * A list of {@link ContentViewCore} overlay objects that are managed by ext
ernal components but |
208 * need to be sized and rendered along side this {@link Tab}s content. | 213 * need to be sized and rendered along side this {@link Tab}s content. |
209 */ | 214 */ |
210 private final List<ContentViewCore> mOverlayContentViewCores = new ArrayList
<>(); | 215 private final List<ContentViewCore> mOverlayContentViewCores = new ArrayList
<>(); |
211 | 216 |
212 // Content layer Observers and Delegates | 217 // Content layer Observers and Delegates |
213 private ContentViewClient mContentViewClient; | 218 private ContentViewClient mContentViewClient; |
214 private TabWebContentsObserver mWebContentsObserver; | 219 private TabWebContentsObserver mWebContentsObserver; |
215 private TabWebContentsDelegateAndroid mWebContentsDelegate; | 220 private TabWebContentsDelegateAndroid mWebContentsDelegate; |
| 221 private BlimpContents mBlimpContents; |
216 | 222 |
217 /** | 223 /** |
218 * If this tab was opened from another tab, store the id of the tab that | 224 * If this tab was opened from another tab, store the id of the tab that |
219 * caused it to be opened so that we can activate it when this tab gets | 225 * caused it to be opened so that we can activate it when this tab gets |
220 * closed. | 226 * closed. |
221 */ | 227 */ |
222 private int mParentId = INVALID_TAB_ID; | 228 private int mParentId = INVALID_TAB_ID; |
223 | 229 |
224 /** | 230 /** |
225 * If this tab was opened from another tab in another Activity, this is the
Intent that can be | 231 * If this tab was opened from another tab in another Activity, this is the
Intent that can be |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 * @param observer The {@link TabObserver} to remove. | 733 * @param observer The {@link TabObserver} to remove. |
728 */ | 734 */ |
729 public void removeObserver(TabObserver observer) { | 735 public void removeObserver(TabObserver observer) { |
730 mObservers.removeObserver(observer); | 736 mObservers.removeObserver(observer); |
731 } | 737 } |
732 | 738 |
733 /** | 739 /** |
734 * @return Whether or not this tab has a previous navigation entry. | 740 * @return Whether or not this tab has a previous navigation entry. |
735 */ | 741 */ |
736 public boolean canGoBack() { | 742 public boolean canGoBack() { |
737 return getWebContents() != null && getWebContents().getNavigationControl
ler().canGoBack(); | 743 if (isBlimpTab()) { |
| 744 return getBlimpContents() != null |
| 745 && getBlimpContents().getNavigationController().canGoBack(); |
| 746 } else { |
| 747 return getWebContents() != null |
| 748 && getWebContents().getNavigationController().canGoBack(); |
| 749 } |
738 } | 750 } |
739 | 751 |
740 /** | 752 /** |
741 * @return Whether or not this tab has a navigation entry after the current
one. | 753 * @return Whether or not this tab has a navigation entry after the current
one. |
742 */ | 754 */ |
743 public boolean canGoForward() { | 755 public boolean canGoForward() { |
744 return getWebContents() != null && getWebContents().getNavigationControl
ler() | 756 if (isBlimpTab()) { |
745 .canGoForward(); | 757 return getBlimpContents() != null |
| 758 && getBlimpContents().getNavigationController().canGoForward
(); |
| 759 } else { |
| 760 return getWebContents() != null |
| 761 && getWebContents().getNavigationController().canGoForward()
; |
| 762 } |
746 } | 763 } |
747 | 764 |
748 /** | 765 /** |
749 * Goes to the navigation entry before the current one. | 766 * Goes to the navigation entry before the current one. |
750 */ | 767 */ |
751 public void goBack() { | 768 public void goBack() { |
752 if (getWebContents() != null) getWebContents().getNavigationController()
.goBack(); | 769 if (isBlimpTab()) { |
| 770 if (getBlimpContents() != null) getBlimpContents().getNavigationCont
roller().goBack(); |
| 771 } else { |
| 772 if (getWebContents() != null) getWebContents().getNavigationControll
er().goBack(); |
| 773 } |
753 } | 774 } |
754 | 775 |
755 /** | 776 /** |
756 * Goes to the navigation entry after the current one. | 777 * Goes to the navigation entry after the current one. |
757 */ | 778 */ |
758 public void goForward() { | 779 public void goForward() { |
759 if (getWebContents() != null) getWebContents().getNavigationController()
.goForward(); | 780 if (isBlimpTab()) { |
| 781 if (getBlimpContents() != null) { |
| 782 getBlimpContents().getNavigationController().goForward(); |
| 783 } |
| 784 } else { |
| 785 if (getWebContents() != null) getWebContents().getNavigationControll
er().goForward(); |
| 786 } |
760 } | 787 } |
761 | 788 |
762 /** | 789 /** |
763 * Loads the current navigation if there is a pending lazy load (after tab r
estore). | 790 * Loads the current navigation if there is a pending lazy load (after tab r
estore). |
764 */ | 791 */ |
765 public void loadIfNecessary() { | 792 public void loadIfNecessary() { |
766 if (getWebContents() != null) getWebContents().getNavigationController()
.loadIfNecessary(); | 793 if (getWebContents() != null) getWebContents().getNavigationController()
.loadIfNecessary(); |
767 } | 794 } |
768 | 795 |
769 /** | 796 /** |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 | 1010 |
984 printingController.setPendingPrint(new TabPrinter(this), | 1011 printingController.setPendingPrint(new TabPrinter(this), |
985 new PrintManagerDelegateImpl(getActivity())); | 1012 new PrintManagerDelegateImpl(getActivity())); |
986 } | 1013 } |
987 | 1014 |
988 /** | 1015 /** |
989 * Reloads the current page content. | 1016 * Reloads the current page content. |
990 */ | 1017 */ |
991 public void reload() { | 1018 public void reload() { |
992 // TODO(dtrainor): Should we try to rebuild the ContentView if it's froz
en? | 1019 // TODO(dtrainor): Should we try to rebuild the ContentView if it's froz
en? |
993 if (getWebContents() != null) getWebContents().getNavigationController()
.reload(true); | 1020 if (isBlimpTab()) { |
| 1021 if (getBlimpContents() != null) { |
| 1022 getBlimpContents().getNavigationController().reload(); |
| 1023 } |
| 1024 } else { |
| 1025 if (getWebContents() != null) getWebContents().getNavigationControll
er().reload(true); |
| 1026 } |
994 } | 1027 } |
995 | 1028 |
996 /** | 1029 /** |
997 * Reloads the current page content. | 1030 * Reloads the current page content. |
998 * This version ignores the cache and reloads from the network. | 1031 * This version ignores the cache and reloads from the network. |
999 */ | 1032 */ |
1000 public void reloadIgnoringCache() { | 1033 public void reloadIgnoringCache() { |
1001 if (getWebContents() != null) { | 1034 if (getWebContents() != null) { |
1002 getWebContents().getNavigationController().reloadBypassingCache(true
); | 1035 getWebContents().getNavigationController().reloadBypassingCache(true
); |
1003 } | 1036 } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1121 } | 1154 } |
1122 | 1155 |
1123 /** | 1156 /** |
1124 * @return The web contents associated with this tab. | 1157 * @return The web contents associated with this tab. |
1125 */ | 1158 */ |
1126 public WebContents getWebContents() { | 1159 public WebContents getWebContents() { |
1127 return mContentViewCore != null ? mContentViewCore.getWebContents() : nu
ll; | 1160 return mContentViewCore != null ? mContentViewCore.getWebContents() : nu
ll; |
1128 } | 1161 } |
1129 | 1162 |
1130 /** | 1163 /** |
| 1164 * @return The {@link BlimpContents} associated with this tab, if in blimp m
ode. |
| 1165 */ |
| 1166 public BlimpContents getBlimpContents() { |
| 1167 return mBlimpContents; |
| 1168 } |
| 1169 |
| 1170 /** |
| 1171 * @return Whether or not this tab is running in blimp mode. |
| 1172 */ |
| 1173 public boolean isBlimpTab() { |
| 1174 return mBlimp; |
| 1175 } |
| 1176 |
| 1177 /** |
1131 * @return The profile associated with this tab. | 1178 * @return The profile associated with this tab. |
1132 */ | 1179 */ |
1133 public Profile getProfile() { | 1180 public Profile getProfile() { |
1134 if (mNativeTabAndroid == 0) return null; | 1181 if (mNativeTabAndroid == 0) return null; |
1135 return nativeGetProfileAndroid(mNativeTabAndroid); | 1182 return nativeGetProfileAndroid(mNativeTabAndroid); |
1136 } | 1183 } |
1137 | 1184 |
1138 /** | 1185 /** |
1139 * For more information about the uniqueness of {@link #getId()} see comment
s on {@link Tab}. | 1186 * For more information about the uniqueness of {@link #getId()} see comment
s on {@link Tab}. |
1140 * @see Tab | 1187 * @see Tab |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 } | 1224 } |
1178 | 1225 |
1179 /** | 1226 /** |
1180 * Set whether or not the {@link ContentViewCore} should be using a desktop
user agent for the | 1227 * Set whether or not the {@link ContentViewCore} should be using a desktop
user agent for the |
1181 * currently loaded page. | 1228 * currently loaded page. |
1182 * @param useDesktop If {@code true}, use a desktop user agent. Otherwi
se use a mobile one. | 1229 * @param useDesktop If {@code true}, use a desktop user agent. Otherwi
se use a mobile one. |
1183 * @param reloadOnChange Reload the page if the user agent has changed. | 1230 * @param reloadOnChange Reload the page if the user agent has changed. |
1184 */ | 1231 */ |
1185 public void setUseDesktopUserAgent(boolean useDesktop, boolean reloadOnChang
e) { | 1232 public void setUseDesktopUserAgent(boolean useDesktop, boolean reloadOnChang
e) { |
1186 if (getWebContents() != null) { | 1233 if (getWebContents() != null) { |
1187 getWebContents().getNavigationController() | 1234 getWebContents().getNavigationController().setUseDesktopUserAgent( |
1188 .setUseDesktopUserAgent(useDesktop, reloadOnChange); | 1235 useDesktop, reloadOnChange); |
1189 } | 1236 } |
1190 } | 1237 } |
1191 | 1238 |
1192 /** | 1239 /** |
1193 * @return Whether or not the {@link ContentViewCore} is using a desktop use
r agent. | 1240 * @return Whether or not the {@link ContentViewCore} is using a desktop use
r agent. |
1194 */ | 1241 */ |
1195 public boolean getUseDesktopUserAgent() { | 1242 public boolean getUseDesktopUserAgent() { |
1196 return getWebContents() != null && getWebContents().getNavigationControl
ler() | 1243 return getWebContents() != null |
1197 .getUseDesktopUserAgent(); | 1244 && getWebContents().getNavigationController().getUseDesktopUserA
gent(); |
1198 } | 1245 } |
1199 | 1246 |
1200 /** | 1247 /** |
1201 * @return The current {@link ConnectionSecurityLevel} for the tab. | 1248 * @return The current {@link ConnectionSecurityLevel} for the tab. |
1202 */ | 1249 */ |
1203 // TODO(tedchoc): Remove this and transition all clients to use ToolbarModel
directly. | 1250 // TODO(tedchoc): Remove this and transition all clients to use ToolbarModel
directly. |
1204 public int getSecurityLevel() { | 1251 public int getSecurityLevel() { |
1205 return SecurityStateModel.getSecurityLevelForWebContents(getWebContents(
)); | 1252 return SecurityStateModel.getSecurityLevelForWebContents(getWebContents(
)); |
1206 } | 1253 } |
1207 | 1254 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1427 TraceEvent.begin("Tab.initialize"); | 1474 TraceEvent.begin("Tab.initialize"); |
1428 | 1475 |
1429 mDelegateFactory = delegateFactory; | 1476 mDelegateFactory = delegateFactory; |
1430 initializeNative(); | 1477 initializeNative(); |
1431 | 1478 |
1432 RevenueStats.getInstance().tabCreated(this); | 1479 RevenueStats.getInstance().tabCreated(this); |
1433 | 1480 |
1434 mTopControlsVisibilityDelegate = | 1481 mTopControlsVisibilityDelegate = |
1435 mDelegateFactory.createTopControlsVisibilityDelegate(this); | 1482 mDelegateFactory.createTopControlsVisibilityDelegate(this); |
1436 | 1483 |
| 1484 mBlimp = BlimpClientContextFactory |
| 1485 .getBlimpClientContextForProfile( |
| 1486 Profile.getLastUsedProfile().getOriginalPro
file()) |
| 1487 .isBlimpEnabled() |
| 1488 && !mIncognito; |
| 1489 |
1437 // Attach the TabContentManager if we have one. This will bind this
Tab's content layer | 1490 // Attach the TabContentManager if we have one. This will bind this
Tab's content layer |
1438 // to this manager. | 1491 // to this manager. |
1439 // TODO(dtrainor): Remove this and move to a pull model instead of p
ushing the layer. | 1492 // TODO(dtrainor): Remove this and move to a pull model instead of p
ushing the layer. |
1440 attachTabContentManager(tabContentManager); | 1493 attachTabContentManager(tabContentManager); |
1441 | 1494 |
1442 // If there is a frozen WebContents state or a pending lazy load, do
n't create a new | 1495 // If there is a frozen WebContents state or a pending lazy load, do
n't create a new |
1443 // WebContents. | 1496 // WebContents. |
1444 if (getFrozenContentsState() != null || getPendingLoadParams() != nu
ll) { | 1497 if (getFrozenContentsState() != null || getPendingLoadParams() != nu
ll) { |
1445 if (unfreeze) unfreezeContents(); | 1498 if (unfreeze) unfreezeContents(); |
1446 return; | 1499 return; |
1447 } | 1500 } |
1448 | 1501 |
| 1502 if (isBlimpTab() && getBlimpContents() == null) { |
| 1503 Profile profile = Profile.getLastUsedProfile(); |
| 1504 if (mIncognito) profile = profile.getOffTheRecordProfile(); |
| 1505 mBlimpContents = nativeInitBlimpContents(mNativeTabAndroid, prof
ile); |
| 1506 getBlimpContents().addObserver(new TabBlimpContentsObserver(this
)); |
| 1507 } |
| 1508 |
1449 boolean creatingWebContents = webContents == null; | 1509 boolean creatingWebContents = webContents == null; |
1450 if (creatingWebContents) { | 1510 if (creatingWebContents) { |
1451 webContents = WarmupManager.getInstance().takeSpareWebContents( | 1511 webContents = WarmupManager.getInstance().takeSpareWebContents( |
1452 isIncognito(), initiallyHidden); | 1512 isIncognito(), initiallyHidden); |
1453 if (webContents == null) { | 1513 if (webContents == null) { |
1454 webContents = | 1514 webContents = |
1455 WebContentsFactory.createWebContents(isIncognito(),
initiallyHidden); | 1515 WebContentsFactory.createWebContents(isIncognito(),
initiallyHidden); |
1456 } | 1516 } |
1457 } | 1517 } |
1458 | 1518 |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2010 if (mTabUma != null) mTabUma.onDestroy(); | 2070 if (mTabUma != null) mTabUma.onDestroy(); |
2011 | 2071 |
2012 for (TabObserver observer : mObservers) observer.onDestroyed(this); | 2072 for (TabObserver observer : mObservers) observer.onDestroyed(this); |
2013 mObservers.clear(); | 2073 mObservers.clear(); |
2014 | 2074 |
2015 NativePage currentNativePage = mNativePage; | 2075 NativePage currentNativePage = mNativePage; |
2016 mNativePage = null; | 2076 mNativePage = null; |
2017 destroyNativePageInternal(currentNativePage); | 2077 destroyNativePageInternal(currentNativePage); |
2018 destroyContentViewCore(true); | 2078 destroyContentViewCore(true); |
2019 | 2079 |
| 2080 // Native part of BlimpContents is destroyed on the subsequent call to n
ativeDestroy. |
| 2081 mBlimpContents = null; |
| 2082 |
2020 // Destroys the native tab after destroying the ContentView but before d
estroying the | 2083 // Destroys the native tab after destroying the ContentView but before d
estroying the |
2021 // InfoBarContainer. The native tab should be destroyed before the infob
ar container as | 2084 // InfoBarContainer. The native tab should be destroyed before the infob
ar container as |
2022 // destroying the native tab cleanups up any remaining infobars. The inf
obar container | 2085 // destroying the native tab cleanups up any remaining infobars. The inf
obar container |
2023 // expects all infobars to be cleaned up before its own destruction. | 2086 // expects all infobars to be cleaned up before its own destruction. |
2024 assert mNativeTabAndroid != 0; | 2087 assert mNativeTabAndroid != 0; |
2025 nativeDestroy(mNativeTabAndroid); | 2088 nativeDestroy(mNativeTabAndroid); |
2026 assert mNativeTabAndroid == 0; | 2089 assert mNativeTabAndroid == 0; |
2027 | 2090 |
2028 if (mInfoBarContainer != null) { | 2091 if (mInfoBarContainer != null) { |
2029 mInfoBarContainer.destroy(); | 2092 mInfoBarContainer.destroy(); |
(...skipping 14 matching lines...) Expand all Loading... |
2044 return mIsInitialized; | 2107 return mIsInitialized; |
2045 } | 2108 } |
2046 | 2109 |
2047 /** | 2110 /** |
2048 * @return The URL associated with the tab. | 2111 * @return The URL associated with the tab. |
2049 */ | 2112 */ |
2050 @CalledByNative | 2113 @CalledByNative |
2051 public String getUrl() { | 2114 public String getUrl() { |
2052 String url = getWebContents() != null ? getWebContents().getUrl() : ""; | 2115 String url = getWebContents() != null ? getWebContents().getUrl() : ""; |
2053 | 2116 |
| 2117 if (isBlimpTab() && getBlimpContents() != null) { |
| 2118 url = getBlimpContents().getNavigationController().getUrl(); |
| 2119 } |
| 2120 |
2054 // If we have a ContentView, or a NativePage, or the url is not empty, w
e have a WebContents | 2121 // If we have a ContentView, or a NativePage, or the url is not empty, w
e have a WebContents |
2055 // so cache the WebContent's url. If not use the cached version. | 2122 // so cache the WebContent's url. If not use the cached version. |
2056 if (getContentViewCore() != null || getNativePage() != null || !TextUtil
s.isEmpty(url)) { | 2123 if (getContentViewCore() != null || getNativePage() != null || !TextUtil
s.isEmpty(url)) { |
2057 mUrl = url; | 2124 mUrl = url; |
2058 } | 2125 } |
2059 | 2126 |
2060 return mUrl != null ? mUrl : ""; | 2127 return mUrl != null ? mUrl : ""; |
2061 } | 2128 } |
2062 | 2129 |
2063 /** | 2130 /** |
2064 * @return The tab title. | 2131 * @return The tab title. |
2065 */ | 2132 */ |
2066 @CalledByNative | 2133 @CalledByNative |
2067 public String getTitle() { | 2134 public String getTitle() { |
2068 if (mTitle == null) updateTitle(); | 2135 if (mTitle == null) updateTitle(); |
2069 return mTitle; | 2136 return mTitle; |
2070 } | 2137 } |
2071 | 2138 |
2072 void updateTitle() { | 2139 void updateTitle() { |
2073 if (isFrozen()) return; | 2140 if (isFrozen()) return; |
2074 | 2141 |
2075 // When restoring the tabs, the title will no longer be populated, so re
quest it from the | 2142 // When restoring the tabs, the title will no longer be populated, so re
quest it from the |
2076 // ContentViewCore or NativePage (if present). | 2143 // ContentViewCore or NativePage (if present). |
2077 String title = ""; | 2144 String title = ""; |
2078 if (mNativePage != null) { | 2145 if (mNativePage != null) { |
2079 title = mNativePage.getTitle(); | 2146 title = mNativePage.getTitle(); |
| 2147 } else if (getBlimpContents() != null) { |
| 2148 title = getBlimpContents().getNavigationController().getTitle(); |
2080 } else if (getWebContents() != null) { | 2149 } else if (getWebContents() != null) { |
2081 title = getWebContents().getTitle(); | 2150 title = getWebContents().getTitle(); |
2082 } | 2151 } |
2083 updateTitle(title); | 2152 updateTitle(title); |
2084 } | 2153 } |
2085 | 2154 |
2086 /** | 2155 /** |
2087 * Cache the title for the current page. | 2156 * Cache the title for the current page. |
2088 * | 2157 * |
2089 * {@link ContentViewClient#onUpdateTitle} is unreliable, particularly for n
avigating backwards | 2158 * {@link ContentViewClient#onUpdateTitle} is unreliable, particularly for n
avigating backwards |
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3235 String packageName = ContextUtils.getApplicationContext().getPackageName
(); | 3304 String packageName = ContextUtils.getApplicationContext().getPackageName
(); |
3236 return getLaunchType() == TabLaunchType.FROM_EXTERNAL_APP | 3305 return getLaunchType() == TabLaunchType.FROM_EXTERNAL_APP |
3237 && !TextUtils.equals(getAppAssociatedWith(), packageName); | 3306 && !TextUtils.equals(getAppAssociatedWith(), packageName); |
3238 } | 3307 } |
3239 | 3308 |
3240 private native void nativeInit(); | 3309 private native void nativeInit(); |
3241 private native void nativeDestroy(long nativeTabAndroid); | 3310 private native void nativeDestroy(long nativeTabAndroid); |
3242 private native void nativeInitWebContents(long nativeTabAndroid, boolean inc
ognito, | 3311 private native void nativeInitWebContents(long nativeTabAndroid, boolean inc
ognito, |
3243 WebContents webContents, TabWebContentsDelegateAndroid delegate, | 3312 WebContents webContents, TabWebContentsDelegateAndroid delegate, |
3244 ContextMenuPopulator contextMenuPopulator); | 3313 ContextMenuPopulator contextMenuPopulator); |
| 3314 private native BlimpContents nativeInitBlimpContents(long nativeTabAndroid,
Profile profile); |
3245 private native void nativeUpdateDelegates(long nativeTabAndroid, | 3315 private native void nativeUpdateDelegates(long nativeTabAndroid, |
3246 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context
MenuPopulator); | 3316 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context
MenuPopulator); |
3247 private native void nativeDestroyWebContents(long nativeTabAndroid, boolean
deleteNative); | 3317 private native void nativeDestroyWebContents(long nativeTabAndroid, boolean
deleteNative); |
3248 private native Profile nativeGetProfileAndroid(long nativeTabAndroid); | 3318 private native Profile nativeGetProfileAndroid(long nativeTabAndroid); |
3249 private native int nativeLoadUrl(long nativeTabAndroid, String url, String e
xtraHeaders, | 3319 private native int nativeLoadUrl(long nativeTabAndroid, String url, String e
xtraHeaders, |
3250 ResourceRequestBody postData, int transition, String referrerUrl, in
t referrerPolicy, | 3320 ResourceRequestBody postData, int transition, String referrerUrl, in
t referrerPolicy, |
3251 boolean isRendererInitiated, boolean shoulReplaceCurrentEntry, | 3321 boolean isRendererInitiated, boolean shoulReplaceCurrentEntry, |
3252 long intentReceivedTimestamp, boolean hasUserGesture); | 3322 long intentReceivedTimestamp, boolean hasUserGesture); |
3253 private native void nativeSetActiveNavigationEntryTitleForUrl(long nativeTab
Android, String url, | 3323 private native void nativeSetActiveNavigationEntryTitleForUrl(long nativeTab
Android, String url, |
3254 String title); | 3324 String title); |
3255 private native boolean nativePrint(long nativeTabAndroid); | 3325 private native boolean nativePrint(long nativeTabAndroid); |
3256 private native Bitmap nativeGetFavicon(long nativeTabAndroid); | 3326 private native Bitmap nativeGetFavicon(long nativeTabAndroid); |
3257 private native void nativeCreateHistoricalTab(long nativeTabAndroid); | 3327 private native void nativeCreateHistoricalTab(long nativeTabAndroid); |
3258 private native void nativeUpdateTopControlsState( | 3328 private native void nativeUpdateTopControlsState( |
3259 long nativeTabAndroid, int constraints, int current, boolean animate
); | 3329 long nativeTabAndroid, int constraints, int current, boolean animate
); |
3260 private native void nativeLoadOriginalImage(long nativeTabAndroid); | 3330 private native void nativeLoadOriginalImage(long nativeTabAndroid); |
3261 private native long nativeGetBookmarkId(long nativeTabAndroid, boolean onlyE
ditable); | 3331 private native long nativeGetBookmarkId(long nativeTabAndroid, boolean onlyE
ditable); |
3262 private native boolean nativeIsOfflinePage(long nativeTabAndroid); | 3332 private native boolean nativeIsOfflinePage(long nativeTabAndroid); |
3263 private native OfflinePageItem nativeGetOfflinePage(long nativeTabAndroid); | 3333 private native OfflinePageItem nativeGetOfflinePage(long nativeTabAndroid); |
3264 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro
id, | 3334 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro
id, |
3265 InterceptNavigationDelegate delegate); | 3335 InterceptNavigationDelegate delegate); |
3266 private native void nativeAttachToTabContentManager(long nativeTabAndroid, | 3336 private native void nativeAttachToTabContentManager(long nativeTabAndroid, |
3267 TabContentManager tabContentManager); | 3337 TabContentManager tabContentManager); |
3268 private native void nativeAttachOverlayWebContents( | 3338 private native void nativeAttachOverlayWebContents( |
3269 long nativeTabAndroid, WebContents webContents, boolean visible); | 3339 long nativeTabAndroid, WebContents webContents, boolean visible); |
3270 private native void nativeDetachOverlayWebContents( | 3340 private native void nativeDetachOverlayWebContents( |
3271 long nativeTabAndroid, WebContents webContents); | 3341 long nativeTabAndroid, WebContents webContents); |
3272 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String
url); | 3342 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String
url); |
3273 } | 3343 } |
OLD | NEW |