Commit Graph

3539 Commits

Author SHA1 Message Date
Robert Sesek
b21dbc220f Delay starting the webview_zygote until first use.
During boot, WebViewZygote.setMultiprocessEnabled() is called by the
WebView initialization logic. Starting the WebViewZygote here causes a
slowdown in the system_server boot process, so delay launching the
zygote until it is needed.

Previously the webview_zygote was launched by init, and merely
connecting to it in the boot process didn't have significant overhead.

Bug: 73743583
Bug: 63749735
Test: Boot a device, verify that webview_zygote process is not running.
Test: Launch "Third-party licenses" activity from Settings, and it
      renders correctly via the WebView.

Change-Id: I1352a5df95e4a793ac64862c439ba2573ddd2d18
2018-02-26 16:59:48 -05:00
Robert Sesek
602d1323ed Reparent the webview_zygote to be a child of the main app_process zygote.
This uses the new ZygoteProcess.startChildZygote() method to launch the
webview_zygote, rather than having init start it. This will share more
memory between the app_process and the webview_zygote, reducing the
overall system footprint.

Bug: 63749735
Test: m
Test: Launch "Third-party licenses" activity from Settings, and it
      renders correctly via the WebView.
Change-Id: I3e39cd8adb9c099c92ee34640428916d90cb2b8f
2018-02-20 17:00:41 -05:00
Torne (Richard Coles)
5bc14af5fa Consider shared libs when precreating WebView classloader.
The change to handling of the deprecated Apache HTTP library means that
the WebView implementation package might have a non-empty shared library
list. Make sure to fetch shared libraries when querying WebView
implementations, and take them into account when constructing both the
actual classpath to be used to precreate the classloader, and when
deciding what the cache key for the precreated classloader should be.

Change-Id: I5e1409358d935e1c9f325db434bc6d4ef8ead759
Merged-In: I5e1409358d935e1c9f325db434bc6d4ef8ead759
Fixes: 65574359
Test: launch anything that uses WebView
(cherry picked from commit 4fd8aa51e4)
2018-02-20 15:41:12 -05:00
Tobias Sargeant
f4d85d806e Add a Java FindAddress implentation.
This stops calling findAddress (possibly indirectly via Linkify) from
loading webview native code, resulting in a performance and memory
improvement for those apps that call WebView#findAddress but do not
otherwise use WebView.

Bug: 22362008
Test: Existing WebView CTS test.
Change-Id: I5fcab725ceaf0d6a00e931d3b6cd2f3799d68391
2018-01-05 14:44:10 +00:00
Felipe Leme
58390fe9ae Minor fixes on WebView.onProvideAutofillVirtualStructure() javadoc.
Test: mmm -j108 frameworks/base/:doc-comment-check-docs
Bug: 65751159

Change-Id: Ie60b1f32e4d9acc675c6e25b7d3e606049b6a3c3
2017-09-15 16:48:41 -07:00
Nate Fischer
b5a9bf41b1 WebView: document Safe Browsing and shouldInterceptRequest
No change to logic, docs only.

This documents shouldInterceptRequest request behavior when Safe
Browsing is enabled, with recommendations for how this can be avoided
depending on the application's needs.

Bug: 65555402
Test: make docs (manually verify links all work)
Change-Id: I055254bfae3a06061402c519e8740ec4d9779e8f
2017-09-11 16:12:24 -07:00
Nate Fischer
fbebfa9d53 WebView: fix setSafeBrowsingWhitelist table in docs
No change to logic, only docs changes.

The documentation for setSafeBrowsingWhitelist uses a table to describe
whitelist rules. However, this table was previously formatted
incorrectly (it uses <th> elements for each cell, when normal data cells
should use <td> according to Android API guidelines).

This fixes the table to conform to the guidelines, adjusts white space
for consistency, and removes an unnecessary <p> element.

Bug: 65173825
Test: make docs (and manually verify the table looks correct)
Change-Id: I5d7390a44613aaa3acb147a69f8e0ce741e817ed
2017-08-30 21:03:19 +00:00
Nate Fischer
220d86d142 WebView: require APKs to target OMR1
This disallows WebView/Monochrome APKs targeting O or below to be chosen
as WebView providers.

Bug: 65080651
Test: Open WebView shell with webview from system image, no crash
Test: Install Monochrome compiled for O, it's not in the webview provider list
Change-Id: I79162cedaa801ce227ad4c2eb3cbea9c08704da8
2017-08-28 12:15:56 -07:00
Nate Fischer
02e281a13d WebView: clarify docs for addJavascriptInterface
Docs change only, no change in logic.

We do not support calling #addJavascriptInterface until after JavaScript
is enabled via WebSettings#setJavaScriptEnabled. Calling these methods
in the wrong order is undefined behavior (and we've seen that it's buggy
under certain conditions, e.g. if the DOM includes an <img> element).

This clarifies the point in the docs and code example.

Bug: 64899039
Test: make -j40 docs (everything looks good)
Change-Id: I8ef9eec7f038037e6b898286e4dad8a57ecad472
(cherry picked from commit aaef6827ca)
2017-08-23 17:49:46 +00:00
Nate Fischer
2b108d8609 WebView: rename initSafeBrowsing and remove shutdownSafeBrowsing
This renames the method as follows:

 * initSafeBrowsing -> startSafeBrowsing

This also updates documentation to fix javadoc references, and to
clarify that Safe Browsing checks are not guaranteed until after
startSafeBrowsing() invokes its callback.

This does not change the method name in WebViewFactoryProvider, because
changing this would break CTS tests (since the WebView APK implements
this under the old name).

This also removes shutdownSafeBrowsing, because we found there was no
good use for this (it's meaningless for AOSP, and we were recommended to
avoid calling the underlying GMSCore API for GoogleWebView). More
significantly, there's no good place for an application to call it from.

Bug: 64331900
Test: make update-api (docs are correct)
Change-Id: Idf2b9390306052f5c5dfb92909fca4cfeec74aef
2017-08-21 18:04:28 -07:00
Felipe Leme
2220049d58 Merge "Additional documentation about Autofill / WebView security." into oc-dev am: 36cbdef880
am: a3c2cee055

Change-Id: Ie107dd462a47009a34ee3768183dfda2e36107c3
2017-08-15 21:48:32 +00:00
Felipe Leme
a3c2cee055 Merge "Additional documentation about Autofill / WebView security." into oc-dev
am: 36cbdef880

Change-Id: Ie198dbbdc7ab4ea1089c7363f1b1d2df333c1d8f
2017-08-15 21:33:01 +00:00
Nate Fischer
7b00b32216 WebView: switch to OMR1 FactoryProvider
We now fetch the *ForOMR1 class instead of *ForO, which enables
OMR1-specific code in the WebView APK.

Bug: 63687088
Test: N/A
Change-Id: Ia36a00cd26aff8b87d7aeae859c72cb2fb364d2c
2017-08-14 18:43:28 +00:00
Felipe Leme
303b609eaa Additional documentation about Autofill / WebView security.
Test: ran 'm -j doc-comment-check-docs' and checked resulting HTML

Fixes: 64114048
Fixes: 64337380
Fixes: 64125551

Change-Id: I375bb4712af875251fea4f3e572d92165643409a
2017-08-14 08:49:47 -07:00
TreeHugger Robot
a9732da1f3 Merge "WebView: remove unused DATA_REDUCTION_PROXY_SETTING_CHANGED API" into oc-mr1-dev 2017-08-11 17:38:11 +00:00
Nate Fischer
3898ac12e4 WebView: add WebView#getSafeBrowsingPrivacyPolicyUrl() API
This adds a dedicated API for fetching a URL for the Safe Browsing
reporting privacy policy.

This URL should be displayed by applications on custom Safe Browsing
interstitials.

Bug: 64077668
Test: make update-api (it compiles and javadocs look good)
Change-Id: I2873260edcaa924e68517c8679079e147b9995f4
2017-08-10 18:33:21 -07:00
Nate Fischer
bc1da9e2b4 WebView: fix SafeBrowsingResponse javadocs
Docs change only.

