diff options
| author | Nate Fischer <ntfschr@google.com> | 2017-09-08 17:02:00 -0700 |
|---|---|---|
| committer | Nate Fischer <ntfschr@google.com> | 2017-09-21 18:34:43 -0700 |
| commit | 3442c74d2ce220a2d104a5717994bbaf09a9f02d (patch) | |
| tree | c4ba9c316a916dfd4ccd267b30e36164cde25467 /core/java/android/webkit/WebView.java | |
| parent | ff499e4b0818eda3470c388fa34400ce3fe7f8a9 (diff) | |
WebView: add @Nullable and @NonNull annotations
This adds @Nullable and @NonNull annotations where the docs previously
stated this. This change should be safe, since we already disallowed
null values for the @NonNull parameters via documentation.
I verified that documentation changes for APIs which previously did not
mention null-ness in @param or @return Javadocs (if the API already
mentioned it in these spots, then DroidDoc prefers the hand-written
description).
This also fixes various lint errors.
Bug: 65465498
Test: make update-api and manually verify docs
Change-Id: I4751508d0e72be8ddfc3d6b601db8c307c9df60e
Diffstat (limited to 'core/java/android/webkit/WebView.java')
| -rw-r--r-- | core/java/android/webkit/WebView.java | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index a930fa80e035..3c5a7e49e813 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -443,7 +443,7 @@ public class WebView extends AbsoluteLayout * @deprecated Deprecated due to internal changes. */ @Deprecated - public void onNewPicture(WebView view, Picture picture); + void onNewPicture(WebView view, @Nullable Picture picture); } public static class HitTestResult { @@ -534,6 +534,7 @@ public class WebView extends AbsoluteLayout * * @return additional type-dependant information about the result */ + @Nullable public String getExtra() { return mExtra; } @@ -722,6 +723,7 @@ public class WebView extends AbsoluteLayout * * @return the SSL certificate for the main top-level page */ + @Nullable public SslCertificate getCertificate() { checkThread(); return mProvider.getCertificate(); @@ -790,6 +792,7 @@ public class WebView extends AbsoluteLayout * @deprecated Use {@link WebViewDatabase#getHttpAuthUsernamePassword} instead */ @Deprecated + @Nullable public String[] getHttpAuthUsernamePassword(String host, String realm) { checkThread(); return mProvider.getHttpAuthUsernamePassword(host, realm); @@ -858,9 +861,10 @@ public class WebView extends AbsoluteLayout * called. * * @param outState the Bundle to store this WebView's state - * @return the same copy of the back/forward list used to save the state. If - * saveState fails, the returned list will be {@code null}. + * @return the same copy of the back/forward list used to save the state, {@code null} if the + * method fails. */ + @Nullable public WebBackForwardList saveState(Bundle outState) { checkThread(); return mProvider.saveState(outState); @@ -911,6 +915,7 @@ public class WebView extends AbsoluteLayout * @param inState the incoming Bundle of state * @return the restored back/forward list or {@code null} if restoreState failed */ + @Nullable public WebBackForwardList restoreState(Bundle inState) { checkThread(); return mProvider.restoreState(inState); @@ -990,10 +995,11 @@ public class WebView extends AbsoluteLayout * always overrides that specified in the HTML or XML document itself. * * @param data a String of data in the given encoding - * @param mimeType the MIME type of the data, e.g. 'text/html' + * @param mimeType the MIMEType of the data, e.g. 'text/html'. If {@code null}, + * defaults to 'text/html'. * @param encoding the encoding of the data */ - public void loadData(String data, String mimeType, String encoding) { + public void loadData(String data, @Nullable String mimeType, @Nullable String encoding) { checkThread(); mProvider.loadData(data, mimeType, encoding); } @@ -1027,8 +1033,8 @@ public class WebView extends AbsoluteLayout * @param historyUrl the URL to use as the history entry. If {@code null} defaults * to 'about:blank'. If non-null, this must be a valid URL. */ - public void loadDataWithBaseURL(String baseUrl, String data, - String mimeType, String encoding, String historyUrl) { + public void loadDataWithBaseURL(@Nullable String baseUrl, String data, + @Nullable String mimeType, @Nullable String encoding, @Nullable String historyUrl) { checkThread(); mProvider.loadDataWithBaseURL(baseUrl, data, mimeType, encoding, historyUrl); } @@ -1050,7 +1056,7 @@ public class WebView extends AbsoluteLayout * completes with the result of the execution (if any). * May be {@code null} if no notification of the result is required. */ - public void evaluateJavascript(String script, ValueCallback<String> resultCallback) { + public void evaluateJavascript(String script, @Nullable ValueCallback<String> resultCallback) { checkThread(); mProvider.evaluateJavaScript(script, resultCallback); } @@ -1077,7 +1083,8 @@ public class WebView extends AbsoluteLayout * under which the file was saved, or {@code null} if saving the * file failed. */ - public void saveWebArchive(String basename, boolean autoname, ValueCallback<String> callback) { + public void saveWebArchive(String basename, boolean autoname, @Nullable ValueCallback<String> + callback) { checkThread(); mProvider.saveWebArchive(basename, autoname, callback); } @@ -1400,7 +1407,7 @@ public class WebView extends AbsoluteLayout * returns the anchor's href attribute. "title" returns the * anchor's text. "src" returns the image's src attribute. */ - public void requestFocusNodeHref(Message hrefMsg) { + public void requestFocusNodeHref(@Nullable Message hrefMsg) { checkThread(); mProvider.requestFocusNodeHref(hrefMsg); } @@ -1620,10 +1627,9 @@ public class WebView extends AbsoluteLayout * shared by all the WebViews that are created by the embedder application. * * @param onCleared A runnable to be invoked when client certs are cleared. - * The embedder can pass {@code null} if not interested in the - * callback. The runnable will be called in UI thread. + * The runnable will be called in UI thread. */ - public static void clearClientCertPreferences(Runnable onCleared) { + public static void clearClientCertPreferences(@Nullable Runnable onCleared) { getFactory().getStatics().clearClientCertPreferences(onCleared); } @@ -1645,7 +1651,8 @@ public class WebView extends AbsoluteLayout * @param callback will be called on the UI thread with {@code true} if initialization is * successful, {@code false} otherwise. */ - public static void startSafeBrowsing(Context context, ValueCallback<Boolean> callback) { + public static void startSafeBrowsing(Context context, + @Nullable ValueCallback<Boolean> callback) { getFactory().getStatics().initSafeBrowsing(context, callback); } @@ -1769,7 +1776,7 @@ public class WebView extends AbsoluteLayout * provides a more robust solution. */ @Deprecated - public boolean showFindDialog(String text, boolean showIme) { + public boolean showFindDialog(@Nullable String text, boolean showIme) { checkThread(); return mProvider.showFindDialog(text, showIme); } @@ -1796,6 +1803,7 @@ public class WebView extends AbsoluteLayout * @param addr the string to search for addresses * @return the address, or if no address is found, {@code null} */ + @Nullable public static String findAddress(String addr) { // TODO: Rewrite this in Java so it is not needed to start up chromium // Could also be deprecated @@ -1896,6 +1904,7 @@ public class WebView extends AbsoluteLayout * @return the WebChromeClient, or {@code null} if not yet set * @see #setWebChromeClient */ + @Nullable public WebChromeClient getWebChromeClient() { checkThread(); return mProvider.getWebChromeClient(); @@ -1978,7 +1987,7 @@ public class WebView extends AbsoluteLayout * * @param name the name used to expose the object in JavaScript */ - public void removeJavascriptInterface(String name) { + public void removeJavascriptInterface(@NonNull String name) { checkThread(); mProvider.removeJavascriptInterface(name); } @@ -2990,6 +2999,7 @@ public class WebView extends AbsoluteLayout * next time the app starts and loads WebView it will use the new WebView package instead. * @return the current WebView package, or {@code null} if there is none. */ + @Nullable public static PackageInfo getCurrentWebViewPackage() { PackageInfo webviewPackage = WebViewFactory.getLoadedPackageInfo(); if (webviewPackage != null) { |
