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

[iOS] Use Chromium web embedder (CWVWebView) #24657

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

kylehickinson
Copy link
Collaborator

@kylehickinson kylehickinson commented Jul 15, 2024

Resolves brave/brave-browser#38667

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 load behaviours (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
  • Back/forward navigation with on http websites hits a DCHECK (Chromium bug)

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
  • safe browsing private API for sec fix (WKWebView - private API)

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 1431
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 kylehickinson added CI/skip-android Do not run CI builds for Android CI/skip-macos-x64 Do not run CI builds for macOS x64 CI/skip-windows-x64 Do not run CI builds for Windows x64 CI/skip-macos-arm64 Do not run CI builds for macOS arm64 CI/skip-teamcity Do not run builds in TeamCity and removed CI/skip Do not run CI builds (except noplatform) CI/skip-all-linters Do not run linters and presubmit checks labels Oct 25, 2024
@kylehickinson kylehickinson marked this pull request as ready for review October 25, 2024 18:08
@kylehickinson kylehickinson requested review from a team as code owners October 25, 2024 18:08
@kylehickinson kylehickinson changed the title [wip] use CWVWebView embedder in iOS [iOS] Use Chromium web embedder (CWVWebView) Oct 25, 2024
@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

// Cleanup
self.braveSearchManager = nil
}
)
Copy link
Contributor

Choose a reason for hiding this comment

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

contentWorld: Self.scriptSandbox,
escapeArgs: false
) { (object, error) -> Void in
return
Copy link
Contributor

Choose a reason for hiding this comment

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

escapeArgs: false,
asFunction: true,
completion: nil
)
Copy link
Contributor

Choose a reason for hiding this comment

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

completionHandler: { value, error in
completion?(value, error)
}
)
Copy link
Contributor

Choose a reason for hiding this comment

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

escapeArgs: escapeArgs,
asFunction: asFunction
) { value, error in
continuation.resume(returning: (value, error))
Copy link
Contributor

Choose a reason for hiding this comment

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

contentWorld: contentWorld,
escapeArgs: escapeArgs,
asFunction: asFunction
)
Copy link
Contributor

Choose a reason for hiding this comment

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

escapeArgs: false,
asFunction: true,
completion: nil
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

The security team is monitoring all repositories for certain keywords. This PR includes the word(s) "password, safe browsing" and so security team members have been added as reviewers to take a look.

No need to request a full security review at this stage, the security team will take a look shortly and either clear the label or request more information/changes.

Notifications have already been sent, but if this is blocking your merge feel free to reach out directly to the security team on Slack so that we can expedite this check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/skip-android Do not run CI builds for Android CI/skip-macos-arm64 Do not run CI builds for macOS arm64 CI/skip-macos-x64 Do not run CI builds for macOS x64 CI/skip-teamcity Do not run builds in TeamCity CI/skip-windows-x64 Do not run CI builds for Windows x64 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.

[IOS] Use Chromium's web navigation delegates
5 participants