This fixes javadoc errors in SafeBrowsingResponse.java:

 * Typo: capital "B" in "onSafeBrowsingHit"
 * Add full package names
 * Add parameter lists to all linked methods

Bug: 64077668
Test: make update-api and check javadocs manually
Change-Id: I5e7b0e59ba865619b252f7e9e431ffac6e1bab1f
2017-08-08 15:43:44 -07:00
Nate Fischer
2ddac82335 Merge "WebView: update SafeBrowsing documentation" into oc-mr1-dev 2017-08-08 21:00:59 +00:00
Nate Fischer
07ea436685 WebView: remove unused DATA_REDUCTION_PROXY_SETTING_CHANGED API
This API was unused. We're removing this under recommendation from the
API council.

Bug: 62425491
Test: make -j40 update-api
Change-Id: If869305b46b2dd2c5c4ab269e3544d4e2156ddd7
2017-08-07 12:21:06 -07:00
Jeff Sharkey
67f9d5070a Fix broken javadocs.
Bug: 64337634
Test: make -j32 doc-comment-check-docs
Change-Id: I20fdd3dcddef09111d35946c41c596c7689effa6
2017-08-06 07:37:08 -06:00
Selim Gurun
a30ec5ff4c Merge "Update documentation for Whitelist API" into oc-mr1-dev 2017-07-31 14:27:52 +00:00
Selim Gurun
89e935904a Update documentation for Whitelist API
Bug: 64144913
Test: compile documentation and visually confirm

Change-Id: Ia19ca9b6cf4f8a0802835d597a30e10c498dbd81
2017-07-28 12:06:42 -07:00
Nate Fischer
471891df02 WebView: update SafeBrowsing documentation
No change in logic, only docs changes:

 * Docs about Safe Browsing feature as a whole.
 * Expand the docs for initSafeBrowsing/shutdownSafeBrowsing

Bug: 63660204
Bug: 62192626
Test: make update-api and manually check javadocs
Change-Id: I6526a0f1ce1327f6eff416c27ded89866587f173
2017-07-27 21:43:59 +00:00
Tima Vaisburd
e8c611f04d Unhide get/setTextClassifier in WebView
We can unhide the methods etTextClassifier and getTextClassifier since
the WebView M61 that is shipping with O-MR1 has the corresponding
implementation.

Bug: 63903071
Test: CTS test in a ceparate CL
Change-Id: I72df0d34a0fccd2c213ed10ca8993a7d786ff835
2017-07-20 16:05:26 -07:00
Nate Fischer
c5ec745135 WebView: remove @Nullable from SB whitelist
This removes the @Nullable annotation from
WebView#setSafeBrowsingWhitelist's List parameter. This does not need to
be Nullable, since the whitelist can be unset just as easily by passing
an empty list.

Bug: 63084528
Test: N/A
Change-Id: Ica9d67bc907b16e89d0a1b6a15d91e21f74cc4c9
2017-07-18 16:32:19 -07:00
TreeHugger Robot
8e82f01280 Merge "WebView: change setSafeBrowsingWhiteList signature" 2017-07-18 00:54:41 +00:00
Nate Fischer
d6385d326b WebView: change setSafeBrowsingWhiteList signature
* Renames WhiteList -> Whitelist
 * Adds a callback to indicate malformed URLs to the application

Bug: 63660204
Bug: 63084528
Bug: 63765158
Test: N/A
Change-Id: Ia12f0822c5d3a339633a820c40bdbff4137f510b
2017-07-17 23:32:22 +00:00
Nate Fischer
5ab00b31ee WebView: add IntDef for SafeBrowsingThreat
This adds an @IntDef for WebViewClient#onSafeBrowsingHit()'s threatType
argument.

