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

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

Issue 2327083002: Ntp: restore scroll position. (Closed)
Patch Set: Cleanups. Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
index f97f467908e0ad2af404f8aed63c22a52cd2777b..8f6e65b9873d0ad00bc8ef754f96b426a300f5c8 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
@@ -99,6 +99,7 @@ import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.crypto.CipherFactory;
import org.chromium.content_public.browser.GestureStateListener;
import org.chromium.content_public.browser.LoadUrlParams;
+import org.chromium.content_public.browser.NavigationEntry;
import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.common.Referrer;
import org.chromium.content_public.common.ResourceRequestBody;
@@ -1435,6 +1436,33 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
}
/**
+ * Returns the value for the extra data that was stored with {@code key} in the last committed
+ * navigation entry. Returns null if there is no last committed entry, or if no data is found.
+ * @param key The key for the data field.
+ * @return The data value, or null if no data is found.
+ */
+ public String getLastCommittedNavigationEntryExtraData(String key) {
+ if (getWebContents() == null) return null;
+
+ NavigationEntry entry = getWebContents().getNavigationController().getEntryAtIndex(
Bernhard Bauer 2016/09/16 15:02:50 Extract the NavigationController to a local variab
Michael van Ouwerkerk 2016/09/16 16:35:05 Done.
+ getWebContents().getNavigationController().getLastCommittedEntryIndex());
+ if (entry == null) return null;
+
+ return entry.getExtraData(key);
+ }
+
+ /**
+ * Stores {@code value} under {@code key} in the last committed navigation entry, if such an
+ * entry exists.
+ * @param key The key for the data field.
+ * @param value The value for the data field.
+ */
+ public void setLastCommittedNavigationEntryExtraData(String key, String value) {
+ assert mNativeTabAndroid != 0;
+ nativeSetLastCommittedNavigationEntryExtraData(mNativeTabAndroid, key, value);
Bernhard Bauer 2016/09/16 15:02:50 Would it make sense to move the JNI call to Naviga
Michael van Ouwerkerk 2016/09/16 16:35:05 Done.
+ }
+
+ /**
* Replaces the current NativePage with a empty stand-in for a NativePage. This can be used
* to reduce memory pressure.
*/
@@ -3325,6 +3353,8 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
long intentReceivedTimestamp, boolean hasUserGesture);
private native void nativeSetActiveNavigationEntryTitleForUrl(long nativeTabAndroid, String url,
String title);
+ private native void nativeSetLastCommittedNavigationEntryExtraData(
+ long nativeTabAndroid, String key, String value);
private native boolean nativePrint(long nativeTabAndroid);
private native Bitmap nativeGetFavicon(long nativeTabAndroid);
private native void nativeCreateHistoricalTab(long nativeTabAndroid);

Powered by Google App Engine
This is Rietveld 408576698