-
Notifications
You must be signed in to change notification settings - Fork 905
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add about:payments and basic web ui handler
- Loading branch information
Showing
14 changed files
with
175 additions
and
9 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
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,64 @@ | ||
/* 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/basic_ui.h" | ||
|
||
#include "brave/common/url_constants.h" | ||
#include "chrome/browser/profiles/profile.h" | ||
#include "components/grit/brave_components_resources.h" | ||
#include "content/public/browser/web_ui_data_source.h" | ||
#include "content/public/browser/web_ui_message_handler.h" | ||
#include "ui/base/resource/resource_bundle.h" | ||
|
||
using content::WebContents; | ||
using content::WebUIMessageHandler; | ||
|
||
namespace { | ||
|
||
content::WebUIDataSource* CreateBasicUIHTMLSource(const std::string& name) { | ||
content::WebUIDataSource* source = | ||
content::WebUIDataSource::Create(kPaymentsHost); | ||
|
||
if (name == kPaymentsHost) { | ||
source->AddResourcePath(kPaymentsJS, IDR_BRAVE_PAYMENTS_JS); | ||
source->SetDefaultResource(IDR_BRAVE_PAYMENTS_HTML); | ||
} | ||
|
||
return source; | ||
} | ||
|
||
// The handler for Javascript messages for Brave about: pages | ||
class BasicDOMHandler : public WebUIMessageHandler { | ||
public: | ||
BasicDOMHandler() { | ||
} | ||
~BasicDOMHandler() override {} | ||
|
||
void Init(); | ||
|
||
// WebUIMessageHandler implementation. | ||
void RegisterMessages() override; | ||
|
||
private: | ||
DISALLOW_COPY_AND_ASSIGN(BasicDOMHandler); | ||
}; | ||
|
||
void BasicDOMHandler::RegisterMessages() { | ||
} | ||
|
||
void BasicDOMHandler::Init() { | ||
} | ||
|
||
} // namespace | ||
|
||
BasicUI::BasicUI(content::WebUI* web_ui, const std::string& name) | ||
: WebUIController(web_ui) { | ||
Profile* profile = Profile::FromWebUI(web_ui); | ||
|
||
auto handler_owner = base::MakeUnique<BasicDOMHandler>(); | ||
BasicDOMHandler* handler = handler_owner.get(); | ||
web_ui->AddMessageHandler(std::move(handler_owner)); | ||
handler->Init(); | ||
content::WebUIDataSource::Add(profile, CreateBasicUIHTMLSource(name)); | ||
} |
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,27 @@ | ||
/* 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_BASIC_UI_H_ | ||
#define BRAVE_BROWSER_UI_WEBUI_BASIC_UI_H_ | ||
|
||
#include <string> | ||
|
||
#include "base/compiler_specific.h" | ||
#include "base/macros.h" | ||
#include "content/public/browser/web_ui_controller.h" | ||
|
||
class BasicUI : public content::WebUIController { | ||
public: | ||
explicit BasicUI(content::WebUI* web_ui, const std::string& host); | ||
~BasicUI() override {} | ||
|
||
private: | ||
DISALLOW_COPY_AND_ASSIGN(BasicUI); | ||
}; | ||
|
||
namespace basic_ui { | ||
|
||
} // namespace basic_ui | ||
|
||
#endif // BRAVE_BROWSER_UI_WEBUI_BASIC_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#include "brave/common/url_constants.h" | ||
|
||
const char kPaymentsHost[] = "payments"; | ||
const char kPaymentsJS[] = "brave_payments.js"; |
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,12 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width"> | ||
<title>Payments</title> | ||
<link rel="stylesheet" href="chrome://resources/css/text_defaults.css"> | ||
<script src="chrome://payments/brave_payments.js"></script> | ||
<body> | ||
Brave Payments | ||
</body> | ||
</html> |
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 @@ | ||
console.log('brave_payments.js loaded') |
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,15 @@ | ||
import("//printing/features/features.gni") | ||
import("//tools/grit/grit_rule.gni") | ||
|
||
grit("brave_components_resources_grit") { | ||
source = "brave_components_resources.grd" | ||
|
||
output_name = "brave_components_resources_new" | ||
outputs = [ | ||
"grit/brave_components_resources.h", | ||
"brave_components_resources.pak", | ||
] | ||
output_dir = "$root_gen_dir/components" | ||
resource_ids = "//brave/browser/resources/resource_ids" | ||
} | ||
|
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,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<grit latest_public_release="0" current_release="1" output_all_resource_defines="false"> | ||
<outputs> | ||
<output filename="grit/brave_components_resources.h" type="rc_header"> | ||
<emit emit_type='prepend'></emit> | ||
</output> | ||
<output filename="brave_components_resources.pak" type="data_package" /> | ||
</outputs> | ||
<release seq="1"> | ||
<includes> | ||
<include name="IDR_BRAVE_PAYMENTS_HTML" file="../brave_payments_ui/brave_payments.html" type="BINDATA" /> | ||
<include name="IDR_BRAVE_PAYMENTS_JS" file="../brave_payments_ui/brave_payments.js" type="BINDATA" /> | ||
</includes> | ||
</release> | ||
</grit> |
21 changes: 21 additions & 0 deletions
21
patches/chrome-browser-ui-webui-chrome_web_ui_controller_factory.cc.patch
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,21 @@ | ||
diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc | ||
index 6d3b59691af1d5d05024dc37e8a4a2c8a023a700..4dac0261acaadebe8daf5dbe8a0aabdf07eb0b32 100644 | ||
--- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc | ||
+++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc | ||
@@ -11,6 +11,7 @@ | ||
#include "base/bind.h" | ||
#include "base/location.h" | ||
#include "base/threading/thread_task_runner_handle.h" | ||
+#include "brave/browser/ui/webui/brave_web_ui_controller_factory.h" | ||
#include "build/build_config.h" | ||
#include "chrome/browser/about_flags.h" | ||
#include "chrome/browser/devtools/devtools_ui_bindings.h" | ||
@@ -726,7 +727,7 @@ void ChromeWebUIControllerFactory::GetFaviconForURL( | ||
|
||
// static | ||
ChromeWebUIControllerFactory* ChromeWebUIControllerFactory::GetInstance() { | ||
- return base::Singleton<ChromeWebUIControllerFactory>::get(); | ||
+ return BraveWebUIControllerFactory::GetInstance(); | ||
} | ||
|
||
ChromeWebUIControllerFactory::ChromeWebUIControllerFactory() { |