Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java

Issue 2233023002: Adding BlimpNavigationController to Tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@nav_handler_remove
Patch Set: @nyquist feedback Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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.WebContentsFactory; 56 import org.chromium.chrome.browser.WebContentsFactory;
56 import org.chromium.chrome.browser.banners.AppBannerManager; 57 import org.chromium.chrome.browser.banners.AppBannerManager;
58 import org.chromium.chrome.browser.blimp.BlimpClientContextFactory;
57 import org.chromium.chrome.browser.bookmarks.BookmarkUtils; 59 import org.chromium.chrome.browser.bookmarks.BookmarkUtils;
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;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 final 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
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 <ContentViewCore>(); 215 private final List<ContentViewCore> mOverlayContentViewCores = new ArrayList <ContentViewCore>();
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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 mDefaultThemeColor = mIncognito 647 mDefaultThemeColor = mIncognito
642 ? ApiCompatibilityUtils.getColor(resources, R.color.incognit o_primary_color) 648 ? ApiCompatibilityUtils.getColor(resources, R.color.incognit o_primary_color)
643 : ApiCompatibilityUtils.getColor(resources, R.color.default_ primary_color); 649 : ApiCompatibilityUtils.getColor(resources, R.color.default_ primary_color);
644 mThemeColor = calculateThemeColor(false); 650 mThemeColor = calculateThemeColor(false);
645 } else { 651 } else {
646 mIdealFaviconSize = 16; 652 mIdealFaviconSize = 16;
647 mDefaultThemeColor = 0; 653 mDefaultThemeColor = 0;
648 mThemeColor = mDefaultThemeColor; 654 mThemeColor = mDefaultThemeColor;
649 } 655 }
650 656
657 mBlimp = BlimpClientContextFactory
David Trainor- moved to gerrit 2016/08/18 17:06:30 We should pass this into tab. Some tabs will not
shaktisahu 2016/08/18 19:36:06 Yes, the creator should pass this to tab. But that
658 .getBlimpClientContextForProfile(
659 Profile.getLastUsedProfile().getOriginalProfile ())
660 .isBlimpEnabled();
David Trainor- moved to gerrit 2016/08/18 18:28:19 && !mIsIncognito
shaktisahu 2016/08/18 19:36:06 Done.
661
651 // Restore data from the TabState, if it existed. 662 // Restore data from the TabState, if it existed.
652 if (frozenState != null) { 663 if (frozenState != null) {
653 assert type == TabLaunchType.FROM_RESTORE; 664 assert type == TabLaunchType.FROM_RESTORE;
654 restoreFieldsFromState(frozenState); 665 restoreFieldsFromState(frozenState);
655 } 666 }
656 667
657 setContentViewClient(new TabContentViewClient()); 668 setContentViewClient(new TabContentViewClient());
658 669
659 mHandler = new Handler() { 670 mHandler = new Handler() {
660 @Override 671 @Override
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 * @param observer The {@link TabObserver} to remove. 738 * @param observer The {@link TabObserver} to remove.
728 */ 739 */
729 public void removeObserver(TabObserver observer) { 740 public void removeObserver(TabObserver observer) {
730 mObservers.removeObserver(observer); 741 mObservers.removeObserver(observer);
731 } 742 }
732 743
733 /** 744 /**
734 * @return Whether or not this tab has a previous navigation entry. 745 * @return Whether or not this tab has a previous navigation entry.
735 */ 746 */
736 public boolean canGoBack() { 747 public boolean canGoBack() {
737 return getWebContents() != null && getWebContents().getNavigationControl ler().canGoBack(); 748 if (isBlimpTab()) {
749 return getBlimpContents() != null
750 && getBlimpContents().getNavigationController().canGoBack();
751 } else {
752 return getWebContents() != null
753 && getWebContents().getNavigationController().canGoBack();
754 }
738 } 755 }
739 756
740 /** 757 /**
741 * @return Whether or not this tab has a navigation entry after the current one. 758 * @return Whether or not this tab has a navigation entry after the current one.
742 */ 759 */
743 public boolean canGoForward() { 760 public boolean canGoForward() {
744 return getWebContents() != null && getWebContents().getNavigationControl ler() 761 if (isBlimpTab()) {
745 .canGoForward(); 762 return getBlimpContents() != null
763 && getBlimpContents().getNavigationController().canGoForward ();
764 } else {
765 return getWebContents() != null
766 && getWebContents().getNavigationController().canGoForward() ;
767 }
746 } 768 }
747 769
748 /** 770 /**
749 * Goes to the navigation entry before the current one. 771 * Goes to the navigation entry before the current one.
750 */ 772 */
751 public void goBack() { 773 public void goBack() {
752 if (getWebContents() != null) getWebContents().getNavigationController() .goBack(); 774 if (isBlimpTab()) {
775 if (getBlimpContents() != null) getBlimpContents().getNavigationCont roller().goBack();
776 } else {
777 if (getWebContents() != null) getWebContents().getNavigationControll er().goBack();
778 }
753 } 779 }
754 780
755 /** 781 /**
756 * Goes to the navigation entry after the current one. 782 * Goes to the navigation entry after the current one.
757 */ 783 */
758 public void goForward() { 784 public void goForward() {
759 if (getWebContents() != null) getWebContents().getNavigationController() .goForward(); 785 if (isBlimpTab()) {
786 if (getBlimpContents() != null) {
787 getBlimpContents().getNavigationController().goForward();
788 }
789 } else {
790 if (getWebContents() != null) getWebContents().getNavigationControll er().goForward();
791 }
760 } 792 }
761 793
762 /** 794 /**
763 * Loads the current navigation if there is a pending lazy load (after tab r estore). 795 * Loads the current navigation if there is a pending lazy load (after tab r estore).
764 */ 796 */
765 public void loadIfNecessary() { 797 public void loadIfNecessary() {
766 if (getWebContents() != null) getWebContents().getNavigationController() .loadIfNecessary(); 798 if (getWebContents() != null) getWebContents().getNavigationController() .loadIfNecessary();
767 } 799 }
768 800
769 /** 801 /**
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 1016
985 printingController.setPendingPrint(new TabPrinter(this), 1017 printingController.setPendingPrint(new TabPrinter(this),
986 new PrintManagerDelegateImpl(getActivity())); 1018 new PrintManagerDelegateImpl(getActivity()));
987 } 1019 }
988 1020
989 /** 1021 /**
990 * Reloads the current page content. 1022 * Reloads the current page content.
991 */ 1023 */
992 public void reload() { 1024 public void reload() {
993 // TODO(dtrainor): Should we try to rebuild the ContentView if it's froz en? 1025 // TODO(dtrainor): Should we try to rebuild the ContentView if it's froz en?
994 if (getWebContents() != null) getWebContents().getNavigationController() .reload(true); 1026 if (isBlimpTab()) {
1027 if (getBlimpContents() != null) {
1028 getBlimpContents().getNavigationController().reload();
1029 }
1030 } else {
1031 if (getWebContents() != null) getWebContents().getNavigationControll er().reload(true);
1032 }
995 } 1033 }
996 1034
997 /** 1035 /**
998 * Reloads the current page content. 1036 * Reloads the current page content.
999 * This version ignores the cache and reloads from the network. 1037 * This version ignores the cache and reloads from the network.
1000 */ 1038 */
1001 public void reloadIgnoringCache() { 1039 public void reloadIgnoringCache() {
1002 if (getWebContents() != null) { 1040 if (getWebContents() != null) {
1003 getWebContents().getNavigationController().reloadBypassingCache(true ); 1041 getWebContents().getNavigationController().reloadBypassingCache(true );
1004 } 1042 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 } 1163 }
1126 1164
1127 /** 1165 /**
1128 * @return The web contents associated with this tab. 1166 * @return The web contents associated with this tab.
1129 */ 1167 */
1130 public WebContents getWebContents() { 1168 public WebContents getWebContents() {
1131 return mContentViewCore != null ? mContentViewCore.getWebContents() : nu ll; 1169 return mContentViewCore != null ? mContentViewCore.getWebContents() : nu ll;
1132 } 1170 }
1133 1171
1134 /** 1172 /**
1173 * @return The {@link BlimpContents} associated with this tab, if in blimp m ode.
1174 */
1175 public BlimpContents getBlimpContents() {
1176 return mBlimpContents;
1177 }
1178
1179 /**
1180 * @return Whether or not this tab is running in blimp mode.
1181 */
1182 public boolean isBlimpTab() {
1183 return mBlimp;
1184 }
1185
1186 /**
1135 * @return The profile associated with this tab. 1187 * @return The profile associated with this tab.
1136 */ 1188 */
1137 public Profile getProfile() { 1189 public Profile getProfile() {
1138 if (mNativeTabAndroid == 0) return null; 1190 if (mNativeTabAndroid == 0) return null;
1139 return nativeGetProfileAndroid(mNativeTabAndroid); 1191 return nativeGetProfileAndroid(mNativeTabAndroid);
1140 } 1192 }
1141 1193
1142 /** 1194 /**
1143 * For more information about the uniqueness of {@link #getId()} see comment s on {@link Tab}. 1195 * For more information about the uniqueness of {@link #getId()} see comment s on {@link Tab}.
1144 * @see Tab 1196 * @see Tab
1145 * @return The id representing this tab. 1197 * @return The id representing this tab.
1146 */ 1198 */
1147 @CalledByNative 1199 @CalledByNative
1148 public int getId() { 1200 public int getId() {
1149 return mId; 1201 return mId;
1150 } 1202 }
1151 1203
1152 /** 1204 /**
1153 * @return Whether or not this tab is incognito. 1205 * @return Whether or not this tab is incognito.
1154 */ 1206 */
1207 @CalledByNative
1155 public boolean isIncognito() { 1208 public boolean isIncognito() {
1156 return mIncognito; 1209 return mIncognito;
1157 } 1210 }
1158 1211
1159 /** 1212 /**
1160 * @return The {@link ContentViewCore} associated with the current page, or {@code null} if 1213 * @return The {@link ContentViewCore} associated with the current page, or {@code null} if
1161 * there is no current page or the current page is displayed using a native view. 1214 * there is no current page or the current page is displayed using a native view.
1162 */ 1215 */
1163 public ContentViewCore getContentViewCore() { 1216 public ContentViewCore getContentViewCore() {
1164 return mNativePage == null ? mContentViewCore : null; 1217 return mNativePage == null ? mContentViewCore : null;
(...skipping 16 matching lines...) Expand all
1181 } 1234 }
1182 1235
1183 /** 1236 /**
1184 * Set whether or not the {@link ContentViewCore} should be using a desktop user agent for the 1237 * Set whether or not the {@link ContentViewCore} should be using a desktop user agent for the
1185 * currently loaded page. 1238 * currently loaded page.
1186 * @param useDesktop If {@code true}, use a desktop user agent. Otherwi se use a mobile one. 1239 * @param useDesktop If {@code true}, use a desktop user agent. Otherwi se use a mobile one.
1187 * @param reloadOnChange Reload the page if the user agent has changed. 1240 * @param reloadOnChange Reload the page if the user agent has changed.
1188 */ 1241 */
1189 public void setUseDesktopUserAgent(boolean useDesktop, boolean reloadOnChang e) { 1242 public void setUseDesktopUserAgent(boolean useDesktop, boolean reloadOnChang e) {
1190 if (getWebContents() != null) { 1243 if (getWebContents() != null) {
1191 getWebContents().getNavigationController() 1244 getWebContents().getNavigationController().setUseDesktopUserAgent(
1192 .setUseDesktopUserAgent(useDesktop, reloadOnChange); 1245 useDesktop, reloadOnChange);
1193 } 1246 }
1194 } 1247 }
1195 1248
1196 /** 1249 /**
1197 * @return Whether or not the {@link ContentViewCore} is using a desktop use r agent. 1250 * @return Whether or not the {@link ContentViewCore} is using a desktop use r agent.
1198 */ 1251 */
1199 public boolean getUseDesktopUserAgent() { 1252 public boolean getUseDesktopUserAgent() {
1200 return getWebContents() != null && getWebContents().getNavigationControl ler() 1253 return getWebContents() != null
1201 .getUseDesktopUserAgent(); 1254 && getWebContents().getNavigationController().getUseDesktopUserA gent();
1202 } 1255 }
1203 1256
1204 /** 1257 /**
1205 * @return The current {@link ConnectionSecurityLevel} for the tab. 1258 * @return The current {@link ConnectionSecurityLevel} for the tab.
1206 */ 1259 */
1207 // TODO(tedchoc): Remove this and transition all clients to use ToolbarModel directly. 1260 // TODO(tedchoc): Remove this and transition all clients to use ToolbarModel directly.
1208 public int getSecurityLevel() { 1261 public int getSecurityLevel() {
1209 return SecurityStateModel.getSecurityLevelForWebContents(getWebContents( )); 1262 return SecurityStateModel.getSecurityLevelForWebContents(getWebContents( ));
1210 } 1263 }
1211 1264
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 // TODO(dtrainor): Remove this and move to a pull model instead of p ushing the layer. 1496 // TODO(dtrainor): Remove this and move to a pull model instead of p ushing the layer.
1444 attachTabContentManager(tabContentManager); 1497 attachTabContentManager(tabContentManager);
1445 1498
1446 // If there is a frozen WebContents state or a pending lazy load, do n't create a new 1499 // If there is a frozen WebContents state or a pending lazy load, do n't create a new
1447 // WebContents. 1500 // WebContents.
1448 if (getFrozenContentsState() != null || getPendingLoadParams() != nu ll) { 1501 if (getFrozenContentsState() != null || getPendingLoadParams() != nu ll) {
1449 if (unfreeze) unfreezeContents(); 1502 if (unfreeze) unfreezeContents();
1450 return; 1503 return;
1451 } 1504 }
1452 1505
1506 if (isBlimpTab() && getBlimpContents() == null) {
1507 nativeInitBlimpContents(mNativeTabAndroid);
David Trainor- moved to gerrit 2016/08/18 17:06:30 Can we just return the BlimpContents from this?
shaktisahu 2016/08/18 19:36:06 Done. Removing the nativeGetBlimpContents method.
1508 mBlimpContents = nativeGetBlimpContents(mNativeTabAndroid);
1509 getBlimpContents().addObserver(new TabBlimpContentsObserver(this ));
1510 }
1511
1453 boolean creatingWebContents = webContents == null; 1512 boolean creatingWebContents = webContents == null;
1454 if (creatingWebContents) { 1513 if (creatingWebContents) {
1455 webContents = WebContentsFactory.createWebContents(isIncognito() , initiallyHidden); 1514 webContents = WebContentsFactory.createWebContents(isIncognito() , initiallyHidden);
1456 } 1515 }
1457 1516
1458 ContentViewCore contentViewCore = ContentViewCore.fromWebContents(we bContents); 1517 ContentViewCore contentViewCore = ContentViewCore.fromWebContents(we bContents);
1459 1518
1460 if (contentViewCore == null) { 1519 if (contentViewCore == null) {
1461 initContentViewCore(webContents); 1520 initContentViewCore(webContents);
1462 } else { 1521 } else {
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
2009 if (mTabUma != null) mTabUma.onDestroy(); 2068 if (mTabUma != null) mTabUma.onDestroy();
2010 2069
2011 for (TabObserver observer : mObservers) observer.onDestroyed(this); 2070 for (TabObserver observer : mObservers) observer.onDestroyed(this);
2012 mObservers.clear(); 2071 mObservers.clear();
2013 2072
2014 NativePage currentNativePage = mNativePage; 2073 NativePage currentNativePage = mNativePage;
2015 mNativePage = null; 2074 mNativePage = null;
2016 destroyNativePageInternal(currentNativePage); 2075 destroyNativePageInternal(currentNativePage);
2017 destroyContentViewCore(true); 2076 destroyContentViewCore(true);
2018 2077
2078 mBlimpContents = null;
David Trainor- moved to gerrit 2016/08/18 17:06:30 Who destroys this? When do we drop the native poi
shaktisahu 2016/08/18 19:36:06 The native pointer is a unique_ptr owned by TabAnd
David Trainor- moved to gerrit 2016/08/22 21:30:00 Can you add a comment to that effect? Thanks!
2079
2019 // Destroys the native tab after destroying the ContentView but before d estroying the 2080 // Destroys the native tab after destroying the ContentView but before d estroying the
2020 // InfoBarContainer. The native tab should be destroyed before the infob ar container as 2081 // InfoBarContainer. The native tab should be destroyed before the infob ar container as
2021 // destroying the native tab cleanups up any remaining infobars. The inf obar container 2082 // destroying the native tab cleanups up any remaining infobars. The inf obar container
2022 // expects all infobars to be cleaned up before its own destruction. 2083 // expects all infobars to be cleaned up before its own destruction.
2023 assert mNativeTabAndroid != 0; 2084 assert mNativeTabAndroid != 0;
2024 nativeDestroy(mNativeTabAndroid); 2085 nativeDestroy(mNativeTabAndroid);
2025 assert mNativeTabAndroid == 0; 2086 assert mNativeTabAndroid == 0;
2026 2087
2027 if (mInfoBarContainer != null) { 2088 if (mInfoBarContainer != null) {
2028 mInfoBarContainer.destroy(); 2089 mInfoBarContainer.destroy();
(...skipping 14 matching lines...) Expand all
2043 return mIsInitialized; 2104 return mIsInitialized;
2044 } 2105 }
2045 2106
2046 /** 2107 /**
2047 * @return The URL associated with the tab. 2108 * @return The URL associated with the tab.
2048 */ 2109 */
2049 @CalledByNative 2110 @CalledByNative
2050 public String getUrl() { 2111 public String getUrl() {
2051 String url = getWebContents() != null ? getWebContents().getUrl() : ""; 2112 String url = getWebContents() != null ? getWebContents().getUrl() : "";
2052 2113
2114 if (isBlimpTab() && getBlimpContents() != null) {
2115 url = getBlimpContents().getNavigationController().getUrl();
2116 }
2117
2053 // If we have a ContentView, or a NativePage, or the url is not empty, w e have a WebContents 2118 // If we have a ContentView, or a NativePage, or the url is not empty, w e have a WebContents
2054 // so cache the WebContent's url. If not use the cached version. 2119 // so cache the WebContent's url. If not use the cached version.
2055 if (getContentViewCore() != null || getNativePage() != null || !TextUtil s.isEmpty(url)) { 2120 if (getContentViewCore() != null || getNativePage() != null || !TextUtil s.isEmpty(url)) {
2056 mUrl = url; 2121 mUrl = url;
2057 } 2122 }
2058 2123
2059 return mUrl != null ? mUrl : ""; 2124 return mUrl != null ? mUrl : "";
2060 } 2125 }
2061 2126
2062 /** 2127 /**
2063 * @return The tab title. 2128 * @return The tab title.
2064 */ 2129 */
2065 @CalledByNative 2130 @CalledByNative
2066 public String getTitle() { 2131 public String getTitle() {
2067 if (mTitle == null) updateTitle(); 2132 if (mTitle == null) updateTitle();
2068 return mTitle; 2133 return mTitle;
2069 } 2134 }
2070 2135
2071 void updateTitle() { 2136 void updateTitle() {
2072 if (isFrozen()) return; 2137 if (isFrozen()) return;
2073 2138
2074 // When restoring the tabs, the title will no longer be populated, so re quest it from the 2139 // When restoring the tabs, the title will no longer be populated, so re quest it from the
2075 // ContentViewCore or NativePage (if present). 2140 // ContentViewCore or NativePage (if present).
2076 String title = ""; 2141 String title = "";
2077 if (mNativePage != null) { 2142 if (mNativePage != null) {
2078 title = mNativePage.getTitle(); 2143 title = mNativePage.getTitle();
2144 } else if (getBlimpContents() != null) {
2145 title = getBlimpContents().getNavigationController().getTitle();
2079 } else if (getWebContents() != null) { 2146 } else if (getWebContents() != null) {
2080 title = getWebContents().getTitle(); 2147 title = getWebContents().getTitle();
2081 } 2148 }
2082 updateTitle(title); 2149 updateTitle(title);
2083 } 2150 }
2084 2151
2085 /** 2152 /**
2086 * Cache the title for the current page. 2153 * Cache the title for the current page.
2087 * 2154 *
2088 * {@link ContentViewClient#onUpdateTitle} is unreliable, particularly for n avigating backwards 2155 * {@link ContentViewClient#onUpdateTitle} is unreliable, particularly for n avigating backwards
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after
3244 String packageName = ContextUtils.getApplicationContext().getPackageName (); 3311 String packageName = ContextUtils.getApplicationContext().getPackageName ();
3245 return getLaunchType() == TabLaunchType.FROM_EXTERNAL_APP 3312 return getLaunchType() == TabLaunchType.FROM_EXTERNAL_APP
3246 && !TextUtils.equals(getAppAssociatedWith(), packageName); 3313 && !TextUtils.equals(getAppAssociatedWith(), packageName);
3247 } 3314 }
3248 3315
3249 private native void nativeInit(); 3316 private native void nativeInit();
3250 private native void nativeDestroy(long nativeTabAndroid); 3317 private native void nativeDestroy(long nativeTabAndroid);
3251 private native void nativeInitWebContents(long nativeTabAndroid, boolean inc ognito, 3318 private native void nativeInitWebContents(long nativeTabAndroid, boolean inc ognito,
3252 WebContents webContents, TabWebContentsDelegateAndroid delegate, 3319 WebContents webContents, TabWebContentsDelegateAndroid delegate,
3253 ContextMenuPopulator contextMenuPopulator); 3320 ContextMenuPopulator contextMenuPopulator);
3321 private native void nativeInitBlimpContents(long nativeTabAndroid);
David Trainor- moved to gerrit 2016/08/18 18:28:19 Make this take a profile? Profile profile = Profi
3322 private native BlimpContents nativeGetBlimpContents(long nativeTabAndroid);
3254 private native void nativeUpdateDelegates(long nativeTabAndroid, 3323 private native void nativeUpdateDelegates(long nativeTabAndroid,
3255 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator); 3324 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator);
3256 private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative); 3325 private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative);
3257 private native Profile nativeGetProfileAndroid(long nativeTabAndroid); 3326 private native Profile nativeGetProfileAndroid(long nativeTabAndroid);
3258 private native int nativeLoadUrl(long nativeTabAndroid, String url, String e xtraHeaders, 3327 private native int nativeLoadUrl(long nativeTabAndroid, String url, String e xtraHeaders,
3259 ResourceRequestBody postData, int transition, String referrerUrl, in t referrerPolicy, 3328 ResourceRequestBody postData, int transition, String referrerUrl, in t referrerPolicy,
3260 boolean isRendererInitiated, boolean shoulReplaceCurrentEntry, 3329 boolean isRendererInitiated, boolean shoulReplaceCurrentEntry,
3261 long intentReceivedTimestamp, boolean hasUserGesture); 3330 long intentReceivedTimestamp, boolean hasUserGesture);
3262 private native void nativeSetActiveNavigationEntryTitleForUrl(long nativeTab Android, String url, 3331 private native void nativeSetActiveNavigationEntryTitleForUrl(long nativeTab Android, String url,
3263 String title); 3332 String title);
(...skipping 10 matching lines...) Expand all
3274 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro id, 3343 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro id,
3275 InterceptNavigationDelegate delegate); 3344 InterceptNavigationDelegate delegate);
3276 private native void nativeAttachToTabContentManager(long nativeTabAndroid, 3345 private native void nativeAttachToTabContentManager(long nativeTabAndroid,
3277 TabContentManager tabContentManager); 3346 TabContentManager tabContentManager);
3278 private native void nativeAttachOverlayWebContents( 3347 private native void nativeAttachOverlayWebContents(
3279 long nativeTabAndroid, WebContents webContents, boolean visible); 3348 long nativeTabAndroid, WebContents webContents, boolean visible);
3280 private native void nativeDetachOverlayWebContents( 3349 private native void nativeDetachOverlayWebContents(
3281 long nativeTabAndroid, WebContents webContents); 3350 long nativeTabAndroid, WebContents webContents);
3282 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String url); 3351 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String url);
3283 } 3352 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698