Commit Graph

3506 Commits

Author SHA1 Message Date
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
Andrew Solovay
9b6cdc584d Merge "docs: Changing "http" to "https" in Javadoc examples" into oc-dev am: c159323ebd
am: e6fa70bcec

Change-Id: Ie3d6b1468dc276aa5fcf64b34da517b87370ed26
2017-05-08 22:36:04 +00:00
Andrew Solovay
51142577ab docs: Changing "http" to "https" in Javadoc examples
Several of the Javadoc comments had code snippets that used "http"
web addresses (e.g. "http://example.com"). Our style heavily
recommends using https whenever possible; in addition, this caused
the generated Javadoc files to fail presubmit checks when we try
to migrate them to Piper (see, e.g., http://cl/155212684)

In addition, one code snipped used (as an example) a link to
http://slashdot.org/ ; we really shouldn't be using links to real
websited (that we don't control) unless we absolutely have to.

I changed all the examples to "https://example.com/" ; I've verified
that that's a valid URL (they've got a good certificate).

Generated the doc and staged it to:
go/dac-stage/reference/android/webkit/WebView.html

Test: make ds-docs
Bug: 37996959
Change-Id: Id8e44930b107b94022376a260892ed867ba281fc
2017-05-05 17:09:46 -07:00
TreeHugger Robot
eff8ed36b4 Merge "Add a time-out for connecting to SystemServer, and WebView, zygotes." 2017-05-02 10:00:27 +00:00
Gustav Sennton
f0c52b5e9c Add a time-out for connecting to SystemServer, and WebView, zygotes.
We wait for both the system server and the WebView zygotes, using
infinite loops.
This CL adds a time-out to both these loops.

Bug: 37654329
Test: Boot device, disable Chrome, enable Chrome, then start a WebView
app.

Change-Id: I74397de3caf2b02ee403195aeb3beb2320a2240d
2017-04-28 15:05:12 +01:00
Tima Vaisburd
5544f6c63b Hide onMovedToDisplay for WebView
Bug: 37724053
Test: Not needed
Change-Id: Ic6decc3be65e6b16f8fb42149f3e0798e855d4b7
2017-04-27 14:24:24 -07:00
Tima Vaisburd
2240ea6448 Hide getTextClassifier and setTextClassifier for WebView
Bug: 37724053
Test: Not needed, these methods have not been implemented.
Change-Id: I43c97cb13e80eeb13d53123a22230d5934b8a60d
2017-04-26 21:59:12 -07:00
Gustav Sennton
3202c10207 Merge "Explicitly wait for the WebView Zygote." into oc-dev 2017-04-25 16:05:58 +00:00
Gustav Sennton
833813cecc Explicitly wait for the WebView Zygote.
There is a time-window during which the WebViewZygote service has
started, but can't be connected to. To avoid crashing during this
time-window we add a retry-loop in this CL to explicitly initiate a
connection to the Zygote.

Bug: 36687066
Test: gts-tradefed run gts --module GtsWebViewHostTestCases
Change-Id: Ia58a3342cd4e149621ba6b4aaf926e7b53c06d8f
2017-04-24 16:08:39 +01:00
Abodunrinwa Toki
3f3354e087 Undeprecate WebView.findAddress
Reverts I772961bd20bff4817a060f14a843abeceb55ac92
Until we bring back TextClassifier.getLinks
See I275a9d055ef0ab68f3ca339c37ee939257c4bd54

Test: none
Bug: 22362008
Bug: 37565246
Change-Id: I2948f22cf4c3462491f47376af48624697703969
2017-04-24 14:41:14 +00:00
Selim Gurun
9858e5372a Deprecate findAddress() method
FindAddress method only ever worked on US addresses and being a part
of WebView API, it required the users that did not use WebView otherwise
to pay a heavy penalty. Further, it was also used by Linkify.

The new way to find addresses is using TextClassifier.

Bug: 22362008
Test: WebView.findAddress.

Change-Id: I772961bd20bff4817a060f14a843abeceb55ac92
2017-04-11 11:18:49 -07:00
Selim Gurun
ec0a1f2599 Add an API to enable disable safebrowsing in WebView
WebView safebrowsing can be opted in using a manifest value. However,
we also need to control individual WebViews.

Bug:37158813
Test: See change I71e813bccc2fab73d100384661128c7311dd396c

Change-Id: I647dc304787d6406691b5cbadf1c9a4f13ac5604
2017-04-07 18:46:18 -07:00
Tima Vaisburd
134752b471 Added onMovedToDisplay method to WebView
Delegate the action to WebViewProvider, by default it is no-op.

Bug: 36006397
Test: There is no implementation yet to test.
Change-Id: Ib5101d3669a92ae81cfb34cc5db607c374712a3d
2017-04-06 15:50:05 -07:00
Selim Gurun
13e5b0bb97 Disable WebView autocomplete feature.
Platform is now providing autofill feature. Disable WebView's simple
form data save feature for platform O and above.

Test: Removing the functionality and the test
Bug: 36869838

Change-Id: If6b9fc12edbe4146fca99d9c6ef8fde36d61f852
2017-04-04 10:19:28 -07:00
TreeHugger Robot
4d558930c8 Merge "Created an HtmlInfo object on ViewStructure." into oc-dev 2017-04-01 02:34:03 +00:00
TreeHugger Robot
c7f474668e Merge "Override View.autofill() method and call into ViewDelegate" into oc-dev 2017-03-31 02:57:38 +00:00
Philip P. Moltmann
81192b40de Rename autoFillHint to autoFillHints.
Fixes: 35364993
Test: cts-tradefed run cts-dev -m CtsAutoFillServiceTestCases
Change-Id: I65a4c2c65563e7bbd60c4e99c8800b0b11af2300
(cherry picked from commit feb3299ed5)
2017-03-30 23:45:33 +00:00
Tao Bai
a5717331d1 Override View.autofill() method and call into ViewDelegate
BUG: 36787841

Test: this just forwards api call.
Change-Id: Ie2c9675e5a7ee2ed2a7997d1270cf388571a855b
2017-03-30 15:02:53 -07:00
Felipe Leme
25bf787ffb Created an HtmlInfo object on ViewStructure.
The ViewStructure typically represents a View, but it it can also be a virtual
view; in particular, WebView uses virtual views to represent HTML elements.

Although most of the properties of the HTML element maps to properties of
Android Views, some properties (such as 'name' and 'id' on <INPUT> fields)
don't, and those are crucial for autofilling web pages.

Rather than trying to artificially map these properties, it's better to create
a generic representation, for the following reasons:

1. Web standards move in a different velocity than Android APIs
2. Android APIs cannot be changed easily. Deprecated APIs continue to work,
   and new added APIs don't work in older versions
3. The data used for autofill is opaque to the Framework - it's only relevant
   to the node producers (like WebView) and consumers (Autofill services).

Also removed the setIdEntry() that was used for the same purpose.

Fixes: 36696757
Bug: 36718508
Test: VirtualContainerActivityTest with new checks pass

Change-Id: Ia626bd1f640b0b5861e81a5915504b95029874c9
2017-03-30 14:24:05 -07:00
Tima Vaisburd
cf49a23b3c TextClassifier: add API to WebView
Delegate the actions to WebViewProvider, by default they are no-ops.

Bug: 34780392
Test: Existing tests should be enough
Change-Id: Iefb1045b44a6e8cee5d1cc2c9b194b392d33f36d
2017-03-28 14:24:16 -07:00
Torne (Richard Coles)
0452670374 Support loading a stub WebView using a donor package.
Support loading a WebView package which specifies the name of a "donor"
that provides missing files. This allows a preinstalled stub WebView to
function by loading its code and assets from the preinstalled Monochrome
implementation, as long as the versions are close enough that the
manifest contents are compatible, which should be fine since
preinstalled versions will match.

To do this, we replace the stub's code paths in AppplicationInfo with
the donor's, so that all Java and native code and resources are loaded
from the donor APK at runtime instead of from the (mostly empty) stub.

To get the ClassLoader with the modified path cached as if it was the
regular path, we introduce a new "cacheKey" parameter in
ApplicationLoaders.

Bug: 21643067
Test: build "new" stub WebView upstream in chromium and test loading
Change-Id: I08cc9122b1c9def3e1206974f3e0e8973cca3419
2017-03-28 16:21:10 +00:00
Gustav Sennton
f05f99b910 Post WebView Zygote connection code to a background thread.
Currently, the act of waiting for the WebView Zygote to start running,
and then connecting to it is run in a blocking way from
WebViewZygote.onWebViewProviderChanged(). This causes us to block large
parts of WebViewUpdateService for a long time whenever we change WebView
provider.
This CL moves the blocking code onto a background thread to unblock
WebViewUpdateService.

Bug: 35025131
Test: Ensure changing WebView provider from the WebView Implementation
Developer Setting is quick/responsive.
Test: Turn off WebView multi-process and ensure the WebView Zygote
Service is NOT started.
Test: Turn on WebView multi-process and ensure the WebView Zygote
Service is started.

Change-Id: I0b378a471491d40cbf027568ca317d6c080da4b2
2017-03-24 12:36:12 +00:00
TreeHugger Robot
709ff779e6 Merge "Improved WebView -> ViewStructure mapping for Autofill." 2017-03-21 19:49:43 +00:00
Felipe Leme
1a1e4687e4 Improved WebView -> ViewStructure mapping for Autofill.
Added setIdEntry() on ViewStructure and documented how WebView can map HTML
tags and attributes into ViewStructure.

Test: VirtualContainerActivityTest pass
Test: m update-api
Bug: 36056207

Change-Id: Idaee9612d2c1b1adac99f354c8f87137ee9ef877
2017-03-20 17:54:33 -07:00
Robert Sesek
450b55bbd9 Do not allow WebView instantiation from privileged processes.
Test: Patched in CL on bug, got UnsupportedOperationException
Bug: 36077109
Change-Id: I01dba02407dd7b1ea1ce22f0023f8882e1e96dae
2017-03-16 18:18:13 -04:00
TreeHugger Robot
642028fccd Merge "Replaced auto-fill by autofill to keep it consistent with API style." 2017-03-10 07:05:41 +00:00
Nate Fischer
f7683a6f17 Merge "Add WebView Safe Browsing error code" 2017-03-09 22:14:31 +00:00
Felipe Leme
640f30a776 Replaced auto-fill by autofill to keep it consistent with API style.
This change will affects 2 types of apps: autofill service implementations
and apps that use autofill APIs.

Since just the former is known to be used at the moment, we're not trying
to keep backward compatibility with the latter.

Bug: 35956626
Test: CtsAutoFillServiceTestCases pass
Test: android.provider.SettingsBackupTest pass

Change-Id: Ia720083508716deae9e887f9faa7ae7c5a82f471
2017-03-09 08:14:49 -08:00
Felipe Leme
d04a697ede Optimize ViewStructure for autofill by removing irrelevant nodes.
Test: CtsAutoFillServiceTestCases (with new tests) pass
Fixes: 35840787

Change-Id: Iaa2c1907c8383b4a820fd7204e67fa2d276ad2b8
2017-03-08 13:31:38 -08:00
Gustav Sennton
4cbfe71bba Update WebView.getCurrentWebViewPackage documentation.
Explain when a WebView implementation change can occur, and what happens
when it occurs.

Bug: 35764852
Test: None (java-doc change).
Change-Id: I2d2bcccc2f16bc911636373bb47c64d846f15b2d
2017-03-07 14:33:13 +00:00
Nate Fischer
3c7c937060 Add WebView Safe Browsing error code
This adds a Safe Browsing specific network error code for WebView. This
will be returned when we cancel page load because the end user has
clicked "Back to safety" on an interstitial page, the WebView is too
small to display a readable interstitial page, or other similar cases.

When this is used due to an unsafe subresource, the error passed to
WebViewClient#OnReceivedError() will be associated with that specific
resource, not the main frame.

Bug: 36007752
Test: N/A
Change-Id: I8b149a9d6e4ed113de0dd8ee051a2934af477128
2017-03-06 18:25:07 -08:00
Dimitry Ivanov
638d810099 Add isBundled argument to LoadedApk.makePaths call
There is a disconnect between the way webview created
classloader and the way makePaths decides if paths are
intended for bundled app.

This change moves decision making out of makePaths method
which allows WebViewZygote to pass correct argument and
have makePath omit java.library.path for libPaths

Bug: http://b/35426785
Test: manual
Change-Id: Iab5a18c0091d0193dafa750498eb00f378411ba0
2017-02-22 23:52:01 -08:00
Gustav Sennton
f9295bcc24 Merge "Make sure we cannot use packages targeting pre-O as WebView packages." 2017-02-02 14:34:04 +00:00
Gustav Sennton
564c2fd5db Make sure we cannot use packages targeting pre-O as WebView packages.
Using a WebView package targeting a release before O as WebView provider
on O will cause crashes (because of incompatibility issues), this CL
makes us interpret a package targeting a pre-O release as being invalid
on O.

Also remove the code that lets us fall back to loading the old
WebViewChromiumFactoryProvider (pre-O) class.

Bug: 34773740
Bug: 34180497
Test: Ensure WebView provider with targetSdkVersion="O" shows up in the
WebView Implementation Dev Setting, ensure targetSdkVersion=25 doesn't
show up.
Test: Add WVUS unit test to ensure a packages with targetSdkVersion < 26
are considered invalid, and > 26 are valid. Run WVUS unit tests.

Change-Id: I4d80d46019e2522bc3fc6068712d28eedb31fcce
2017-02-01 13:59:26 +00:00