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

(Wallet) Implement WebUI for main portfolio screen #20635

Merged
merged 23 commits into from
Dec 7, 2023
Merged

Conversation

simoarpe
Copy link
Collaborator

@simoarpe simoarpe commented Oct 23, 2023

Resolves https://github.com/brave/roadmap/issues/944 (Roadmap issue)

Resolves brave/brave-browser#34386

Demo

webui-demo.mov

Details

Implement WebUI to show Android Wallet except for these parts that will remain native:

  • Onboarding
  • Authentication
  • Transaction confirmations

Header menus are hidden on Android.

Hardware Wallets are out of scope for this PR and not shown.

Expand button is shown for DApp websites as usual but is not shown when browsing Wallet pages.

Build Flag

The new WebUI implementation is behind a build flag currently set to true.
If the build flag is set to false the implementation will fall back to the old Android native version.
To enable/disable WebUI feature use brave_android_web_wallet_android boolean in android/buildflags/buildflags.gni.

We decided to go in favor of a leaner approach: #20635 (comment)

Known issues:

Security

Requested a security review: https://github.com/brave/reviews/issues/1455

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 lint, 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:

  • Navigate to Wallet and unlock it
  • Observe Wallet is displayed from a browser tab
  • Browser several pages and verify the behavior is correct and consistent
  • Reset the Wallet and observe the restore process has remained native
  • Perform a transaction and observe the native confirmation shows up

@simoarpe simoarpe added CI/skip-macos-x64 Do not run CI builds for macOS x64 CI/skip-ios Do not run CI builds for iOS CI/skip-windows-x64 Do not run CI builds for Windows x64 unused-CI/skip-linux-x64 Do not run CI builds for Linux x64 labels Oct 23, 2023
@simoarpe simoarpe self-assigned this Oct 23, 2023
@simoarpe simoarpe requested review from a team as code owners October 23, 2023 14:11
@github-actions github-actions bot added potential-layer-violation-fixes This PR touches a BUILD.gn file with check_includes=false CI/storybook-url Deploy storybook and provide a unique URL for each build feature/web3/wallet feature/web3/wallet/core labels Oct 23, 2023
Copy link
Contributor

@Douglashdaniel Douglashdaniel left a comment

Choose a reason for hiding this comment

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

++ Desktop FE

@simoarpe simoarpe force-pushed the simone/web-ui branch 3 times, most recently from b65adbf to 012f0f2 Compare November 2, 2023 14:54
Copy link
Collaborator

@mkarolin mkarolin left a comment

Choose a reason for hiding this comment

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

chromium_src++
grd++

@simoarpe simoarpe requested a review from a team as a code owner November 15, 2023 12:32
@simoarpe simoarpe removed the unused-CI/skip-linux-x64 Do not run CI builds for Linux x64 label Nov 15, 2023
@simoarpe simoarpe added the unused-CI/skip-linux-x64 Do not run CI builds for Linux x64 label Nov 15, 2023
Add assets, transactions, NFTs, rank and hardware path
Allow all URLs that are part of Wallet host

Wallet can be locked while on another page so WebUI needs the resources.
Implements new build flag `ENABLE_BRAVE_ANDROID_WEB_WALLET` and Gn constant
`brave_android_web_wallet_enabled`. When feature flag is set to false old native version
is used for Android Wallet. To enable/disable Android web Wallet use
`brave_android_web_wallet_enabled` in `android/buildflags/buildflags.gni`.
Makes restore button available only through native UI.
Copy link
Contributor

github-actions bot commented Dec 4, 2023

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

