Change "Save Web Archive" to "Save Page"
Bug: 3492152
If WebView fails to save the page as a web archive (which will
happen if the page is not an (X)HTML document), instead of
showing a failure toast we fall back to downloading the URL through
download manager.
Also changes the string "Save Web Archive" to "Save Page" and moves
the menu option to be after "Share page".
Change-Id: Ia4219075ae2585df865b58fa75ad24357150824f
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index c1f1313..fd966de 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -1468,8 +1468,10 @@
newtab.setEnabled(getTabControl().canCreateNewTab());
MenuItem archive = menu.findItem(R.id.save_webarchive_menu_id);
- String url = w != null ? w.getUrl() : null;
- archive.setVisible(url != null && !url.endsWith(".webarchivexml"));
+ Tab tab = getTabControl().getCurrentTab();
+ String url = tab != null ? tab.getUrl() : null;
+ archive.setVisible(!TextUtils.isEmpty(url)
+ && !url.endsWith(".webarchivexml"));
break;
}
mCurrentMenuState = mMenuState;
@@ -1591,6 +1593,7 @@
}
WebView topWebView = getCurrentTopWebView();
final String title = topWebView.getTitle();
+ final String url = topWebView.getUrl();
topWebView.saveWebArchive(directory, true,
new ValueCallback<String>() {
@Override
@@ -1614,8 +1617,8 @@
return;
}
}
- Toast.makeText(mActivity,
- R.string.webarchive_failed, Toast.LENGTH_SHORT).show();
+ DownloadHandler.onDownloadStartNoStream(mActivity,
+ url, null, null, null);
}
});
break;