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

Unified Diff: android_webview/tools/system_webview_shell/apk/src/org/chromium/webview_shell/WebViewBrowserActivity.java

Issue 2330013002: Save and restore state in the webview shell. (Closed)
Patch Set: Comment reloading code. 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/tools/system_webview_shell/apk/src/org/chromium/webview_shell/WebViewBrowserActivity.java
diff --git a/android_webview/tools/system_webview_shell/apk/src/org/chromium/webview_shell/WebViewBrowserActivity.java b/android_webview/tools/system_webview_shell/apk/src/org/chromium/webview_shell/WebViewBrowserActivity.java
index a3cad3c685c8845d74174a5d40b48f5079af7f62..c8b3ae75e7903f68545beb872fadb7dad0d1a847 100644
--- a/android_webview/tools/system_webview_shell/apk/src/org/chromium/webview_shell/WebViewBrowserActivity.java
+++ b/android_webview/tools/system_webview_shell/apk/src/org/chromium/webview_shell/WebViewBrowserActivity.java
@@ -184,6 +184,23 @@ public class WebViewBrowserActivity extends Activity implements PopupMenu.OnMenu
String url = getUrlFromIntent(getIntent());
if (url == null) {
+ mWebView.restoreState(savedInstanceState);
+ url = mWebView.getUrl();
+ if (url != null) {
+ // If we have restored state, and that state includes
+ // a loaded URL, we reload. This allows us to keep the
+ // scroll offset, and also doesn't add an additional
+ // navigation history entry.
+ setUrlBarText(url);
+ // The immediately previous loadUrlFromurlbar must
+ // have got as far as calling loadUrl, so there is no
+ // URI parsing error at this point.
+ setUrlFail(false);
+ hideKeyboard(mUrlBar);
+ mWebView.reload();
+ mWebView.requestFocus();
+ return;
+ }
// Make sure to load a blank page to make it immediately inspectable with
// chrome://inspect.
url = "about:blank";
@@ -194,6 +211,12 @@ public class WebViewBrowserActivity extends Activity implements PopupMenu.OnMenu
}
@Override
+ public void onSaveInstanceState(Bundle savedInstanceState) {
+ // Deliberately don't catch TransactionTooLargeException here.
+ mWebView.saveState(savedInstanceState);
+ }
+
+ @Override
public void onBackPressed() {
if (mWebView.canGoBack()) {
mWebView.goBack();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698