-
Notifications
You must be signed in to change notification settings - Fork 868
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add NFT details screen * chore: remove console.log * chore: remove chrome://image prefix * chore: fix loading of nft asset use url params * chore: add skeleton loader for nft image * chore: check token id when deleting assets * chore: remove redundant lines * chore: add tokenId to dep list * feat: display visible asset modal asset icon in chrome-untrusted * chore: trim url * chore: add tokenId check when removing asset from visible assets list * chore: fix tokenBalanceRegistry keys to avoid duplicates for erc721 tokens * chore: refactor nft details screen * chore: add border-radius to nft image * feat: create react app for rendering nft details in a chrome-untrusted tab * Add string to access via loadTimeData object * Add configurations nft ui untrusted tab * Update build requirements for nft ui untrusted tab * Send message to nft iframe to update state * Added iframe component * Create components for diplaying nft content in chrome untrusted tab * Added utilities for communicating with nft chrome untrusted tab using postmessage * chore: remove unused component * chore: validate url to avoid xss attack * feat: change nft icon display from query parameter(imageUrl) to postmessage api * use specific targetOrigin in postMessage * chore: remove console.log * chore: fix feedback * chore: feedback * chore: add license header and documentation * Revert "chore: add tokenId check when removing asset from visible assets list" This reverts commit 440134d. This will be fixed in brave/brave-browser#24238 * chore: fix unstable test behaviour * chore: fix tests * chore: rename function * chore: refactor to avoid adding unnecessary string * chore: change copyright year * chore: add braveWalletLedgerBridgeUrl string * chore: use getWalletPageProxy * chore: useCallback
- Loading branch information
1 parent
15ece28
commit 0b6165f
Showing
46 changed files
with
925 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* Copyright (c) 2021 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/browser/ui/webui/brave_wallet/nft/nft_ui.h" | ||
|
||
#include <string> | ||
|
||
#include "brave/components/brave_wallet/browser/brave_wallet_constants.h" | ||
#include "brave/components/constants/webui_url_constants.h" | ||
#include "brave/components/l10n/common/locale_util.h" | ||
#include "brave/components/nft_display/resources/grit/nft_display_generated_map.h" | ||
#include "chrome/browser/ui/webui/webui_util.h" | ||
#include "chrome/grit/browser_resources.h" | ||
#include "chrome/grit/generated_resources.h" | ||
#include "components/grit/brave_components_resources.h" | ||
#include "content/public/browser/web_contents.h" | ||
#include "content/public/browser/web_ui_data_source.h" | ||
#include "ui/resources/grit/webui_generated_resources.h" | ||
|
||
namespace nft { | ||
|
||
UntrustedNftUI::UntrustedNftUI(content::WebUI* web_ui) | ||
: ui::UntrustedWebUIController(web_ui) { | ||
auto* untrusted_source = content::WebUIDataSource::Create(kUntrustedNftURL); | ||
|
||
for (const auto& str : brave_wallet::kLocalizedStrings) { | ||
std::u16string l10n_str = | ||
brave_l10n::GetLocalizedResourceUTF16String(str.id); | ||
untrusted_source->AddString(str.name, l10n_str); | ||
} | ||
|
||
untrusted_source->SetDefaultResource(IDR_BRAVE_WALLET_NFT_DISPLAY_HTML); | ||
untrusted_source->AddResourcePaths( | ||
base::make_span(kNftDisplayGenerated, kNftDisplayGeneratedSize)); | ||
untrusted_source->AddFrameAncestor(GURL(kBraveUIWalletPageURL)); | ||
untrusted_source->AddFrameAncestor(GURL(kBraveUIWalletPanelURL)); | ||
webui::SetupWebUIDataSource( | ||
untrusted_source, | ||
base::make_span(kNftDisplayGenerated, kNftDisplayGeneratedSize), | ||
IDR_BRAVE_WALLET_NFT_DISPLAY_HTML); | ||
untrusted_source->OverrideContentSecurityPolicy( | ||
network::mojom::CSPDirectiveName::ScriptSrc, | ||
std::string("script-src 'self' chrome-untrusted://resources " | ||
"chrome-untrusted://brave-resources;")); | ||
untrusted_source->OverrideContentSecurityPolicy( | ||
network::mojom::CSPDirectiveName::StyleSrc, | ||
std::string("style-src 'self' 'unsafe-inline';")); | ||
untrusted_source->OverrideContentSecurityPolicy( | ||
network::mojom::CSPDirectiveName::FontSrc, | ||
std::string("font-src 'self' data:;")); | ||
untrusted_source->AddResourcePath("load_time_data.js", | ||
IDR_WEBUI_JS_LOAD_TIME_DATA_JS); | ||
untrusted_source->UseStringsJs(); | ||
untrusted_source->AddString("braveWalletNftBridgeUrl", kUntrustedNftURL); | ||
untrusted_source->AddString("braveWalletTrezorBridgeUrl", | ||
kUntrustedTrezorURL); | ||
untrusted_source->AddString("braveWalletLedgerBridgeUrl", | ||
kUntrustedLedgerURL); | ||
untrusted_source->OverrideContentSecurityPolicy( | ||
network::mojom::CSPDirectiveName::ImgSrc, | ||
std::string("img-src 'self' https: data:;")); | ||
auto* browser_context = web_ui->GetWebContents()->GetBrowserContext(); | ||
content::WebUIDataSource::Add(browser_context, untrusted_source); | ||
} | ||
|
||
UntrustedNftUI::~UntrustedNftUI() = default; | ||
|
||
std::unique_ptr<content::WebUIController> | ||
UntrustedNftUIConfig::CreateWebUIController(content::WebUI* web_ui) { | ||
return std::make_unique<UntrustedNftUI>(web_ui); | ||
} | ||
|
||
UntrustedNftUIConfig::UntrustedNftUIConfig() | ||
: WebUIConfig(content::kChromeUIUntrustedScheme, kUntrustedNftHost) {} | ||
|
||
} // namespace nft |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* Copyright (c) 2021 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_BROWSER_UI_WEBUI_BRAVE_WALLET_NFT_NFT_UI_H_ | ||
#define BRAVE_BROWSER_UI_WEBUI_BRAVE_WALLET_NFT_NFT_UI_H_ | ||
|
||
#include <memory> | ||
|
||
#include "content/public/browser/web_ui.h" | ||
#include "content/public/browser/webui_config.h" | ||
#include "content/public/common/url_constants.h" | ||
#include "ui/webui/untrusted_web_ui_controller.h" | ||
|
||
namespace nft { | ||
|
||
class UntrustedNftUI : public ui::UntrustedWebUIController { | ||
public: | ||
explicit UntrustedNftUI(content::WebUI* web_ui); | ||
UntrustedNftUI(const UntrustedNftUI&) = delete; | ||
UntrustedNftUI& operator=(const UntrustedNftUI&) = delete; | ||
~UntrustedNftUI() override; | ||
}; | ||
|
||
class UntrustedNftUIConfig : public content::WebUIConfig { | ||
public: | ||
UntrustedNftUIConfig(); | ||
~UntrustedNftUIConfig() override = default; | ||
|
||
std::unique_ptr<content::WebUIController> CreateWebUIController( | ||
content::WebUI* web_ui) override; | ||
}; | ||
|
||
} // namespace nft | ||
|
||
#endif // BRAVE_BROWSER_UI_WEBUI_BRAVE_WALLET_NFT_NFT_UI_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.