| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 import org.chromium.chrome.browser.TabState; | 42 import org.chromium.chrome.browser.TabState; |
| 43 import org.chromium.chrome.browser.TabState.WebContentsState; | 43 import org.chromium.chrome.browser.TabState.WebContentsState; |
| 44 import org.chromium.chrome.browser.UrlConstants; | 44 import org.chromium.chrome.browser.UrlConstants; |
| 45 import org.chromium.chrome.browser.WebContentsFactory; | 45 import org.chromium.chrome.browser.WebContentsFactory; |
| 46 import org.chromium.chrome.browser.banners.AppBannerManager; | 46 import org.chromium.chrome.browser.banners.AppBannerManager; |
| 47 import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; | 47 import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; |
| 48 import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator; | 48 import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator; |
| 49 import org.chromium.chrome.browser.contextualsearch.ContextualSearchTabHelper; | 49 import org.chromium.chrome.browser.contextualsearch.ContextualSearchTabHelper; |
| 50 import org.chromium.chrome.browser.crash.MinidumpUploadService; | 50 import org.chromium.chrome.browser.crash.MinidumpUploadService; |
| 51 import org.chromium.chrome.browser.customtabs.CustomTabActivity; | 51 import org.chromium.chrome.browser.customtabs.CustomTabActivity; |
| 52 import org.chromium.chrome.browser.device.DeviceClassManager; | |
| 53 import org.chromium.chrome.browser.download.ChromeDownloadDelegate; | 52 import org.chromium.chrome.browser.download.ChromeDownloadDelegate; |
| 54 import org.chromium.chrome.browser.enhancedbookmarks.EnhancedBookmarkUtils; | 53 import org.chromium.chrome.browser.enhancedbookmarks.EnhancedBookmarkUtils; |
| 55 import org.chromium.chrome.browser.fullscreen.FullscreenManager; | 54 import org.chromium.chrome.browser.fullscreen.FullscreenManager; |
| 56 import org.chromium.chrome.browser.help.HelpAndFeedback; | 55 import org.chromium.chrome.browser.help.HelpAndFeedback; |
| 57 import org.chromium.chrome.browser.infobar.InfoBarContainer; | 56 import org.chromium.chrome.browser.infobar.InfoBarContainer; |
| 58 import org.chromium.chrome.browser.media.ui.MediaSessionTabHelper; | 57 import org.chromium.chrome.browser.media.ui.MediaSessionTabHelper; |
| 59 import org.chromium.chrome.browser.ntp.NativePageAssassin; | 58 import org.chromium.chrome.browser.ntp.NativePageAssassin; |
| 60 import org.chromium.chrome.browser.ntp.NativePageFactory; | 59 import org.chromium.chrome.browser.ntp.NativePageFactory; |
| 61 import org.chromium.chrome.browser.omnibox.geo.GeolocationHeader; | 60 import org.chromium.chrome.browser.omnibox.geo.GeolocationHeader; |
| 62 import org.chromium.chrome.browser.policy.PolicyAuditor; | 61 import org.chromium.chrome.browser.policy.PolicyAuditor; |
| 63 import org.chromium.chrome.browser.printing.TabPrinter; | 62 import org.chromium.chrome.browser.printing.TabPrinter; |
| 64 import org.chromium.chrome.browser.profiles.Profile; | 63 import org.chromium.chrome.browser.profiles.Profile; |
| 65 import org.chromium.chrome.browser.rlz.RevenueStats; | 64 import org.chromium.chrome.browser.rlz.RevenueStats; |
| 66 import org.chromium.chrome.browser.search_engines.TemplateUrlService; | 65 import org.chromium.chrome.browser.search_engines.TemplateUrlService; |
| 67 import org.chromium.chrome.browser.snackbar.SnackbarManager; | 66 import org.chromium.chrome.browser.snackbar.SnackbarManager; |
| 68 import org.chromium.chrome.browser.ssl.ConnectionSecurityLevel; | 67 import org.chromium.chrome.browser.ssl.ConnectionSecurityLevel; |
| 69 import org.chromium.chrome.browser.ssl.SecurityStateModel; | 68 import org.chromium.chrome.browser.ssl.SecurityStateModel; |
| 70 import org.chromium.chrome.browser.tab.TabUma.TabCreationState; | 69 import org.chromium.chrome.browser.tab.TabUma.TabCreationState; |
| 71 import org.chromium.chrome.browser.tabmodel.SingleTabModelSelector; | 70 import org.chromium.chrome.browser.tabmodel.SingleTabModelSelector; |
| 72 import org.chromium.chrome.browser.tabmodel.TabModel; | 71 import org.chromium.chrome.browser.tabmodel.TabModel; |
| 73 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; | 72 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; |
| 74 import org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType; | 73 import org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType; |
| 75 import org.chromium.chrome.browser.tabmodel.TabModelImpl; | 74 import org.chromium.chrome.browser.tabmodel.TabModelImpl; |
| 76 import org.chromium.chrome.browser.util.AccessibilityUtil; | |
| 77 import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils; | 75 import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils; |
| 78 import org.chromium.components.navigation_interception.InterceptNavigationDelega
te; | 76 import org.chromium.components.navigation_interception.InterceptNavigationDelega
te; |
| 79 import org.chromium.content.browser.ActivityContentVideoViewClient; | 77 import org.chromium.content.browser.ActivityContentVideoViewClient; |
| 80 import org.chromium.content.browser.ContentVideoViewClient; | 78 import org.chromium.content.browser.ContentVideoViewClient; |
| 81 import org.chromium.content.browser.ContentView; | 79 import org.chromium.content.browser.ContentView; |
| 82 import org.chromium.content.browser.ContentViewClient; | 80 import org.chromium.content.browser.ContentViewClient; |
| 83 import org.chromium.content.browser.ContentViewCore; | 81 import org.chromium.content.browser.ContentViewCore; |
| 84 import org.chromium.content.browser.crypto.CipherFactory; | 82 import org.chromium.content.browser.crypto.CipherFactory; |
| 85 import org.chromium.content_public.browser.GestureStateListener; | 83 import org.chromium.content_public.browser.GestureStateListener; |
| 86 import org.chromium.content_public.browser.LoadUrlParams; | 84 import org.chromium.content_public.browser.LoadUrlParams; |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 | 512 |
| 515 if (didFinishLoad) { | 513 if (didFinishLoad) { |
| 516 // Simulate the PAGE_LOAD_FINISHED notification that we did not
get. | 514 // Simulate the PAGE_LOAD_FINISHED notification that we did not
get. |
| 517 didFinishPageLoad(); | 515 didFinishPageLoad(); |
| 518 } | 516 } |
| 519 } | 517 } |
| 520 }; | 518 }; |
| 521 | 519 |
| 522 private TabDelegateFactory mDelegateFactory; | 520 private TabDelegateFactory mDelegateFactory; |
| 523 | 521 |
| 522 private TopControlsVisibilityDelegate mTopControlsVisibilityDelegate; |
| 523 |
| 524 /** | 524 /** |
| 525 * Creates an instance of a {@link Tab}. | 525 * Creates an instance of a {@link Tab}. |
| 526 * @param id The id this tab should be identified with. | 526 * @param id The id this tab should be identified with. |
| 527 * @param incognito Whether or not this tab is incognito. | 527 * @param incognito Whether or not this tab is incognito. |
| 528 * @param window An instance of a {@link WindowAndroid}. | 528 * @param window An instance of a {@link WindowAndroid}. |
| 529 */ | 529 */ |
| 530 public Tab(int id, boolean incognito, WindowAndroid window) { | 530 public Tab(int id, boolean incognito, WindowAndroid window) { |
| 531 this(id, INVALID_TAB_ID, incognito, null, window, null, null, null); | 531 this(id, INVALID_TAB_ID, incognito, null, window, null, null, null); |
| 532 } | 532 } |
| 533 | 533 |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1256 TraceEvent.begin("Tab.initialize"); | 1256 TraceEvent.begin("Tab.initialize"); |
| 1257 | 1257 |
| 1258 mDelegateFactory = delegateFactory; | 1258 mDelegateFactory = delegateFactory; |
| 1259 initializeNative(); | 1259 initializeNative(); |
| 1260 | 1260 |
| 1261 if (AppBannerManager.isEnabled()) { | 1261 if (AppBannerManager.isEnabled()) { |
| 1262 mAppBannerManager = mDelegateFactory.createAppBannerManager(this
); | 1262 mAppBannerManager = mDelegateFactory.createAppBannerManager(this
); |
| 1263 if (mAppBannerManager != null) addObserver(mAppBannerManager); | 1263 if (mAppBannerManager != null) addObserver(mAppBannerManager); |
| 1264 } | 1264 } |
| 1265 | 1265 |
| 1266 mTopControlsVisibilityDelegate = |
| 1267 mDelegateFactory.createTopControlsVisibilityDelegate(this); |
| 1268 |
| 1266 // Attach the TabContentManager if we have one. This will bind this
Tab's content layer | 1269 // Attach the TabContentManager if we have one. This will bind this
Tab's content layer |
| 1267 // to this manager. | 1270 // to this manager. |
| 1268 // TODO(dtrainor): Remove this and move to a pull model instead of p
ushing the layer. | 1271 // TODO(dtrainor): Remove this and move to a pull model instead of p
ushing the layer. |
| 1269 nativeAttachToTabContentManager(mNativeTabAndroid, tabContentManager
); | 1272 nativeAttachToTabContentManager(mNativeTabAndroid, tabContentManager
); |
| 1270 | 1273 |
| 1271 // If there is a frozen WebContents state or a pending lazy load, do
n't create a new | 1274 // If there is a frozen WebContents state or a pending lazy load, do
n't create a new |
| 1272 // WebContents. | 1275 // WebContents. |
| 1273 if (getFrozenContentsState() != null || getPendingLoadParams() != nu
ll) { | 1276 if (getFrozenContentsState() != null || getPendingLoadParams() != nu
ll) { |
| 1274 if (unfreeze) unfreezeContents(); | 1277 if (unfreeze) unfreezeContents(); |
| 1275 return; | 1278 return; |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1442 | 1445 |
| 1443 private void scheduleEnableFullscreenLoadDelayIfNecessary() { | 1446 private void scheduleEnableFullscreenLoadDelayIfNecessary() { |
| 1444 if (mIsFullscreenWaitingForLoad | 1447 if (mIsFullscreenWaitingForLoad |
| 1445 && !mHandler.hasMessages(MSG_ID_ENABLE_FULLSCREEN_AFTER_LOAD)) { | 1448 && !mHandler.hasMessages(MSG_ID_ENABLE_FULLSCREEN_AFTER_LOAD)) { |
| 1446 mHandler.sendEmptyMessageDelayed( | 1449 mHandler.sendEmptyMessageDelayed( |
| 1447 MSG_ID_ENABLE_FULLSCREEN_AFTER_LOAD, MAX_FULLSCREEN_LOAD_DEL
AY_MS); | 1450 MSG_ID_ENABLE_FULLSCREEN_AFTER_LOAD, MAX_FULLSCREEN_LOAD_DEL
AY_MS); |
| 1448 } | 1451 } |
| 1449 } | 1452 } |
| 1450 | 1453 |
| 1451 /** | 1454 /** |
| 1455 * @return Whether fullscreen state is waiting for the load to finish for an
update. |
| 1456 */ |
| 1457 boolean isFullscreenWaitingForLoad() { |
| 1458 return mIsFullscreenWaitingForLoad; |
| 1459 } |
| 1460 |
| 1461 /** |
| 1452 * Called when a page has failed loading. | 1462 * Called when a page has failed loading. |
| 1453 * @param errorCode The error code causing the page to fail loading. | 1463 * @param errorCode The error code causing the page to fail loading. |
| 1454 */ | 1464 */ |
| 1455 protected void didFailPageLoad(int errorCode) { | 1465 protected void didFailPageLoad(int errorCode) { |
| 1456 cancelEnableFullscreenLoadDelay(); | 1466 cancelEnableFullscreenLoadDelay(); |
| 1457 mIsBeingRestored = false; | 1467 mIsBeingRestored = false; |
| 1458 if (mTabUma != null) mTabUma.onLoadFailed(errorCode); | 1468 if (mTabUma != null) mTabUma.onLoadFailed(errorCode); |
| 1459 for (TabObserver observer : mObservers) observer.onPageLoadFailed(this,
errorCode); | 1469 for (TabObserver observer : mObservers) observer.onPageLoadFailed(this,
errorCode); |
| 1460 updateFullscreenEnabledState(); | 1470 updateFullscreenEnabledState(); |
| 1461 } | 1471 } |
| (...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2399 if ((constraints == TopControlsState.HIDDEN && current == TopControlsSta
te.SHOWN) | 2409 if ((constraints == TopControlsState.HIDDEN && current == TopControlsSta
te.SHOWN) |
| 2400 || (constraints == TopControlsState.SHOWN && current == TopContr
olsState.HIDDEN)) { | 2410 || (constraints == TopControlsState.SHOWN && current == TopContr
olsState.HIDDEN)) { |
| 2401 return; | 2411 return; |
| 2402 } | 2412 } |
| 2403 updateTopControlsState(getTopControlsStateConstraints(), current, animat
e); | 2413 updateTopControlsState(getTopControlsStateConstraints(), current, animat
e); |
| 2404 } | 2414 } |
| 2405 | 2415 |
| 2406 /** | 2416 /** |
| 2407 * @return Whether hiding top controls is enabled or not. | 2417 * @return Whether hiding top controls is enabled or not. |
| 2408 */ | 2418 */ |
| 2409 protected boolean isHidingTopControlsEnabled() { | 2419 private boolean isHidingTopControlsEnabled() { |
| 2410 WebContents webContents = getWebContents(); | 2420 return mTopControlsVisibilityDelegate.isHidingTopControlsEnabled(); |
| 2411 if (webContents == null || webContents.isDestroyed()) return false; | |
| 2412 | |
| 2413 String url = getUrl(); | |
| 2414 boolean enableHidingTopControls = url != null && !url.startsWith(UrlCons
tants.CHROME_SCHEME) | |
| 2415 && !url.startsWith(UrlConstants.CHROME_NATIVE_SCHEME); | |
| 2416 | |
| 2417 int securityState = getSecurityLevel(); | |
| 2418 enableHidingTopControls &= (securityState != ConnectionSecurityLevel.SEC
URITY_ERROR | |
| 2419 && securityState != ConnectionSecurityLevel.SECURITY_WARNING); | |
| 2420 | |
| 2421 enableHidingTopControls &= | |
| 2422 !AccessibilityUtil.isAccessibilityEnabled(getApplicationContext(
)); | |
| 2423 enableHidingTopControls &= !mContentViewCore.isFocusedNodeEditable(); | |
| 2424 enableHidingTopControls &= !mIsShowingErrorPage; | |
| 2425 enableHidingTopControls &= !webContents.isShowingInterstitialPage(); | |
| 2426 enableHidingTopControls &= (mFullscreenManager != null); | |
| 2427 enableHidingTopControls &= DeviceClassManager.enableFullscreen(); | |
| 2428 enableHidingTopControls &= !DeviceClassManager.isAutoHidingToolbarDisabl
ed(mActivity); | |
| 2429 enableHidingTopControls &= !mIsFullscreenWaitingForLoad; | |
| 2430 | |
| 2431 return enableHidingTopControls; | |
| 2432 } | 2421 } |
| 2433 | 2422 |
| 2434 /** | 2423 /** |
| 2435 * Performs any subclass-specific tasks when the Tab crashes. | 2424 * Performs any subclass-specific tasks when the Tab crashes. |
| 2436 */ | 2425 */ |
| 2437 void handleTabCrash() { | 2426 void handleTabCrash() { |
| 2438 mIsLoading = false; | 2427 mIsLoading = false; |
| 2439 mIsBeingRestored = false; | 2428 mIsBeingRestored = false; |
| 2440 | 2429 |
| 2441 if (mTabUma != null) mTabUma.onRendererCrashed(); | 2430 if (mTabUma != null) mTabUma.onRendererCrashed(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2457 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | 2446 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
| 2458 throw e; | 2447 throw e; |
| 2459 } | 2448 } |
| 2460 } | 2449 } |
| 2461 } | 2450 } |
| 2462 | 2451 |
| 2463 /** | 2452 /** |
| 2464 * @return Whether showing top controls is enabled or not. | 2453 * @return Whether showing top controls is enabled or not. |
| 2465 */ | 2454 */ |
| 2466 public boolean isShowingTopControlsEnabled() { | 2455 public boolean isShowingTopControlsEnabled() { |
| 2467 if (mFullscreenManager == null) return true; | 2456 return mTopControlsVisibilityDelegate.isShowingTopControlsEnabled(); |
| 2468 return !mFullscreenManager.getPersistentFullscreenMode(); | |
| 2469 } | 2457 } |
| 2470 | 2458 |
| 2471 /** | 2459 /** |
| 2472 * @return The current visibility constraints for the display of top control
s. | 2460 * @return The current visibility constraints for the display of top control
s. |
| 2473 * {@link TopControlsState} defines the valid return options. | 2461 * {@link TopControlsState} defines the valid return options. |
| 2474 */ | 2462 */ |
| 2475 protected int getTopControlsStateConstraints() { | 2463 protected int getTopControlsStateConstraints() { |
| 2476 boolean enableHidingTopControls = isHidingTopControlsEnabled(); | 2464 boolean enableHidingTopControls = isHidingTopControlsEnabled(); |
| 2477 boolean enableShowingTopControls = isShowingTopControlsEnabled(); | 2465 boolean enableShowingTopControls = isShowingTopControlsEnabled(); |
| 2478 | 2466 |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2885 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro
id, | 2873 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro
id, |
| 2886 InterceptNavigationDelegate delegate); | 2874 InterceptNavigationDelegate delegate); |
| 2887 private native void nativeAttachToTabContentManager(long nativeTabAndroid, | 2875 private native void nativeAttachToTabContentManager(long nativeTabAndroid, |
| 2888 TabContentManager tabContentManager); | 2876 TabContentManager tabContentManager); |
| 2889 private native void nativeAttachOverlayContentViewCore(long nativeTabAndroid
, | 2877 private native void nativeAttachOverlayContentViewCore(long nativeTabAndroid
, |
| 2890 ContentViewCore content, boolean visible); | 2878 ContentViewCore content, boolean visible); |
| 2891 private native void nativeDetachOverlayContentViewCore(long nativeTabAndroid
, | 2879 private native void nativeDetachOverlayContentViewCore(long nativeTabAndroid
, |
| 2892 ContentViewCore content); | 2880 ContentViewCore content); |
| 2893 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String
url); | 2881 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String
url); |
| 2894 } | 2882 } |
| OLD | NEW |