Bug: 62723291, 63655766
Test: N/A
Change-Id: I71fb51753c461d1efa9de123bde977721c8da515
2017-07-13 15:28:21 -07:00
TreeHugger Robot
953daa0a78 Merge "WebView: update docs for WebView#initSafeBrowsing" 2017-07-13 06:35:00 +00:00
Nate Fischer
465104817d Merge "WebView: Fix SafeBrowsingResponse API" 2017-07-13 05:17:39 +00:00
Nate Fischer
3ca196a12d WebView: update docs for WebView#initSafeBrowsing
This fixes the documentation to specify that an application Context will
be used instead of an Activity Context (since only application Context
is needed).

Bug: 62192626, 63616213
Test: N/A
Change-Id: Ia34d2172be8cca7cb0751286c6c2388ff34d3f4a
2017-07-12 18:46:50 -07:00
Nate Fischer
520a8ba279 WebView: fix WebView#setSafeBrowsingWhiteList
This corrects the WebView#setSafeBrowsingWhiteList method to accept a
List<String> instead of a String[], as per API council recommendation.

Bug: 63084528, 63615148
Test: N/A
Change-Id: I53f490c6ab9c10fffe6c89010d7509747ac8f95f
2017-07-12 17:37:07 -07:00
Nate Fischer
6aabdc4dbc WebView: Fix SafeBrowsingResponse API
The methods were previously package-private by mistake. This fixes them
to be public.

Bug: 63615582, 62723291
Test: N/A
Change-Id: Ie9095f861213a70fd655561f911385bdd06632b3
2017-07-12 17:20:55 -07:00
Nate Fischer
2f7af06efb Add SafeBrowsingResponse abstract class
This adds a new class called SafeBrowsingResponse to replace the
ValueCallback parameter for WebViewClient#onSafeBrowsingHit. This
class contains specific methods for each of the available actions.

This also removes the SAFE_BROWSING_ACTION_* constants from the
WebViewClient class.

Bug: 62723291
Test: N/A
Change-Id: Ie4fe878ea470f7aea7a716ae9edb80b53b73e172
2017-07-11 20:32:04 +00:00
Nate Fischer
bf158ec3d8 WebView: add APIs for setSafeBrowsingWhiteList
This adds the APIs for the static method
WebView#setSafeBrowsingWhiteList().

BUG: 63084528
Test: N/A
Change-Id: I6eff32d9f8356e8c1a2c631782e07d52ba9b6ad5
2017-06-27 23:25:15 -07:00
Gustav Sennton
beec08679b Use classloader namespace instead of lib paths to load WebView libs.
When loading WebView's native libraries we now have a classloader
pointing to the namespace of thise libraries - so we no longer need to
explicitly reference those libraries by their path names.

Bug: 62860565
Test: Start a WebView-using app. Ensure that libwebviewchromium.so is
loaded into the app process.

Change-Id: I205131f4b5fac7c33374560515b85ddef19a7ce9
2017-06-26 16:05:33 +01:00
Gustav Sennton
ed98a15636 Move WebView relro related functionality to its own file.
WebViewFactory contains a mix of functionality related to preparing and
loading WebView.
This CL breaks out the functionality related to relro-creation and
native library loading into its own class/file to make WebViewFactory
easier to interpret.

Some variables/methods must stay in WebViewFactory since they are
SystemApis.

Bug: 28736099
Test: start WebView-using app, ensure libwebviewchromium64.relro is
loaded into the app process.

Change-Id: I956e1536f23d47f1de1b6c23fc6abeb2768b58ae
2017-06-20 17:25:53 +01:00
Nate Fischer
0c3043622e Add WebViewClient#onSafeBrowsingHit() API
This adds the WebViewClient#onSafeBrowsingHit() API and its default
implementation.

This also adds the relevant constants. This includes
SAFE_BROWSING_THREAT_UNKNOWN, in case we expose new threat types in the
future.

Bug: 62723291
Test: N/A
Change-Id: I0b424a952466b23db4cf296573680a0a6c61b981
2017-06-16 16:53:44 -07:00
Jeff Sharkey
9039636535 Revert "Hide APIs not intended to ship in DR."
This reverts commit 0c28d43fe1.
2017-06-12 16:26:53 -06:00
Jeff Sharkey
0c28d43fe1 Hide APIs not intended to ship in DR.
This CL will be reverted once it merges into the next release branch
to re-introduce the proposed APIs.

