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] Prepare CWVWebView web embedder for use in iOS #26957

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kylehickinson
Copy link
Collaborator

@kylehickinson kylehickinson commented Dec 10, 2024

This is the split-up contents of #24657. This PR in particular only adds the CWVWebView API and exposes it to the iOS app but does not actually contain the code that uses CWVWebView in the iOS app. There is a shell target added (WebShell) for simple tests, for more comprehensive tests involving multiple tabs, please use the ios-cwvwebview-impl branch

Resolves brave/brave-browser#42838

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

@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 labels Dec 10, 2024
@kylehickinson kylehickinson self-assigned this Dec 10, 2024
@kylehickinson kylehickinson requested review from a team as code owners December 10, 2024 18:15
@kylehickinson kylehickinson requested a review from a team as a code owner January 13, 2025 14:48
Copy link
Contributor

[puLL-Merge] - brave/brave-core@26957

Description

This PR introduces significant changes to the iOS WebView implementation for the Brave browser. It adds new functionality, overrides some Chromium behaviors, and integrates Brave-specific features into the WebView component.

Possible Issues

  1. The PR introduces a large number of new files and modifications, which could potentially lead to integration issues or conflicts with existing code.
  2. Some of the changes override Chromium's default behaviors, which might lead to unexpected side effects or divergence from standard WebView functionality.

Security Hotspots

  1. The modifications to SSL error handling and certificate pinning (cwv_ssl_status_extras.mm and cwv_x509_certificate_extras.mm) should be carefully reviewed to ensure they don't introduce any security vulnerabilities.
  2. The changes to JavaScript execution and content world handling in cwv_web_view_extras.mm could potentially affect the security boundaries between different script contexts.
Changes

Changes

  1. ios/app/brave_core_main.mm:

    • Added support for WebView configuration and browser state management.
    • Implemented methods for handling private browsing and incognito profiles.
  2. ios/browser/web/:

    • Created a new directory with implementations for BraveWebClient and BraveWebMainParts.
    • Added utility functions for JavaScript blocking and universal link handling.
  3. ios/web_view/:

    • Added new files for extending CWVWebView, CWVSSLStatus, and CWVX509Certificate functionality.
    • Implemented Brave-specific overrides for various WebView behaviors.
  4. ios/chrome/browser/https_upgrades/model/https_only_mode_upgrade_tab_helper.mm:

    • Modified HTTPS upgrade logic to handle forward/back navigation differently.
  5. ios/web/navigation/crw_wk_navigation_handler.mm:

    • Added hooks for Brave-specific behavior in navigation handling and error processing.
  6. ios/web/web_state/ui/wk_web_view_configuration_provider.mm:

    • Added a hook for Brave-specific configuration reset.
  7. ios/web_view/BUILD.gn:

    • Modified build configuration to exclude certain Chromium sources and include Brave-specific ones.
  8. ios/web_view/public/cwv_navigation_delegate.h:

    • Added new delegate methods for Brave-specific navigation behaviors.
  9. ios/web_view/public/cwv_web_view.h:

    • Modified visibleURL property to be nullable.
sequenceDiagram
    participant App as Brave iOS App
    participant Core as BraveCoreMain
    participant WebView as CWVWebView
    participant Client as BraveWebClient
    participant Handler as CRWWKNavigationHandler
    
    App->>Core: Initialize
    Core->>WebView: Create with configuration
    WebView->>Client: Set up web client
    WebView->>Handler: Set up navigation handler
    Handler->>Client: Handle navigation actions
    Client->>Handler: Apply Brave-specific behaviors
    Handler->>WebView: Update navigation state
    WebView->>App: Present web content
Loading

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 puLL-Merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for using Chromium's web embedder CWVWebView
2 participants