| 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.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.app.Activity; | 8 import android.app.Activity; |
| 9 import android.app.Application; | 9 import android.app.Application; |
| 10 import android.content.Context; | 10 import android.content.Context; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 import org.chromium.chrome.R; | 40 import org.chromium.chrome.R; |
| 41 import org.chromium.chrome.browser.ChromeActionModeCallback; | 41 import org.chromium.chrome.browser.ChromeActionModeCallback; |
| 42 import org.chromium.chrome.browser.ChromeActivity; | 42 import org.chromium.chrome.browser.ChromeActivity; |
| 43 import org.chromium.chrome.browser.ChromeApplication; | 43 import org.chromium.chrome.browser.ChromeApplication; |
| 44 import org.chromium.chrome.browser.ChromeFeatureList; | 44 import org.chromium.chrome.browser.ChromeFeatureList; |
| 45 import org.chromium.chrome.browser.ChromeVersionInfo; | 45 import org.chromium.chrome.browser.ChromeVersionInfo; |
| 46 import org.chromium.chrome.browser.FrozenNativePage; | 46 import org.chromium.chrome.browser.FrozenNativePage; |
| 47 import org.chromium.chrome.browser.IntentHandler; | 47 import org.chromium.chrome.browser.IntentHandler; |
| 48 import org.chromium.chrome.browser.IntentHandler.TabOpenType; | 48 import org.chromium.chrome.browser.IntentHandler.TabOpenType; |
| 49 import org.chromium.chrome.browser.NativePage; | 49 import org.chromium.chrome.browser.NativePage; |
| 50 import org.chromium.chrome.browser.NativePageHost; | |
| 51 import org.chromium.chrome.browser.SwipeRefreshHandler; | 50 import org.chromium.chrome.browser.SwipeRefreshHandler; |
| 52 import org.chromium.chrome.browser.TabState; | 51 import org.chromium.chrome.browser.TabState; |
| 53 import org.chromium.chrome.browser.TabState.WebContentsState; | 52 import org.chromium.chrome.browser.TabState.WebContentsState; |
| 54 import org.chromium.chrome.browser.UrlConstants; | 53 import org.chromium.chrome.browser.UrlConstants; |
| 55 import org.chromium.chrome.browser.WarmupManager; | 54 import org.chromium.chrome.browser.WarmupManager; |
| 56 import org.chromium.chrome.browser.WebContentsFactory; | 55 import org.chromium.chrome.browser.WebContentsFactory; |
| 57 import org.chromium.chrome.browser.banners.AppBannerManager; | 56 import org.chromium.chrome.browser.banners.AppBannerManager; |
| 58 import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; | 57 import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; |
| 59 import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator; | 58 import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator; |
| 60 import org.chromium.chrome.browser.contextualsearch.ContextualSearchTabHelper; | 59 import org.chromium.chrome.browser.contextualsearch.ContextualSearchTabHelper; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 * <p> | 120 * <p> |
| 122 * Extending just Java: | 121 * Extending just Java: |
| 123 * - Just extend the class normally. Do not override initializeNative(). | 122 * - Just extend the class normally. Do not override initializeNative(). |
| 124 * Extending Java and C++: | 123 * Extending Java and C++: |
| 125 * - Because of the inner-workings of JNI, the subclass is responsible for cons
tructing the native | 124 * - Because of the inner-workings of JNI, the subclass is responsible for cons
tructing the native |
| 126 * subclass, which in turn constructs TabAndroid (the native counterpart to T
ab), which in | 125 * subclass, which in turn constructs TabAndroid (the native counterpart to T
ab), which in |
| 127 * turn sets the native pointer for Tab. For destruction, subclasses in Java
must clear | 126 * turn sets the native pointer for Tab. For destruction, subclasses in Java
must clear |
| 128 * their own native pointer reference, but Tab#destroy() will handle deleting
the native | 127 * their own native pointer reference, but Tab#destroy() will handle deleting
the native |
| 129 * object. | 128 * object. |
| 130 */ | 129 */ |
| 131 public class Tab implements ViewGroup.OnHierarchyChangeListener, | 130 public class Tab |
| 132 View.OnSystemUiVisibilityChangeListener, NativePageH
ost { | 131 implements ViewGroup.OnHierarchyChangeListener, View.OnSystemUiVisibilit
yChangeListener { |
| 133 public static final int INVALID_TAB_ID = -1; | 132 public static final int INVALID_TAB_ID = -1; |
| 134 | 133 |
| 135 /** Return value from {@link #getBookmarkId()} if this tab is not bookmarked
. */ | 134 /** Return value from {@link #getBookmarkId()} if this tab is not bookmarked
. */ |
| 136 public static final long INVALID_BOOKMARK_ID = -1; | 135 public static final long INVALID_BOOKMARK_ID = -1; |
| 137 | 136 |
| 138 private static final long INVALID_TIMESTAMP = -1; | 137 private static final long INVALID_TIMESTAMP = -1; |
| 139 | 138 |
| 140 /** | 139 /** |
| 141 * The required page load percentage for the page to be considered ready ass
uming the | 140 * The required page load percentage for the page to be considered ready ass
uming the |
| 142 * TextureView is also ready. | 141 * TextureView is also ready. |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 } | 630 } |
| 632 | 631 |
| 633 /** | 632 /** |
| 634 * Causes this tab to navigate to the specified URL. | 633 * Causes this tab to navigate to the specified URL. |
| 635 * @param params parameters describing the url load. Note that it is importa
nt to set correct | 634 * @param params parameters describing the url load. Note that it is importa
nt to set correct |
| 636 * page transition as it is used for ranking URLs in the histo
ry so the omnibox | 635 * page transition as it is used for ranking URLs in the histo
ry so the omnibox |
| 637 * can report suggestions correctly. | 636 * can report suggestions correctly. |
| 638 * @return FULL_PRERENDERED_PAGE_LOAD or PARTIAL_PRERENDERED_PAGE_LOAD if th
e page has been | 637 * @return FULL_PRERENDERED_PAGE_LOAD or PARTIAL_PRERENDERED_PAGE_LOAD if th
e page has been |
| 639 * prerendered. DEFAULT_PAGE_LOAD if it had not. | 638 * prerendered. DEFAULT_PAGE_LOAD if it had not. |
| 640 */ | 639 */ |
| 641 @Override | |
| 642 public int loadUrl(LoadUrlParams params) { | 640 public int loadUrl(LoadUrlParams params) { |
| 643 try { | 641 try { |
| 644 TraceEvent.begin("Tab.loadUrl"); | 642 TraceEvent.begin("Tab.loadUrl"); |
| 645 // TODO(tedchoc): When showing the android NTP, delay the call to na
tiveLoadUrl until | 643 // TODO(tedchoc): When showing the android NTP, delay the call to na
tiveLoadUrl until |
| 646 // the android view has entirely rendered. | 644 // the android view has entirely rendered. |
| 647 if (!mIsNativePageCommitPending) { | 645 if (!mIsNativePageCommitPending) { |
| 648 mIsNativePageCommitPending = maybeShowNativePage(params.getUrl()
, false); | 646 mIsNativePageCommitPending = maybeShowNativePage(params.getUrl()
, false); |
| 649 } | 647 } |
| 650 | 648 |
| 651 removeSadTabIfPresent(); | 649 removeSadTabIfPresent(); |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 /** | 1000 /** |
| 1003 * For more information about the uniqueness of {@link #getId()} see comment
s on {@link Tab}. | 1001 * For more information about the uniqueness of {@link #getId()} see comment
s on {@link Tab}. |
| 1004 * @see Tab | 1002 * @see Tab |
| 1005 * @return The id representing this tab. | 1003 * @return The id representing this tab. |
| 1006 */ | 1004 */ |
| 1007 @CalledByNative | 1005 @CalledByNative |
| 1008 public int getId() { | 1006 public int getId() { |
| 1009 return mId; | 1007 return mId; |
| 1010 } | 1008 } |
| 1011 | 1009 |
| 1012 @Override | |
| 1013 public boolean isIncognito() { | 1010 public boolean isIncognito() { |
| 1014 return mIncognito; | 1011 return mIncognito; |
| 1015 } | 1012 } |
| 1016 | 1013 |
| 1017 /** | 1014 /** |
| 1018 * @return The {@link ContentViewCore} associated with the current page. | 1015 * @return The {@link ContentViewCore} associated with the current page. |
| 1019 */ | 1016 */ |
| 1020 public ContentViewCore getActiveContentViewCore() { | 1017 public ContentViewCore getActiveContentViewCore() { |
| 1021 return mContentViewCore; | 1018 return mContentViewCore; |
| 1022 } | 1019 } |
| (...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2120 /** | 2117 /** |
| 2121 * @return true iff the tab is performing a restore page load. | 2118 * @return true iff the tab is performing a restore page load. |
| 2122 */ | 2119 */ |
| 2123 public boolean isBeingRestored() { | 2120 public boolean isBeingRestored() { |
| 2124 return mIsBeingRestored; | 2121 return mIsBeingRestored; |
| 2125 } | 2122 } |
| 2126 | 2123 |
| 2127 /** | 2124 /** |
| 2128 * @return The id of the tab that caused this tab to be opened. | 2125 * @return The id of the tab that caused this tab to be opened. |
| 2129 */ | 2126 */ |
| 2130 @Override | |
| 2131 public int getParentId() { | 2127 public int getParentId() { |
| 2132 return mParentId; | 2128 return mParentId; |
| 2133 } | 2129 } |
| 2134 | 2130 |
| 2135 @Override | |
| 2136 public Tab getActiveTab() { | |
| 2137 return this; | |
| 2138 } | |
| 2139 | |
| 2140 /** | 2131 /** |
| 2141 * @return Whether the tab should be grouped with its parent tab (true by de
fault). | 2132 * @return Whether the tab should be grouped with its parent tab (true by de
fault). |
| 2142 */ | 2133 */ |
| 2143 public boolean isGroupedWithParent() { | 2134 public boolean isGroupedWithParent() { |
| 2144 return mGroupedWithParent; | 2135 return mGroupedWithParent; |
| 2145 } | 2136 } |
| 2146 | 2137 |
| 2147 /** | 2138 /** |
| 2148 * Sets whether the tab should be grouped with its parent tab. | 2139 * Sets whether the tab should be grouped with its parent tab. |
| 2149 * | 2140 * |
| (...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3061 private native boolean nativeIsOfflinePage(long nativeTabAndroid); | 3052 private native boolean nativeIsOfflinePage(long nativeTabAndroid); |
| 3062 private native OfflinePageItem nativeGetOfflinePage(long nativeTabAndroid); | 3053 private native OfflinePageItem nativeGetOfflinePage(long nativeTabAndroid); |
| 3063 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro
id, | 3054 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro
id, |
| 3064 InterceptNavigationDelegate delegate); | 3055 InterceptNavigationDelegate delegate); |
| 3065 private native void nativeAttachToTabContentManager(long nativeTabAndroid, | 3056 private native void nativeAttachToTabContentManager(long nativeTabAndroid, |
| 3066 TabContentManager tabContentManager); | 3057 TabContentManager tabContentManager); |
| 3067 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String
url); | 3058 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String
url); |
| 3068 private native void nativeSetWebappManifestScope(long nativeTabAndroid, Stri
ng scope); | 3059 private native void nativeSetWebappManifestScope(long nativeTabAndroid, Stri
ng scope); |
| 3069 private native void nativeEnableEmbeddedMediaExperience(long nativeTabAndroi
d, boolean enabled); | 3060 private native void nativeEnableEmbeddedMediaExperience(long nativeTabAndroi
d, boolean enabled); |
| 3070 } | 3061 } |
| OLD | NEW |