This CL also makes the following code changes to preserve API
compatibility:

-- It keeps the recently added RemoteViews.clone() synchronized logic
intact, but moves it inside the method to avoid changing the API
signature.

-- It reverts the RttCall.read() behavior to the oc-dev logic, since
we can't throw IOException until we get an API level bump.  (The
original logic returned null instead of throwing.)

Test: builds, boots
Bug: 62427252, 62431886, 62427329
Bug: 62468911, 62431162, 62428935, 62429096
Bug: 37290820, 37359238, 36886243
Bug: 30143923, 35761231, 62192626, 29829689
Change-Id: I83d723f598cb0ee1fe198e65debd86ef7fd0420c
2017-06-12 10:26:01 -06:00
TreeHugger Robot
fb95cd11d7 Merge "Update documentation for postmessage method" 2017-06-02 02:49:05 +00:00
Nate Fischer
b4ec958c7c Merge "Add WebView#{init,shutdown}SafeBrowsing APIs" 2017-05-31 00:17:48 +00:00
Nate Fischer
0e72c181c8 Add WebView#{init,shutdown}SafeBrowsing APIs
This adds the APIs for the WebView#initSafeBrowsing and
WebView#shutdownSafeBrowsing static methods.

Implementation for these APIs landed in 60.0.3112.0

Also, this fixes an already-existing error with import order (failed
Checkstyle hook). No actual change to imports.

BUG: 62192626
Test: manual - built a custom app which calls methods via reflection
Change-Id: I763349182443dc20cff1e7f08475290fac65c233
2017-05-30 11:40:26 -07:00
Felipe Leme
0295914784 Merge "Moar Autofill Framework javadoc improvements:" into oc-dev am: 7990306b8b
am: fa2d7ffb95

Change-Id: I4734f1b5abbdf907692006355c2a60d13549819b
2017-05-26 19:12:33 +00:00
Felipe Leme
6dcec87ea2 Moar Autofill Framework javadoc improvements:
- Fixed WebView < > and API calls.
- Improved description of virtual views.
- Described how to set boundaries of virtual views.
- Improved AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS doc.

Bug: 37567048
Test: ran 'm -j doc-comment-check-docs' and checked resulting HTML

Change-Id: Ic0d1e9ff2703c87d4007f0092a2f8dfe0efca6db
2017-05-25 16:10:08 -07:00
Selim Gurun
b18fbfa95f Update documentation for postmessage method
Bug: 35012584

Move wildcard description to body from parameter, as per API
documentation guidelines.

Test: documentation change

Change-Id: Ibf93bcd5bf509898d293db5729b760f5e1b023b4
2017-05-18 23:46:51 +00:00
Jeff Sharkey
12f4b76db2 Merge "Unbreak even more APK 26 apps running on "O" preview/beta builds." into oc-dev am: 997042ac33
am: c244963675

Change-Id: I30e0155a9260ec4099ad45d7161c8459c8b657a2
2017-05-18 16:11:07 +00:00
Jeff Sharkey
f383c24749 Unbreak even more APK 26 apps running on "O" preview/beta builds.
Bug: 38391358
Test: builds
Change-Id: Ic48f9cb53da3ed8241e5d40d3096304ee4dfebd2
2017-05-17 17:53:38 -06:00
TreeHugger Robot
285f9ff995 Merge "Take better control over Exceptions thrown in WebViewFactory." 2017-05-15 17:10:58 +00:00
Gustav Sennton
b715d405b5 Take better control over Exceptions thrown in WebViewFactory.
Turn WebViewFactory.MissingWebViewPackageException into a non-runtime
exception to avoid potential bugs where we miss catching that exception.

Also introduce a new exception specifically for IOExceptions thrown in
getLoadFromApkPath().

Bug: 28736099
Test: make an Angler build.

Change-Id: Ib07257eaefaaa79d7ea45ba0f609be7263438f6c
2017-05-15 13:19:35 +01:00