Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] use CWVWebView embedder in iOS #24657

Draft
wants to merge 60 commits into
base: master
Choose a base branch
from
Draft

Conversation

kylehickinson
Copy link
Collaborator

@kylehickinson kylehickinson commented Jul 15, 2024

Do not merge, meant for gathering feedback on this solution's direction

Running list:

Needs Migration

  • session restoration data check/migration: SessionTab holds onto WKWebView.interactionState, need to drop it or ignore it while restoring CWVWebView and vice-versa.
  • Optional: Use HTTPS Upgrade tab helpers

Broken Features

  • SSL certificate pinning (not supported by Chromium)
  • block javascript shield (not supported by Chromium)
  • link previews (not supported by Chromium)
  • sampled top page color KVO (private API)
  • redirected loads (getInternalRedirect, loading a new request before cancelling an active load) on pages that fail to load in the end hit DCHECK (e.g. http://api.segment.io will get upgraded to https but the link itself is blocked by PiHole/content blockers)
  • CWVWebViewConfiguration teardown needs to be added to WebMainParts

Bugs

  • multiple downloads at once (UI-only: progress doesn't show combined, downloads are parallel now. Chrome only allows one download a time, so we're doing the same for now)
  • URL debounce breaks certain loads (Load this TomsGuide page and click on the Amazon refs, its supposed to open a new tab because its marked as target=_blank but debounce breaks this)
  • Crashes when attempting to start a download that is triggered on a new tab (e.g. https://1password.com/downloads/mac)
  • Popup/child tabs receive JS messages from the parent tab incorrectly

Cosmetic Issues

Product Changes

  • user agent contains CriOS
  • error pages now match desktop/android but lose Brave branding
  • iPad uses mobile user agent by default, controlled by pref

Accesses WebKit

These access -[CWVWebView(Extras) underlyingWebView] or -[CWVWebView(Extras) WKConfiguration] directly and should be migrated over if possible

  • content blockers access (WKWebViewConfiguration)
  • cookie store access (WKWebViewConfiguration). There is web::BrowserState::GetCookieManager() that may be a replacement
  • deprecated javascript control preference (WKWebViewConfiguration)
  • Sampled page top color (WKWebView - private API)
  • PDF data in Leo (WKWebView - private API)
  • zoom level (WKWebView - private API). There is FontSizeTabHelper as a replacement but it's worse
  • playlist web loader (WKWebView - loadHTMLString), only exposed for testing in Chromium

Cleanup

  • remove user agent from BraveCoreMain initializer
  • fix unit tests
  • fixme's
  • optimize patches/overrides
  • layering violation fixes
  • gn check pass
  • presubmit pass
  • document what's accessible from CWVWebView

New Feature Support

These will get follow-up issues and can be implemented after this merges

  • Autofill Passwords
  • Autofill Credit Cards
  • Autofill Addresses
  • Swap to Chromium safe browsing implementation
  • Support simultaneous downloads

Security Checklist

TBD

@kylehickinson kylehickinson self-assigned this Jul 15, 2024
common_flags = [ "-fapplication-extension" ]
cflags_objc = common_flags
cflags_objcc = common_flags
defines = [ "CWV_IMPLEMENTATION" ]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be redefined for cwv_exports.h to properly export the symbols since we're copying public headers as-is

@kylehickinson kylehickinson added CI/skip Do not run CI builds (except noplatform) CI/skip-all-linters Do not run linters and presubmit checks labels Jul 15, 2024
@stoletheminerals stoletheminerals self-requested a review July 16, 2024 11:26
Comment on lines 1397 to 1414
if webView.fullscreenState == .inFullscreen || webView.fullscreenState == .enteringFullscreen {
webView.closeAllMediaPresentations {
self.present(alertController, animated: true)
}
return
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kylehickinson kylehickinson force-pushed the ios-cwvwebview branch 5 times, most recently from 6ccffe6 to 66895b3 Compare July 23, 2024 17:08

# This file exposes the //ios/web_view embedder as a regular source_set

ios_web_view_public_headers = [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this different from ios_web_view_public_headers in ios/web_view/BUILD.gn? If so it would be better to use +=/-= instead of duplicating

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parts under our own 1 extra public header aren't different but since the original list is defined in a GN file and not GNI I couldn't access them to add into our framework so for now it was duped. If its possible to get to let me know!

@kylehickinson kylehickinson force-pushed the ios-cwvwebview branch 2 times, most recently from 4be9903 to 0231609 Compare July 25, 2024 16:12
kylehickinson and others added 29 commits October 18, 2024 13:51
this is already handled by Chromium
rewrites `chrome` schemes to `brave` when formatting and loads them as standard requests
also now correctly destroys private mode data upon last private mode left
this disassociates explicit Tabs being mapped to a given message handler, and now passes in the correct tab based on the web view. This change also exposes the underlying WKWebView from CRWWebController which makes it safer to access
fixes a crash if the notifier dies without the observer being removed from the underlying WKWebView
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/skip Do not run CI builds (except noplatform) CI/skip-all-linters Do not run linters and presubmit checks CI/storybook-url Deploy storybook and provide a unique URL for each build needs-security-review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants