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

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

Issue 908093003: Revert of Add support for ContentViewCore helpers on Tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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; 5 package org.chromium.chrome.browser;
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.graphics.Bitmap; 9 import android.graphics.Bitmap;
10 import android.graphics.Color; 10 import android.graphics.Color;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 import org.chromium.printing.PrintingController; 56 import org.chromium.printing.PrintingController;
57 import org.chromium.printing.PrintingControllerImpl; 57 import org.chromium.printing.PrintingControllerImpl;
58 import org.chromium.ui.WindowOpenDisposition; 58 import org.chromium.ui.WindowOpenDisposition;
59 import org.chromium.ui.base.Clipboard; 59 import org.chromium.ui.base.Clipboard;
60 import org.chromium.ui.base.LocalizationUtils; 60 import org.chromium.ui.base.LocalizationUtils;
61 import org.chromium.ui.base.PageTransition; 61 import org.chromium.ui.base.PageTransition;
62 import org.chromium.ui.base.WindowAndroid; 62 import org.chromium.ui.base.WindowAndroid;
63 import org.chromium.ui.gfx.DeviceDisplayInfo; 63 import org.chromium.ui.gfx.DeviceDisplayInfo;
64 64
65 import java.nio.ByteBuffer; 65 import java.nio.ByteBuffer;
66 import java.util.ArrayList;
67 import java.util.List;
68 import java.util.concurrent.atomic.AtomicInteger; 66 import java.util.concurrent.atomic.AtomicInteger;
69 67
70 /** 68 /**
71 * The basic Java representation of a tab. Contains and manages a {@link Conten tView}. 69 * The basic Java representation of a tab. Contains and manages a {@link Conten tView}.
72 * 70 *
73 * Tab provides common functionality for ChromeShell Tab as well as Chrome on An droid's 71 * Tab provides common functionality for ChromeShell Tab as well as Chrome on An droid's
74 * tab. It is intended to be extended either on Java or both Java and C++, with ownership managed 72 * tab. It is intended to be extended either on Java or both Java and C++, with ownership managed
75 * by this base class. 73 * by this base class.
76 * 74 *
77 * Extending just Java: 75 * Extending just Java:
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 145
148 /** {@link ContentViewCore} showing the current page, or {@code null} if the tab is frozen. */ 146 /** {@link ContentViewCore} showing the current page, or {@code null} if the tab is frozen. */
149 private ContentViewCore mContentViewCore; 147 private ContentViewCore mContentViewCore;
150 148
151 /** The parent view of the ContentView and the InfoBarContainer. */ 149 /** The parent view of the ContentView and the InfoBarContainer. */
152 private FrameLayout mContentViewParent; 150 private FrameLayout mContentViewParent;
153 151
154 /** A list of Tab observers. These are used to broadcast Tab events to list eners. */ 152 /** A list of Tab observers. These are used to broadcast Tab events to list eners. */
155 private final ObserverList<TabObserver> mObservers = new ObserverList<TabObs erver>(); 153 private final ObserverList<TabObserver> mObservers = new ObserverList<TabObs erver>();
156 154
157 /**
158 * A list of {@link ContentViewCore} overlay objects that are managed by ext ernal components but
159 * need to be sized and rendered along side this {@link Tab}s content.
160 */
161 private final List<ContentViewCore> mOverlayContentViewCores = new ArrayList <ContentViewCore>();
162
163 // Content layer Observers and Delegates 155 // Content layer Observers and Delegates
164 private ContentViewClient mContentViewClient; 156 private ContentViewClient mContentViewClient;
165 private WebContentsObserver mWebContentsObserver; 157 private WebContentsObserver mWebContentsObserver;
166 private VoiceSearchTabHelper mVoiceSearchTabHelper; 158 private VoiceSearchTabHelper mVoiceSearchTabHelper;
167 private TabChromeWebContentsDelegateAndroid mWebContentsDelegate; 159 private TabChromeWebContentsDelegateAndroid mWebContentsDelegate;
168 private DomDistillerFeedbackReporter mDomDistillerFeedbackReporter; 160 private DomDistillerFeedbackReporter mDomDistillerFeedbackReporter;
169 161
170 /** 162 /**
171 * If this tab was opened from another tab, store the id of the tab that 163 * If this tab was opened from another tab, store the id of the tab that
172 * caused it to be opened so that we can activate it when this tab gets 164 * caused it to be opened so that we can activate it when this tab gets
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 * Initializes {@link Tab} with {@code webContents}. If {@code webContents} is {@code null} a 1197 * Initializes {@link Tab} with {@code webContents}. If {@code webContents} is {@code null} a
1206 * new {@link WebContents} will be created for this {@link Tab}. 1198 * new {@link WebContents} will be created for this {@link Tab}.
1207 * @param webContents A {@link WebContents} object or {@code null} if one should be 1199 * @param webContents A {@link WebContents} object or {@code null} if one should be
1208 * created. 1200 * created.
1209 * @param tabContentManager A {@link TabContentManager} instance or {@code n ull} if the web 1201 * @param tabContentManager A {@link TabContentManager} instance or {@code n ull} if the web
1210 * content will be managed/displayed manually. 1202 * content will be managed/displayed manually.
1211 * @param initiallyHidden Only used if {@code webContents} is {@code null} . Determines 1203 * @param initiallyHidden Only used if {@code webContents} is {@code null} . Determines
1212 * whether or not the newly created {@link WebConte nts} will be hidden 1204 * whether or not the newly created {@link WebConte nts} will be hidden
1213 * or not. 1205 * or not.
1214 */ 1206 */
1215 public final void initialize(WebContents webContents, TabContentManager tabC ontentManager, 1207 public void initialize(WebContents webContents, TabContentManager tabContent Manager,
1216 boolean initiallyHidden) { 1208 boolean initiallyHidden) {
1217 try { 1209 try {
1218 TraceEvent.begin("Tab.initialize"); 1210 TraceEvent.begin("Tab.initialize");
1219 1211
1220 internalInit(); 1212 internalInit(tabContentManager);
1221
1222 // Attach the TabContentManager if we have one. This will bind this Tab's content layer
1223 // to this manager.
1224 // TODO(dtrainor): Remove this and move to a pull model instead of p ushing the layer.
1225 nativeAttachToTabContentManager(mNativeTabAndroid, tabContentManager );
1226 1213
1227 // If there is a frozen WebContents state or a pending lazy load, do n't create a new 1214 // If there is a frozen WebContents state or a pending lazy load, do n't create a new
1228 // WebContents. 1215 // WebContents.
1229 if (getFrozenContentsState() != null || getPendingLoadParams() != nu ll) return; 1216 if (getFrozenContentsState() != null || getPendingLoadParams() != nu ll) return;
1230 1217
1231 boolean creatingWebContents = webContents == null; 1218 boolean creatingWebContents = webContents == null;
1232 if (creatingWebContents) { 1219 if (creatingWebContents) {
1233 webContents = ContentViewUtil.createWebContents(isIncognito(), i nitiallyHidden); 1220 webContents = ContentViewUtil.createWebContents(isIncognito(), i nitiallyHidden);
1234 } 1221 }
1235 1222
(...skipping 12 matching lines...) Expand all
1248 if (mTimestampMillis == INVALID_TIMESTAMP) { 1235 if (mTimestampMillis == INVALID_TIMESTAMP) {
1249 mTimestampMillis = System.currentTimeMillis(); 1236 mTimestampMillis = System.currentTimeMillis();
1250 } 1237 }
1251 1238
1252 TraceEvent.end("Tab.initialize"); 1239 TraceEvent.end("Tab.initialize");
1253 } 1240 }
1254 } 1241 }
1255 1242
1256 /** 1243 /**
1257 * Perform any class-specific initialization tasks. 1244 * Perform any class-specific initialization tasks.
1245 * @param tabContentManager A {@link TabContentManager} instance or {@code n ull} if the web
1246 * content will be managed/displayed manually.
1258 */ 1247 */
1259 protected void internalInit() { 1248 protected void internalInit(TabContentManager tabContentManager) {
1260 initializeNative(); 1249 initializeNative();
1261 1250
1262 if (AppBannerManager.isEnabled()) { 1251 if (AppBannerManager.isEnabled()) {
1263 mAppBannerManager = new AppBannerManager(this); 1252 mAppBannerManager = new AppBannerManager(this);
1264 addObserver(mAppBannerManager); 1253 addObserver(mAppBannerManager);
1265 } 1254 }
1266 } 1255 }
1267 1256
1268 /** 1257 /**
1269 * Used to get a list of Android {@link View}s that represent both the norma l content as well as
1270 * overlays.
1271 * @param content A {@link List} that will be populated with {@link View}s t hat represent all of
1272 * the content in this {@link Tab}.
1273 */
1274 public void getAllViews(List<View> content) {
1275 content.add(getView());
1276 for (int i = 0; i < mOverlayContentViewCores.size(); i++) {
1277 content.add(mOverlayContentViewCores.get(i).getContainerView());
1278 }
1279 }
1280
1281 /**
1282 * Used to get a list of {@link ContentViewCore}s that represent both the no rmal content as well
1283 * as overlays. These are all {@link ContentViewCore}s currently showing or rendering content
1284 * for this {@link Tab}.
1285 * @param content A {@link List} that will be populated with {@link ContentV iewCore}s currently
1286 * rendering content related to this {@link Tab}.
1287 */
1288 public void getAllContentViewCores(List<ContentViewCore> content) {
1289 content.add(mContentViewCore);
1290 for (int i = 0; i < mOverlayContentViewCores.size(); i++) {
1291 content.add(mOverlayContentViewCores.get(i));
1292 }
1293 }
1294
1295 /**
1296 * Adds a {@link ContentViewCore} to this {@link Tab} as an overlay object. This
1297 * {@link ContentViewCore} will be attached to the CC layer hierarchy and ha ve all layout events
1298 * propagated to it. This {@link ContentViewCore} can be removed via
1299 * {@link #detachOverlayContentViewCore(ContentViewCore)}.
1300 * @param content The {@link ContentViewCore} to attach.
1301 * @param visible Whether or not to make the content visible.
1302 */
1303 public void attachOverlayContentViewCore(ContentViewCore content, boolean vi sible) {
1304 if (content == null) return;
1305
1306 assert !mOverlayContentViewCores.contains(content);
1307 mOverlayContentViewCores.add(content);
1308 nativeAttachOverlayContentViewCore(mNativeTabAndroid, content, visible);
1309 for (TabObserver observer : mObservers) {
1310 observer.onOverlayContentViewCoreAdded(this, content);
1311 }
1312 }
1313
1314 /**
1315 * Removes a {@link ContentViewCore} overlay object from this {@link Tab}. This
1316 * {@link ContentViewCore} must have previously been added via
1317 * {@link #attachOverlayContentViewCore(ContentViewCore, boolean)}.
1318 * @param content The {@link ContentViewCore} to detach.
1319 */
1320 public void detachOverlayContentViewCore(ContentViewCore content) {
1321 if (content == null) return;
1322
1323 for (TabObserver observer : mObservers) {
1324 observer.onOverlayContentViewCoreRemoved(this, content);
1325 }
1326
1327 assert mOverlayContentViewCores.contains(content);
1328 mOverlayContentViewCores.remove(content);
1329
1330 nativeDetachOverlayContentViewCore(mNativeTabAndroid, content);
1331 }
1332
1333 /**
1334 * Called when a page has started loading. 1258 * Called when a page has started loading.
1335 * @param validatedUrl URL being loaded. 1259 * @param validatedUrl URL being loaded.
1336 * @param showingErrorPage Whether an error page is being shown. 1260 * @param showingErrorPage Whether an error page is being shown.
1337 */ 1261 */
1338 protected void didStartPageLoad(String validatedUrl, boolean showingErrorPag e) { 1262 protected void didStartPageLoad(String validatedUrl, boolean showingErrorPag e) {
1339 mIsShowingErrorPage = showingErrorPage; 1263 mIsShowingErrorPage = showingErrorPage;
1340 1264
1341 updateTitle(); 1265 updateTitle();
1342 removeSadTabIfPresent(); 1266 removeSadTabIfPresent();
1343 1267
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2460 private native void nativeSetActiveNavigationEntryTitleForUrl(long nativeTab Android, String url, 2384 private native void nativeSetActiveNavigationEntryTitleForUrl(long nativeTab Android, String url,
2461 String title); 2385 String title);
2462 private native boolean nativePrint(long nativeTabAndroid); 2386 private native boolean nativePrint(long nativeTabAndroid);
2463 private native Bitmap nativeGetFavicon(long nativeTabAndroid); 2387 private native Bitmap nativeGetFavicon(long nativeTabAndroid);
2464 private native void nativeCreateHistoricalTab(long nativeTabAndroid); 2388 private native void nativeCreateHistoricalTab(long nativeTabAndroid);
2465 private native void nativeUpdateTopControlsState( 2389 private native void nativeUpdateTopControlsState(
2466 long nativeTabAndroid, int constraints, int current, boolean animate ); 2390 long nativeTabAndroid, int constraints, int current, boolean animate );
2467 private native void nativeSearchByImageInNewTabAsync(long nativeTabAndroid); 2391 private native void nativeSearchByImageInNewTabAsync(long nativeTabAndroid);
2468 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro id, 2392 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro id,
2469 InterceptNavigationDelegate delegate); 2393 InterceptNavigationDelegate delegate);
2470 private native void nativeAttachToTabContentManager(long nativeTabAndroid,
2471 TabContentManager tabContentManager);
2472 private native void nativeAttachOverlayContentViewCore(long nativeTabAndroid ,
2473 ContentViewCore content, boolean visible);
2474 private native void nativeDetachOverlayContentViewCore(long nativeTabAndroid ,
2475 ContentViewCore content);
2476 private static native void nativeRecordStartupToCommitUma(); 2394 private static native void nativeRecordStartupToCommitUma();
2477 } 2395 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698