-
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.
- Loading branch information
1 parent
8181774
commit c6e5bda
Showing
29 changed files
with
431 additions
and
100 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,54 @@ | ||
/* 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/common/webui_url_constants.h" | ||
#include "brave/components/nft_display/resources/grit/nft_display_generated_map.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); | ||
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)); | ||
|
||
// TODO(nvonpentz) Determine CSP. Commented below was copied from trezor_ui.cc | ||
// | ||
// untrusted_source->OverrideContentSecurityPolicy( | ||
// network::mojom::CSPDirectiveName::StyleSrc, | ||
// std::string("style-src 'unsafe-inline';")); | ||
untrusted_source->AddResourcePath("load_time_data.js", | ||
IDR_WEBUI_JS_LOAD_TIME_DATA_JS); | ||
untrusted_source->UseStringsJs(); | ||
untrusted_source->AddString("braveWalletNftBridgeUrl", kUntrustedNftURL); | ||
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/common/url_constants.h" | ||
#include "ui/webui/untrusted_web_ui_controller.h" | ||
#include "ui/webui/webui_config.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 ui::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
Oops, something went wrong.