The provided patch modifies multiple files related to the Brave browser, specifically the android/java and browser/ui directories, affecting how the Brave Wallet feature is integrated and displayed within the browser on Android. Below, I'll provide a summarized explanation for each modified area:

  1. BraveActivity.java:

    • Adds constants for Brave Wallet's URL and host (e.g., "brave://wallet/crypto/portfolio/assets").
  2. BraveWalletActivity.java:

    • Removes code that sets up wallet navigation and backup reminders in the Android UI.
    • Calls WalletUtils.openWebWallet() to open the wallet in a web interface instead.
  3. DAppsWalletController.java:

    • Refactors and renames methods for initializing wallet-related services.
    • Adds logic to determine whether to show an "Expand Wallet" button in the wallet panel based on the current URL.
  4. BraveWalletPanel.java:

    • Introduces a showExpandButton flag. If true, an expand button is shown, allowing users to open the full wallet. The flag is set based on the URL's host, hiding the button for the wallet screen.
    • Modifies the constructor to receive the showExpandButton flag as an argument.
  5. WalletUtils.java:

    • Adds the openWebWallet() utility method, used to open the Brave Wallet in a new or existing tab.
  6. brave_wallet_panel_layout.xml:

    • Sets the visibility of the expand wallet image to "gone" by default.
  7. BUILD.gn:

    • Refactors the GN build script, mainly moving some dependencies around and adjusting the conditional structure for different platforms.
  8. android_brave_strings.grd:

    • Minor formatting change (removal of extra whitespace).
  9. android_wallet_page_ui.cc and wallet_page_ui.cc:

    • Changes in the web UI classes to set up data sources for rendering WebUI pages on Android, including adding a boolean to indicate if it is an Android platform.
  10. brave_web_ui_controller_factory.cc:

    • Modifications in the factory that creates web UI controllers, including restructuring the conditional compilation directives and a bug fix to avoid crashing when opening the Brave Wallet if the wallet is locked.
  11. chrome_untrusted_web_ui_configs.cc:

    • Moves and adds configurations for untrusted web UI components, likely to include wallet-related features in the untrusted web UI whitelist.
  12. android_page_appearing_browsertest.cc:

    • Adds a browser test to ensure that the Wallet Portfolio page appears correctly.
  13. brave_wallet_ui components:

    • Several changes in UI components to adjust how wallet features are displayed and interacted with, including hiding certain features on Android and other small UI tweaks.
  14. webui_url_constants.h:

    • Removes Android-specific path constants related to the Brave Wallet.
  15. brave_components_resources.grd:

    • Rearranges the inclusion order of some resources, most likely to clean up and ensure proper compilation of resources.

In summary, the patch makes modifications across several parts of the Brave codebase to refine and adjust the wallet feature's UI presentation and integration, particularly focusing on Android. It also includes updates to the build system, refactoring of code, cleanup, and additional testing.

Copy link
Member

@kdenhartog kdenhartog left a comment

Choose a reason for hiding this comment

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

LGTM from security perspective

@simoarpe simoarpe merged commit fbc2b67 into master Dec 7, 2023
@simoarpe simoarpe deleted the simone/web-ui branch December 7, 2023 11:32
@github-actions github-actions bot added this to the 1.63.x - Nightly milestone Dec 7, 2023
@goodov
Copy link
Member

goodov commented Dec 7, 2023

@simoarpe this PR has all desktop builds disabled. master is currently broken because of it:

../../brave/browser/ui/webui/brave_wallet/wallet_page_ui.cc(82,11): error: call to member function 'AddString' is ambiguous
   82 |   source->AddString("isAndroid", false);
      |   ~~~~~~~~^~~~~~~~~
../..\content/public/browser/web_ui_data_source.h(52,16): note: candidate function
   52 |   virtual void AddString(base::StringPiece name,
      |                ^
../..\content/public/browser/web_ui_data_source.h(56,16): note: candidate function
   56 |   virtual void AddString(base::StringPiece name, const std::string& value) = 0;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/skip-ios Do not run CI builds for iOS 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/storybook-url Deploy storybook and provide a unique URL for each build feature/web3/wallet/core feature/web3/wallet potential-layer-violation-fixes This PR touches a BUILD.gn file with check_includes=false unused-CI/skip-linux-x64 Do not run CI builds for Linux x64
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wallet Web UI/2.0